summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/gui/commit_files_panel.go10
-rw-r--r--pkg/gui/commit_message_panel.go4
-rw-r--r--pkg/gui/commits_panel.go12
-rw-r--r--pkg/gui/credentials_panel.go4
-rw-r--r--pkg/gui/keybindings.go6
-rw-r--r--pkg/gui/list_view.go20
-rw-r--r--pkg/gui/reflog_panel.go8
-rw-r--r--pkg/gui/reset_menu_panel.go2
-rw-r--r--pkg/gui/stash_panel.go8
-rw-r--r--pkg/gui/tags_panel.go8
-rw-r--r--pkg/gui/view_helpers.go12
11 files changed, 44 insertions, 50 deletions
diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go
index 720f77e55..0bddbb8e9 100644
--- a/pkg/gui/commit_files_panel.go
+++ b/pkg/gui/commit_files_panel.go
@@ -18,13 +18,13 @@ func (gui *Gui) getSelectedCommitFile() *commands.CommitFile {
func (gui *Gui) handleCommitFilesClick(g *gocui.Gui, v *gocui.View) error {
itemCount := len(gui.State.CommitFiles)
- handleSelect := gui.handleCommitFileSelect
+ handleSelect := gui.wrappedHandler(gui.handleCommitFileSelect)
selectedLine := &gui.State.Panels.CommitFiles.SelectedLine
return gui.handleClick(v, itemCount, selectedLine, handleSelect)
}
-func (gui *Gui) handleCommitFileSelect(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleCommitFileSelect() error {
if gui.popupPanelFocused() {
return nil
}
@@ -44,7 +44,7 @@ func (gui *Gui) handleCommitFileSelect(g *gocui.Gui, v *gocui.View) error {
return err
}
- v.FocusPoint(0, gui.State.Panels.CommitFiles.SelectedLine)
+ gui.getCommitFilesView().FocusPoint(0, gui.State.Panels.CommitFiles.SelectedLine)
cmd := gui.OSCommand.ExecutableFromString(
gui.GitCommand.ShowCommitFileCmdStr(commitFile.Sha, commitFile.Name, false),
@@ -122,7 +122,7 @@ func (gui *Gui) refreshCommitFilesView() error {
displayStrings := presentation.GetCommitFileListDisplayStrings(gui.State.CommitFiles, gui.State.Diff.Ref)
gui.renderDisplayStrings(commitsFileView, displayStrings)
- return gui.handleCommitFileSelect(gui.g, commitsFileView)
+ return gui.handleCommitFileSelect()
}
func (gui *Gui) handleOpenOldCommitFile(g *gocui.Gui, v *gocui.View) error {
@@ -251,5 +251,5 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error {
func (gui *Gui) onCommitFilesPanelSearchSelect(selectedLine int) error {
gui.State.Panels.CommitFiles.SelectedLine = selectedLine
- return gui.handleCommitFileSelect(gui.g, gui.getCommitFilesView())
+ return gui.handleCommitFileSelect()
}
diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go
index af79795f1..9c1a3ff52 100644
--- a/pkg/gui/commit_message_panel.go
+++ b/pkg/gui/commit_message_panel.go
@@ -56,8 +56,8 @@ func (gui *Gui) handleCommitClose(g *gocui.Gui, v *gocui.View) error {
return gui.switchFocus(v, gui.getFilesView())
}
-func (gui *Gui) handleCommitFocused(g *gocui.Gui, v *gocui.View) error {
- if _, err := g.SetViewOnTop("commitMessage"); err != nil {
+func (gui *Gui) handleCommitFocused() error {
+ if _, err := gui.g.SetViewOnTop("commitMessage"); err != nil {
return err
}
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index 1f0b132f6..e96170b83 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -21,7 +21,7 @@ func (gui *Gui) getSelectedCommit() *commands.Commit {
return gui.State.Commits[selectedLine]
}
-func (gui *Gui) handleCommitSelect(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleCommitSelect() error {
if gui.popupPanelFocused() {
return nil
}
@@ -31,7 +31,7 @@ func (gui *Gui) handleCommitSelect(g *gocui.Gui, v *gocui.View) error {
return err
}
- if _, err := gui.g.SetCurrentView(v.Name()); err != nil {
+ if _, err := gui.g.SetCurrentView("commits"); err != nil {
return err
}
@@ -54,7 +54,7 @@ func (gui *Gui) handleCommitSelect(g *gocui.Gui, v *gocui.View) error {
return gui.newStringTask("main", gui.Tr.SLocalize("NoCommitsThisBranch"))
}
- v.FocusPoint(0, gui.State.Panels.Commits.SelectedLine)
+ gui.getCommitsView().FocusPoint(0, gui.State.Panels.Commits.SelectedLine)
if gui.inDiffMode() {
return gui.renderDiff()
@@ -637,7 +637,7 @@ func (gui *Gui) renderBranchCommitsWithSelection() error {
displayStrings := presentation.GetCommitListDisplayStrings(gui.State.Commits, gui.State.ScreenMode != SCREEN_NORMAL, gui.cherryPickedCommitShaMap(), gui.State.Diff.Ref)
gui.renderDisplayStrings(commitsView, displayStrings)
if gui.g.CurrentView() == commitsView && commitsView.Context == "branch-commits" {
- if err := gui.handleCommitSelect(gui.g, commitsView); err != nil {
+ if err := gui.handleCommitSelect(); err != nil {
return err
}
}
@@ -709,10 +709,10 @@ func (gui *Gui) onCommitsPanelSearchSelect(selectedLine int) error {
switch commitsView.Context {
case "branch-commits":
gui.State.Panels.Commits.SelectedLine = selectedLine
- return gui.handleCommitSelect(gui.g, commitsView)
+ return gui.handleCommitSelect()
case "reflog-commits":
gui.State.Panels.ReflogCommits.SelectedLine = selectedLine
- return gui.handleReflogCommitSelect(gui.g, commitsView)
+ return gui.handleReflogCommitSelect()
}
return nil
}
diff --git a/pkg/gui/credentials_panel.go b/pkg/gui/credentials_panel.go
index 7858f26f4..b5c7b62dc 100644
--- a/pkg/gui/credentials_panel.go
+++ b/pkg/gui/credentials_panel.go
@@ -60,8 +60,8 @@ func (gui *Gui) handleCloseCredentialsView(g *gocui.Gui, v *gocui.View) error {
return gui.switchFocus(nil, gui.getFilesView())
}
-func (gui *Gui) handleCredentialsViewFocused(g *gocui.Gui, v *gocui.View) error {
- if _, err := g.SetViewOnTop("credentials"); err != nil {
+func (gui *Gui) handleCredentialsViewFocused() error {
+ if _, err := gui.g.SetViewOnTop("credentials"); err != nil {
return err
}
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 09b2331dd..a0e6f463f 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -1334,12 +1334,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Description: gui.Tr.SLocalize("setUpstream"),
},
{
- ViewName: "stash",
- Key: gocui.MouseLeft,
- Modifier: gocui.ModNone,
- Handler: gui.handleStashEntrySelect,
- },
- {
ViewName: "status",
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
diff --git a/pkg/gui/list_view.go b/pkg/gui/list_view.go
index c48f51ce5..e22ec8519 100644
--- a/pkg/gui/list_view.go
+++ b/pkg/gui/list_view.go
@@ -163,8 +163,8 @@ func (gui *Gui) getListViews() []*listView {
context: "tags",
getItemsLength: func() int { return len(gui.State.Tags) },
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Tags.SelectedLine },
- handleFocus: gui.handleTagSelect,
- handleItemSelect: gui.handleTagSelect,
+ handleFocus: gui.wrappedHandler(gui.handleTagSelect),
+ handleItemSelect: gui.wrappedHandler(gui.handleTagSelect),
gui: gui,
rendersToMainView: true,
},
@@ -174,8 +174,8 @@ func (gui *Gui) getListViews() []*listView {
context: "branch-commits",
getItemsLength: func() int { return len(gui.State.Commits) },
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Commits.SelectedLine },
- handleFocus: gui.handleCommitSelect,
- handleItemSelect: gui.handleCommitSelect,
+ handleFocus: gui.wrappedHandler(gui.handleCommitSelect),
+ handleItemSelect: gui.wrappedHandler(gui.handleCommitSelect),
handleClickSelectedItem: gui.handleSwitchToCommitFilesPanel,
gui: gui,
rendersToMainView: true,
@@ -185,8 +185,8 @@ func (gui *Gui) getListViews() []*listView {
context: "reflog-commits",
getItemsLength: func() int { return len(gui.State.FilteredReflogCommits) },
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.ReflogCommits.SelectedLine },
- handleFocus: gui.handleReflogCommitSelect,
- handleItemSelect: gui.handleReflogCommitSelect,
+ handleFocus: gui.wrappedHandler(gui.handleReflogCommitSelect),
+ handleItemSelect: gui.wrappedHandler(gui.handleReflogCommitSelect),
gui: gui,
rendersToMainView: true,
},
@@ -194,8 +194,8 @@ func (gui *Gui) getListViews() []*listView {
viewName: "stash",
getItemsLength: func() int { return len(gui.State.StashEntries) },
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Stash.SelectedLine },
- handleFocus: gui.handleStashEntrySelect,
- handleItemSelect: gui.handleStashEntrySelect,
+ handleFocus: gui.wrappedHandler(gui.handleStashEntrySelect),
+ handleItemSelect: gui.wrappedHandler(gui.handleStashEntrySelect),
gui: gui,
rendersToMainView: true,
},
@@ -203,8 +203,8 @@ func (gui *Gui) getListViews() []*listView {
viewName: "commitFiles",
getItemsLength: func() int { return len(gui.State.CommitFiles) },
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.CommitFiles.SelectedLine },
- handleFocus: gui.handleCommitFileSelect,
- handleItemSelect: gui.handleCommitFileSelect,
+ handleFocus: gui.wrappedHandler(gui.handleCommitFileSelect),
+ handleItemSelect: gui.wrappedHandler(gui.handleCommitFileSelect),
gui: gui,
rendersToMainView: true,
},
diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go
index 0077502b3..66be53e55 100644
--- a/pkg/gui/reflog_panel.go
+++ b/pkg/gui/reflog_panel.go
@@ -18,14 +18,14 @@ func (gui *Gui) getSelectedReflogCommit() *commands.Commit {
return reflogComits[selectedLine]
}
-func (gui *Gui) handleReflogCommitSelect(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleReflogCommitSelect() error {
if gui.popupPanelFocused() {
return nil
}
gui.State.SplitMainPanel = false
- if _, err := gui.g.SetCurrentView(v.Name()); err != nil {
+ if _, err := gui.g.SetCurrentView("commits"); err != nil {
return err
}
@@ -35,7 +35,7 @@ func (gui *Gui) handleReflogCommitSelect(g *gocui.Gui, v *gocui.View) error {
if commit == nil {
return gui.newStringTask("main", "No reflog history")
}
- v.FocusPoint(0, gui.State.Panels.ReflogCommits.SelectedLine)
+ gui.getCommitsView().FocusPoint(0, gui.State.Panels.ReflogCommits.SelectedLine)
if gui.inDiffMode() {
return gui.renderDiff()
@@ -107,7 +107,7 @@ func (gui *Gui) renderReflogCommitsWithSelection() error {
displayStrings := presentation.GetReflogCommitListDisplayStrings(gui.State.FilteredReflogCommits, gui.State.ScreenMode != SCREEN_NORMAL, gui.State.Diff.Ref)
gui.renderDisplayStrings(commitsView, displayStrings)
if gui.g.CurrentView() == commitsView && commitsView.Context == "reflog-commits" {
- if err := gui.handleReflogCommitSelect(gui.g, commitsView); err != nil {
+ if err := gui.handleReflogCommitSelect(); err != nil {
return err
}
}
diff --git a/pkg/gui/reset_menu_panel.go b/pkg/gui/reset_menu_panel.go
index 1e101caad..4267fbb72 100644
--- a/pkg/gui/reset_menu_panel.go
+++ b/pkg/gui/reset_menu_panel.go
@@ -28,7 +28,7 @@ func (gui *Gui) resetToRef(ref string, strength string, options commands.RunComm
return err
}
- return gui.handleCommitSelect(gui.g, gui.getCommitsView())
+ return gui.handleCommitSelect()
}
func (gui *Gui) createResetMenu(ref string) error {
diff --git a/pkg/gui/stash_panel.go b/pkg/gui/stash_panel.go
index 38dc5a92c..3f0536bfd 100644
--- a/pkg/gui/stash_panel.go
+++ b/pkg/gui/stash_panel.go
@@ -17,14 +17,14 @@ func (gui *Gui) getSelectedStashEntry() *commands.StashEntry {
return gui.State.StashEntries[selectedLine]
}
-func (gui *Gui) handleStashEntrySelect(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleStashEntrySelect() error {
if gui.popupPanelFocused() {
return nil
}
gui.State.SplitMainPanel = false
- if _, err := gui.g.SetCurrentView(v.Name()); err != nil {
+ if _, err := gui.g.SetCurrentView("stash"); err != nil {
return err
}
@@ -34,7 +34,7 @@ func (gui *Gui) handleStashEntrySelect(g *gocui.Gui, v *gocui.View) error {
if stashEntry == nil {
return gui.newStringTask("main", gui.Tr.SLocalize("NoStashEntries"))
}
- v.FocusPoint(0, gui.State.Panels.Stash.SelectedLine)
+ gui.getStashView().FocusPoint(0, gui.State.Panels.Stash.SelectedLine)
if gui.inDiffMode() {
return gui.renderDiff()
@@ -152,5 +152,5 @@ func (gui *Gui) handleStashSave(stashFunc func(message string) error) error {
func (gui *Gui) onStashPanelSearchSelect(selectedLine int) error {
gui.State.Panels.Stash.SelectedLine = selectedLine
- return gui.handleStashEntrySelect(gui.g, gui.getStashView())
+ return gui.handleStashEntrySelect()
}
diff --git a/pkg/gui/tags_panel.go b/pkg/gui/tags_panel.go
index 44e6c1246..de80d0e93 100644
--- a/pkg/gui/tags_panel.go
+++ b/pkg/gui/tags_panel.go
@@ -17,14 +17,14 @@ func (gui *Gui) getSelectedTag() *commands.Tag {
return gui.State.Tags[selectedLine]
}
-func (gui *Gui) handleTagSelect(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleTagSelect() error {
if gui.popupPanelFocused() {
return nil
}
gui.State.SplitMainPanel = false
- if _, err := gui.g.SetCurrentView(v.Name()); err != nil {
+ if _, err := gui.g.SetCurrentView("branches"); err != nil {
return err
}
@@ -34,7 +34,7 @@ func (gui *Gui) handleTagSelect(g *gocui.Gui, v *gocui.View) error {
if tag == nil {
return gui.newStringTask("main", "No tags")
}
- v.FocusPoint(0, gui.State.Panels.Tags.SelectedLine)
+ gui.getBranchesView().FocusPoint(0, gui.State.Panels.Tags.SelectedLine)
if gui.inDiffMode() {
return gui.renderDiff()
@@ -72,7 +72,7 @@ func (gui *Gui) renderTagsWithSelection() error {
displayStrings := presentation.GetTagListDisplayStrings(gui.State.Tags, gui.State.Diff.Ref)
gui.renderDisplayStrings(branchesView, displayStrings)
if gui.g.CurrentView() == branchesView && branchesView.Context == "tags" {
- if err := gui.handleTagSelect(gui.g, branchesView); err != nil {
+ if err := gui.handleTagSelect(); err != nil {
return gui.surfaceError(err)
}
}
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index 2114ac073..64fa35cdf 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -234,22 +234,22 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error {
case "remote-branches":
return gui.handleRemoteBranchSelect()
case "tags":
- return gui.handleTagSelect(g, v)
+ return gui.handleTagSelect()
default:
return errors.New("unknown branches panel context: " + branchesView.Context)
}
case "commits":
- return gui.handleCommitSelect(g, v)
+ return gui.handleCommitSelect()
case "commitFiles":
- return gui.handleCommitFileSelect(g, v)
+ return gui.handleCommitFileSelect()
case "stash":
- return gui.handleStashEntrySelect(g, v)
+ return gui.handleStashEntrySelect()
case "confirmation":
return nil
case "commitMessage":
- return gui.handleCommitFocused(g, v)
+ return gui.handleCommitFocused()
case "credentials":
- return gui.handleCredentialsViewFocused(g, v)
+ return gui.handleCredentialsViewFocused()
case "main":
if gui.State.MainContext == "merging" {
return gui.refreshMergePanel()