diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-16 14:00:27 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-21 22:07:14 +1100 |
commit | 8aa1062e0693289188c2fb705f2fa15d014f07a0 (patch) | |
tree | 4a6eb1101af72b22f51834cf955ad82fee374070 /pkg/gui/branches_panel.go | |
parent | 7e0a8f235ef6971a98fba9c91c7fa159ca842180 (diff) |
extract out some logic for list views
Diffstat (limited to 'pkg/gui/branches_panel.go')
-rw-r--r-- | pkg/gui/branches_panel.go | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 205adf236..015f51739 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -105,34 +105,6 @@ func (gui *Gui) refreshBranches(g *gocui.Gui) error { return nil } -func (gui *Gui) handleBranchesNextLine(g *gocui.Gui, v *gocui.View) error { - if gui.popupPanelFocused() { - return nil - } - - panelState := gui.State.Panels.Branches - gui.changeSelectedLine(&panelState.SelectedLine, len(gui.State.Branches), false) - - if err := gui.resetOrigin(gui.getMainView()); err != nil { - return err - } - return gui.handleBranchSelect(gui.g, v) -} - -func (gui *Gui) handleBranchesPrevLine(g *gocui.Gui, v *gocui.View) error { - if gui.popupPanelFocused() { - return nil - } - - panelState := gui.State.Panels.Branches - gui.changeSelectedLine(&panelState.SelectedLine, len(gui.State.Branches), true) - - if err := gui.resetOrigin(gui.getMainView()); err != nil { - return err - } - return gui.handleBranchSelect(gui.g, v) -} - // specific functions func (gui *Gui) handleBranchPress(g *gocui.Gui, v *gocui.View) error { @@ -364,16 +336,17 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) onBranchesTabClick(tabIndex int) error { - gui.State.Panels.Branches.ContextIndex = tabIndex + contexts := []string{"local-branches", "remotes", "tabs"} branchesView := gui.getBranchesView() + branchesView.Context = contexts[tabIndex] branchesView.TabIndex = tabIndex - switch tabIndex { - case 0: + switch contexts[tabIndex] { + case "local-branches": if err := gui.renderListPanel(branchesView, gui.State.Branches); err != nil { return err } - case 1: + case "remotes": if err := gui.renderListPanel(branchesView, gui.State.Remotes); err != nil { return err } |