mirror of
https://github.com/bcicen/ctop.git
synced 2025-11-17 08:20:37 +01:00
move highlight method into textcol widget
This commit is contained in:
@@ -108,16 +108,6 @@ func (row *Compact) Buffer() ui.Buffer {
|
|||||||
return buf
|
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) {
|
func (row *Compact) SetNet(rx int64, tx int64) {
|
||||||
label := fmt.Sprintf("%s / %s", cwidgets.ByteFormat(rx), cwidgets.ByteFormat(tx))
|
label := fmt.Sprintf("%s / %s", cwidgets.ByteFormat(rx), cwidgets.ByteFormat(tx))
|
||||||
row.Net.Set(label)
|
row.Net.Set(label)
|
||||||
|
|||||||
@@ -24,6 +24,16 @@ func NewTextCol(s string) *TextCol {
|
|||||||
return &TextCol{p}
|
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() {
|
func (w *TextCol) Reset() {
|
||||||
w.Text = "-"
|
w.Text = "-"
|
||||||
}
|
}
|
||||||
|
|||||||
10
grid.go
10
grid.go
@@ -36,7 +36,7 @@ func NewGrid() *Grid {
|
|||||||
func (g *Grid) cursorReset() {
|
func (g *Grid) cursorReset() {
|
||||||
if len(g.containers) > 0 {
|
if len(g.containers) > 0 {
|
||||||
g.cursorID = g.containers[0].Id
|
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]
|
active := g.containers[idx]
|
||||||
next := g.containers[idx-1]
|
next := g.containers[idx-1]
|
||||||
|
|
||||||
active.Widgets.UnHighlight()
|
active.Widgets.Name.UnHighlight()
|
||||||
g.cursorID = next.Id
|
g.cursorID = next.Id
|
||||||
next.Widgets.Highlight()
|
next.Widgets.Name.Highlight()
|
||||||
|
|
||||||
ui.Render(cGrid)
|
ui.Render(cGrid)
|
||||||
}
|
}
|
||||||
@@ -78,9 +78,9 @@ func (g *Grid) cursorDown() {
|
|||||||
active := g.containers[idx]
|
active := g.containers[idx]
|
||||||
next := g.containers[idx+1]
|
next := g.containers[idx+1]
|
||||||
|
|
||||||
active.Widgets.UnHighlight()
|
active.Widgets.Name.UnHighlight()
|
||||||
g.cursorID = next.Id
|
g.cursorID = next.Id
|
||||||
next.Widgets.Highlight()
|
next.Widgets.Name.Highlight()
|
||||||
ui.Render(cGrid)
|
ui.Render(cGrid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user