Skip to content

Commit

Permalink
Add table cell padding
Browse files Browse the repository at this point in the history
  • Loading branch information
spacez320 committed Dec 14, 2023
1 parent e99d40b commit 40c5d68
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions internal/lib/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (
)

const (
RESULTS_SIZE = 3 // Proportional size of the results widget.
LOGS_SIZE = 1 // Proportional size of the logs widget.
LOGS_SIZE = 1 // Proportional size of the logs widget.
RESULTS_SIZE = 3 // Proportional size of the results widget.
TABLE_PADDING = 2 // Padding for table cell entries.
)

var (
Expand Down Expand Up @@ -136,6 +137,7 @@ func RawResults() {
// Creates a table of results for the results pane.
func TableResults() {
resultsView := tview.NewTable().SetBorders(true)
tableCellPadding := strings.Repeat(" ", TABLE_PADDING)

initDisplay(resultsView, LogsView)

Expand All @@ -150,15 +152,19 @@ func TableResults() {
// Display the new result.
row := resultsView.InsertRow(i)
for j, token := range next.Values {
var nextCellContent string

// Extrapolate the field types in order to print them out.
switch token.(type) {
case int64:
row.SetCellSimple(i, j, strconv.FormatInt(token.(int64), 10))
nextCellContent = strconv.FormatInt(token.(int64), 10)
case float64:
row.SetCellSimple(i, j, strconv.FormatFloat(token.(float64), 'E', -1, 64))
nextCellContent = strconv.FormatFloat(token.(float64), 'f', -1, 64)
default:
row.SetCellSimple(i, j, token.(string))
nextCellContent = token.(string)
}

row.SetCellSimple(i, j, tableCellPadding+nextCellContent+tableCellPadding)
}

i += 1
Expand Down

0 comments on commit 40c5d68

Please sign in to comment.