diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-02 19:20:40 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-06 19:34:32 +1000 |
commit | 798d3e2d54e828f25ed4aadcefff11593fa23e10 (patch) | |
tree | 3b68eedd78e13836da8d7b8c46c5862c458f02a0 /pkg/gui/list_context.go | |
parent | e8f99c3326f543b713cafb6420a5b9c3c9b4d50c (diff) |
get rid of these positively ghastly method signatures
Diffstat (limited to 'pkg/gui/list_context.go')
-rw-r--r-- | pkg/gui/list_context.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/pkg/gui/list_context.go b/pkg/gui/list_context.go index ac345dd97..03089acfa 100644 --- a/pkg/gui/list_context.go +++ b/pkg/gui/list_context.go @@ -150,11 +150,11 @@ func (lc *ListContext) HandleRender() error { return lc.OnRender() } -func (lc *ListContext) handlePrevLine(g *gocui.Gui, v *gocui.View) error { +func (lc *ListContext) handlePrevLine() error { return lc.handleLineChange(-1) } -func (lc *ListContext) handleNextLine(g *gocui.Gui, v *gocui.View) error { +func (lc *ListContext) handleNextLine() error { return lc.handleLineChange(1) } @@ -188,7 +188,7 @@ func (lc *ListContext) handleLineChange(change int) error { return lc.HandleFocus() } -func (lc *ListContext) handleNextPage(g *gocui.Gui, v *gocui.View) error { +func (lc *ListContext) handleNextPage() error { view, err := lc.Gui.g.View(lc.ViewName) if err != nil { return nil @@ -198,15 +198,15 @@ func (lc *ListContext) handleNextPage(g *gocui.Gui, v *gocui.View) error { return lc.handleLineChange(delta) } -func (lc *ListContext) handleGotoTop(g *gocui.Gui, v *gocui.View) error { +func (lc *ListContext) handleGotoTop() error { return lc.handleLineChange(-lc.GetItemsLength()) } -func (lc *ListContext) handleGotoBottom(g *gocui.Gui, v *gocui.View) error { +func (lc *ListContext) handleGotoBottom() error { return lc.handleLineChange(lc.GetItemsLength()) } -func (lc *ListContext) handlePrevPage(g *gocui.Gui, v *gocui.View) error { +func (lc *ListContext) handlePrevPage() error { view, err := lc.Gui.g.View(lc.ViewName) if err != nil { return nil @@ -217,13 +217,18 @@ func (lc *ListContext) handlePrevPage(g *gocui.Gui, v *gocui.View) error { return lc.handleLineChange(-delta) } -func (lc *ListContext) handleClick(g *gocui.Gui, v *gocui.View) error { +func (lc *ListContext) handleClick() error { if !lc.Gui.isPopupPanel(lc.ViewName) && lc.Gui.popupPanelFocused() { return nil } + view, err := lc.Gui.g.View(lc.ViewName) + if err != nil { + return nil + } + prevSelectedLineIdx := lc.GetPanelState().GetSelectedLineIdx() - newSelectedLineIdx := v.SelectedLineIdx() + newSelectedLineIdx := view.SelectedLineIdx() // we need to focus the view if err := lc.Gui.pushContext(lc); err != nil { @@ -573,7 +578,7 @@ func (gui *Gui) getListContextKeyBindings() []*Binding { ViewName: listContext.ViewName, Contexts: []string{listContext.ContextKey}, Key: gui.getKey(keybindingConfig.Universal.StartSearch), - Handler: openSearchHandler, + Handler: func() error { return openSearchHandler(listContext.ViewName) }, Description: gui.Tr.LcStartSearch, Tag: "navigation", }, |