mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
add filter string to ctopheader
This commit is contained in:
parent
70974ee131
commit
97a561260a
5
grid.go
5
grid.go
@ -77,6 +77,7 @@ func (g *Grid) redrawRows() {
|
|||||||
// build layout
|
// build layout
|
||||||
if config.GetToggle("enableHeader") {
|
if config.GetToggle("enableHeader") {
|
||||||
g.header.SetCount(len(g.containers))
|
g.header.SetCount(len(g.containers))
|
||||||
|
g.header.SetFilter(config.Get("filterStr"))
|
||||||
ui.Body.AddRows(g.header.Row())
|
ui.Body.AddRows(g.header.Row())
|
||||||
}
|
}
|
||||||
ui.Body.AddRows(fieldHeader())
|
ui.Body.AddRows(fieldHeader())
|
||||||
@ -161,6 +162,10 @@ func Display(g *Grid) bool {
|
|||||||
menu = HelpMenu
|
menu = HelpMenu
|
||||||
ui.StopLoop()
|
ui.StopLoop()
|
||||||
})
|
})
|
||||||
|
ui.Handle("/sys/kbd/H", func(ui.Event) {
|
||||||
|
config.Toggle("enableHeader")
|
||||||
|
g.redrawRows()
|
||||||
|
})
|
||||||
ui.Handle("/sys/kbd/q", func(ui.Event) {
|
ui.Handle("/sys/kbd/q", func(ui.Event) {
|
||||||
ui.StopLoop()
|
ui.StopLoop()
|
||||||
})
|
})
|
||||||
|
@ -8,14 +8,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type CTopHeader struct {
|
type CTopHeader struct {
|
||||||
Time *ui.Par
|
Time *ui.Par
|
||||||
Count *ui.Par
|
Count *ui.Par
|
||||||
|
Filter *ui.Par
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCTopHeader() *CTopHeader {
|
func NewCTopHeader() *CTopHeader {
|
||||||
return &CTopHeader{
|
return &CTopHeader{
|
||||||
Time: headerPar(timeStr()),
|
Time: headerPar(timeStr()),
|
||||||
Count: headerPar("-"),
|
Count: headerPar("-"),
|
||||||
|
Filter: headerPar(""),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,6 +26,7 @@ func (c *CTopHeader) Row() *ui.Row {
|
|||||||
return ui.NewRow(
|
return ui.NewRow(
|
||||||
ui.NewCol(2, 0, c.Time),
|
ui.NewCol(2, 0, c.Time),
|
||||||
ui.NewCol(2, 0, c.Count),
|
ui.NewCol(2, 0, c.Count),
|
||||||
|
ui.NewCol(8, 0, c.Filter),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +34,14 @@ func (c *CTopHeader) SetCount(val int) {
|
|||||||
c.Count.Text = fmt.Sprintf("%d containers", val)
|
c.Count.Text = fmt.Sprintf("%d containers", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *CTopHeader) SetFilter(val string) {
|
||||||
|
if val == "" {
|
||||||
|
c.Filter.Text = ""
|
||||||
|
} else {
|
||||||
|
c.Filter.Text = fmt.Sprintf("filter: %s", val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func timeStr() string {
|
func timeStr() string {
|
||||||
return time.Now().Local().Format("15:04:05 MST")
|
return time.Now().Local().Format("15:04:05 MST")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user