mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
move highlight method into textcol widget
This commit is contained in:
parent
56be64367b
commit
8fb5c5de59
@ -108,16 +108,6 @@ func (row *Compact) Buffer() ui.Buffer {
|
||||
return buf
|
||||
}
|
||||
|
||||
func (row *Compact) Highlight() {
|
||||
row.Name.TextFgColor = ui.ColorDefault
|
||||
row.Name.TextBgColor = ui.ColorWhite
|
||||
}
|
||||
|
||||
func (row *Compact) UnHighlight() {
|
||||
row.Name.TextFgColor = ui.ColorWhite
|
||||
row.Name.TextBgColor = ui.ColorDefault
|
||||
}
|
||||
|
||||
func (row *Compact) SetNet(rx int64, tx int64) {
|
||||
label := fmt.Sprintf("%s / %s", cwidgets.ByteFormat(rx), cwidgets.ByteFormat(tx))
|
||||
row.Net.Set(label)
|
||||
|
@ -24,6 +24,16 @@ func NewTextCol(s string) *TextCol {
|
||||
return &TextCol{p}
|
||||
}
|
||||
|
||||
func (w *TextCol) Highlight() {
|
||||
w.TextFgColor = ui.ThemeAttr("par.text.bg")
|
||||
w.TextBgColor = ui.ThemeAttr("par.text.fg")
|
||||
}
|
||||
|
||||
func (w *TextCol) UnHighlight() {
|
||||
w.TextFgColor = ui.ThemeAttr("par.text.fg")
|
||||
w.TextBgColor = ui.ThemeAttr("par.text.bg")
|
||||
}
|
||||
|
||||
func (w *TextCol) Reset() {
|
||||
w.Text = "-"
|
||||
}
|
||||
|
10
grid.go
10
grid.go
@ -36,7 +36,7 @@ func NewGrid() *Grid {
|
||||
func (g *Grid) cursorReset() {
|
||||
if len(g.containers) > 0 {
|
||||
g.cursorID = g.containers[0].Id
|
||||
g.containers[0].Widgets.Highlight()
|
||||
g.containers[0].Widgets.Name.Highlight()
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,9 +59,9 @@ func (g *Grid) cursorUp() {
|
||||
active := g.containers[idx]
|
||||
next := g.containers[idx-1]
|
||||
|
||||
active.Widgets.UnHighlight()
|
||||
active.Widgets.Name.UnHighlight()
|
||||
g.cursorID = next.Id
|
||||
next.Widgets.Highlight()
|
||||
next.Widgets.Name.Highlight()
|
||||
|
||||
ui.Render(cGrid)
|
||||
}
|
||||
@ -78,9 +78,9 @@ func (g *Grid) cursorDown() {
|
||||
active := g.containers[idx]
|
||||
next := g.containers[idx+1]
|
||||
|
||||
active.Widgets.UnHighlight()
|
||||
active.Widgets.Name.UnHighlight()
|
||||
g.cursorID = next.Id
|
||||
next.Widgets.Highlight()
|
||||
next.Widgets.Name.Highlight()
|
||||
ui.Render(cGrid)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user