|
|
|
@ -3,6 +3,7 @@ package ui |
|
|
|
|
import ( |
|
|
|
|
"cli-mon/yabl" |
|
|
|
|
"fmt" |
|
|
|
|
"github.com/gdamore/tcell/v2" |
|
|
|
|
tview "github.com/rivo/tview" |
|
|
|
|
"reflect" |
|
|
|
|
) |
|
|
|
@ -32,14 +33,14 @@ func (t *table) header(header string) *table { |
|
|
|
|
|
|
|
|
|
func (t *table) columns(name string, cols int) *table { |
|
|
|
|
for i := 1; i <= cols; i++ { |
|
|
|
|
t.SetCell(0, i, tview.NewTableCell(fmt.Sprintf("%s %d", name, i)).SetExpansion(2)) |
|
|
|
|
t.SetCell(0, i, tview.NewTableCell(fmt.Sprintf("%s %d", name, i)).SetExpansion(2)).SetBackgroundColor(tcell.ColorDefault) |
|
|
|
|
} |
|
|
|
|
return t |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (t *table) rows(name string, rows int) *table { |
|
|
|
|
for i := 1; i <= rows; i++ { |
|
|
|
|
t.SetCell(i, 0, tview.NewTableCell(fmt.Sprintf("%s %d", name, i))) //.SetExpansion(2))
|
|
|
|
|
t.SetCell(i, 0, tview.NewTableCell(fmt.Sprintf("%s %d", name, i))).SetBackgroundColor(tcell.ColorDefault) //.SetExpansion(2))
|
|
|
|
|
} |
|
|
|
|
return t |
|
|
|
|
} |
|
|
|
@ -47,7 +48,7 @@ func (t *table) rows(name string, rows int) *table { |
|
|
|
|
func newTable(params []key, min, max int, invert bool, short bool) *table { |
|
|
|
|
t := &table{} |
|
|
|
|
t.Box = tview.NewBox() |
|
|
|
|
t.SetBorderColor(tview.Styles.GraphicsColor) |
|
|
|
|
//t.SetBorderColor(tview.Styles.GraphicsColor)
|
|
|
|
|
t.SetSeparator(' ') |
|
|
|
|
t.SetContent(nil) |
|
|
|
|
t.SetBorders(true) |
|
|
|
@ -59,7 +60,7 @@ func newTable(params []key, min, max int, invert bool, short bool) *table { |
|
|
|
|
for i := min; i <= max; i++ { |
|
|
|
|
k := param |
|
|
|
|
k.id = uint(i) |
|
|
|
|
cell := tview.NewTableCell("") |
|
|
|
|
cell := tview.NewTableCell("").SetBackgroundColor(tcell.ColorDefault) |
|
|
|
|
t.views[k] = cell |
|
|
|
|
var col = i |
|
|
|
|
if min == 0 { |
|
|
|
@ -79,10 +80,11 @@ func newTable(params []key, min, max int, invert bool, short bool) *table { |
|
|
|
|
desc = fmt.Sprintf("%s.%s", param.action, param.field) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cell := tview.NewTableCell(desc).SetBackgroundColor(tcell.ColorDefault) |
|
|
|
|
if !invert { |
|
|
|
|
t.SetCell(int(param.id), 0, tview.NewTableCell(desc)) |
|
|
|
|
t.SetCell(int(param.id), 0, cell) |
|
|
|
|
} else { |
|
|
|
|
t.SetCell(0, int(param.id), tview.NewTableCell(desc)) |
|
|
|
|
t.SetCell(0, int(param.id), cell) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|