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()
|
ui.Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
func OpenMenu(m func()) {
|
|
||||||
ResetView()
|
|
||||||
defer ResetView()
|
|
||||||
m()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *Grid) ExpandView() {
|
func (g *Grid) ExpandView() {
|
||||||
ResetView()
|
ResetView()
|
||||||
defer ResetView()
|
defer ResetView()
|
||||||
@ -195,7 +189,7 @@ func Display(g *Grid) bool {
|
|||||||
|
|
||||||
ui.Loop()
|
ui.Loop()
|
||||||
if menu != nil {
|
if menu != nil {
|
||||||
OpenMenu(menu)
|
menu()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if expand {
|
if expand {
|
||||||
|
10
menus.go
10
menus.go
@ -14,6 +14,9 @@ var helpDialog = []string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func HelpMenu() {
|
func HelpMenu() {
|
||||||
|
ResetView()
|
||||||
|
defer ResetView()
|
||||||
|
|
||||||
m := widgets.NewMenu(helpDialog)
|
m := widgets.NewMenu(helpDialog)
|
||||||
m.TextFgColor = ui.ColorWhite
|
m.TextFgColor = ui.ColorWhite
|
||||||
m.BorderLabel = "Help"
|
m.BorderLabel = "Help"
|
||||||
@ -26,10 +29,14 @@ func HelpMenu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func FilterMenu() {
|
func FilterMenu() {
|
||||||
|
ui.DefaultEvtStream.ResetHandlers()
|
||||||
|
defer ResetView()
|
||||||
|
|
||||||
i := widgets.NewInput()
|
i := widgets.NewInput()
|
||||||
i.TextFgColor = ui.ColorWhite
|
i.TextFgColor = ui.ColorWhite
|
||||||
i.BorderLabel = "Filter"
|
i.BorderLabel = "Filter"
|
||||||
i.BorderFg = ui.ColorCyan
|
i.BorderFg = ui.ColorCyan
|
||||||
|
i.SetY(ui.TermHeight() - i.Height)
|
||||||
ui.Render(i)
|
ui.Render(i)
|
||||||
i.InputHandlers()
|
i.InputHandlers()
|
||||||
ui.Handle("/sys/kbd/<enter>", func(ui.Event) {
|
ui.Handle("/sys/kbd/<enter>", func(ui.Event) {
|
||||||
@ -40,6 +47,9 @@ func FilterMenu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SortMenu() {
|
func SortMenu() {
|
||||||
|
ResetView()
|
||||||
|
defer ResetView()
|
||||||
|
|
||||||
m := widgets.NewMenu(SortFields())
|
m := widgets.NewMenu(SortFields())
|
||||||
m.Selectable = true
|
m.Selectable = true
|
||||||
m.TextFgColor = ui.ColorWhite
|
m.TextFgColor = ui.ColorWhite
|
||||||
|
Loading…
Reference in New Issue
Block a user