diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2018-09-17 21:11:47 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2018-09-17 21:27:53 +1000 |
commit | a66ac8092e30f6c3f9a72c10a6b3eed5fb2265eb (patch) | |
tree | 4630eef219216cbc87117fe9a69c092884935d6f /pkg/gui | |
parent | bd04ecff6990e13d518596d5922fa82427f08aa4 (diff) |
minor refactor
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/menu_panel.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/pkg/gui/menu_panel.go b/pkg/gui/menu_panel.go index ee0773a51..945d0020a 100644 --- a/pkg/gui/menu_panel.go +++ b/pkg/gui/menu_panel.go @@ -49,12 +49,11 @@ func (gui *Gui) handleMenuClose(g *gocui.Gui, v *gocui.View) error { return gui.returnFocus(g, v) } -func (gui *Gui) handleMenu(g *gocui.Gui, v *gocui.View) error { +func (gui *Gui) getBindings(v *gocui.View) []*Binding { var ( bindingsGlobal, bindingsPanel []*Binding ) - // clear keys slice, so we don't have ghost elements - gui.State.Keys = gui.State.Keys[:0] + bindings := gui.GetKeybindings() for _, binding := range bindings { @@ -71,7 +70,11 @@ func (gui *Gui) handleMenu(g *gocui.Gui, v *gocui.View) error { // append dummy element to have a separator between // panel and global keybindings bindingsPanel = append(bindingsPanel, &Binding{}) - gui.State.Keys = append(bindingsPanel, bindingsGlobal...) + return append(bindingsPanel, bindingsGlobal...) +} + +func (gui *Gui) handleMenu(g *gocui.Gui, v *gocui.View) error { + gui.State.Keys = gui.getBindings(v) list, err := utils.RenderList(gui.State.Keys) if err != nil { |