mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
move reset view,handlers into each menu
This commit is contained in:
parent
e49af4d5bf
commit
70974ee131
8
grid.go
8
grid.go
@ -113,12 +113,6 @@ func ResetView() {
|
||||
ui.Clear()
|
||||
}
|
||||
|
||||
func OpenMenu(m func()) {
|
||||
ResetView()
|
||||
defer ResetView()
|
||||
m()
|
||||
}
|
||||
|
||||
func (g *Grid) ExpandView() {
|
||||
ResetView()
|
||||
defer ResetView()
|
||||
@ -195,7 +189,7 @@ func Display(g *Grid) bool {
|
||||
|
||||
ui.Loop()
|
||||
if menu != nil {
|
||||
OpenMenu(menu)
|
||||
menu()
|
||||
return false
|
||||
}
|
||||
if expand {
|
||||
|
10
menus.go
10
menus.go
@ -14,6 +14,9 @@ var helpDialog = []string{
|
||||
}
|
||||
|
||||
func HelpMenu() {
|
||||
ResetView()
|
||||
defer ResetView()
|
||||
|
||||
m := widgets.NewMenu(helpDialog)
|
||||
m.TextFgColor = ui.ColorWhite
|
||||
m.BorderLabel = "Help"
|
||||
@ -26,10 +29,14 @@ func HelpMenu() {
|
||||
}
|
||||
|
||||
func FilterMenu() {
|
||||
ui.DefaultEvtStream.ResetHandlers()
|
||||
defer ResetView()
|
||||
|
||||
i := widgets.NewInput()
|
||||
i.TextFgColor = ui.ColorWhite
|
||||
i.BorderLabel = "Filter"
|
||||
i.BorderFg = ui.ColorCyan
|
||||
i.SetY(ui.TermHeight() - i.Height)
|
||||
ui.Render(i)
|
||||
i.InputHandlers()
|
||||
ui.Handle("/sys/kbd/<enter>", func(ui.Event) {
|
||||
@ -40,6 +47,9 @@ func FilterMenu() {
|
||||
}
|
||||
|
||||
func SortMenu() {
|
||||
ResetView()
|
||||
defer ResetView()
|
||||
|
||||
m := widgets.NewMenu(SortFields())
|
||||
m.Selectable = true
|
||||
m.TextFgColor = ui.ColorWhite
|
||||
|
Loading…
Reference in New Issue
Block a user