move reset view,handlers into each menu

This commit is contained in:
Bradley Cicenas 2017-02-13 03:22:32 +00:00
parent e49af4d5bf
commit 70974ee131
2 changed files with 11 additions and 7 deletions

View File

@ -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 {

View File

@ -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