mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
align ctop header on resize, add keybinding to help dialog
This commit is contained in:
parent
335ac8d741
commit
93db38d654
1
grid.go
1
grid.go
@ -206,6 +206,7 @@ func Display(g *Grid) bool {
|
||||
})
|
||||
|
||||
ui.Handle("/sys/wnd/resize", func(e ui.Event) {
|
||||
g.header.Align()
|
||||
ui.Body.Width = ui.TermWidth()
|
||||
log.Infof("resize: width=%v max-rows=%v", ui.Body.Width, g.maxRows)
|
||||
g.redrawRows()
|
||||
|
1
menus.go
1
menus.go
@ -9,6 +9,7 @@ import (
|
||||
|
||||
var helpDialog = []menu.Item{
|
||||
menu.Item{"[h] - open this help dialog", ""},
|
||||
menu.Item{"[H] - toggle cTop header", ""},
|
||||
menu.Item{"[s] - select container sort field", ""},
|
||||
menu.Item{"[r] - reverse container sort order", ""},
|
||||
menu.Item{"[q] - exit ctop", ""},
|
||||
|
@ -17,8 +17,8 @@ type CTopHeader struct {
|
||||
func NewCTopHeader() *CTopHeader {
|
||||
return &CTopHeader{
|
||||
Time: headerPar(2, timeStr()),
|
||||
Count: headerPar(22, "-"),
|
||||
Filter: headerPar(42, ""),
|
||||
Count: headerPar(27, "-"),
|
||||
Filter: headerPar(47, ""),
|
||||
bg: headerBg(),
|
||||
}
|
||||
}
|
||||
@ -29,6 +29,10 @@ func (c *CTopHeader) Render() {
|
||||
ui.Render(c.Time, c.Count, c.Filter)
|
||||
}
|
||||
|
||||
func (c *CTopHeader) Align() {
|
||||
c.bg.SetWidth(ui.TermWidth() - 1)
|
||||
}
|
||||
|
||||
func (c *CTopHeader) Height() int {
|
||||
return c.bg.Height
|
||||
}
|
||||
@ -65,7 +69,8 @@ func (c *CTopHeader) SetFilter(val string) {
|
||||
}
|
||||
|
||||
func timeStr() string {
|
||||
return time.Now().Local().Format("15:04:05 MST")
|
||||
ts := time.Now().Local().Format("15:04:05 MST")
|
||||
return fmt.Sprintf("cTop - %s", ts)
|
||||
}
|
||||
|
||||
func headerPar(x int, s string) *ui.Par {
|
||||
|
Loading…
Reference in New Issue
Block a user