mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
move menu widget into subpackage
This commit is contained in:
38
menus.go
Normal file
38
menus.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/bcicen/ctop/widgets"
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
var helpDialog = []string{
|
||||
"[h] - open this help dialog",
|
||||
"[q] - exit ctop",
|
||||
}
|
||||
|
||||
func HelpMenu(g *Grid) {
|
||||
m := widgets.NewMenu(helpDialog)
|
||||
m.TextFgColor = ui.ColorWhite
|
||||
m.BorderLabel = "Help"
|
||||
m.BorderFg = ui.ColorCyan
|
||||
ui.Render(m)
|
||||
ui.Handle("/sys/kbd/", func(ui.Event) {
|
||||
ui.StopLoop()
|
||||
})
|
||||
ui.Loop()
|
||||
}
|
||||
|
||||
func SortMenu(g *Grid) {
|
||||
m := widgets.NewMenu(SortFields)
|
||||
m.Selectable = true
|
||||
m.TextFgColor = ui.ColorWhite
|
||||
m.BorderLabel = "Sort Field"
|
||||
m.BorderFg = ui.ColorCyan
|
||||
ui.Render(m)
|
||||
m.NavigationHandlers()
|
||||
ui.Handle("/sys/kbd/<enter>", func(ui.Event) {
|
||||
g.containerMap.config.sortField = m.Items[m.CursorPos]
|
||||
ui.StopLoop()
|
||||
})
|
||||
ui.Loop()
|
||||
}
|
||||
Reference in New Issue
Block a user