summaryrefslogtreecommitdiffstats
path: root/pkg/gui
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-15 17:23:16 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-15 18:01:43 +1000
commit9b7a6934b333755d9408aca5eeb48678f8d98ebb (patch)
treec2ee77cb31f5281473de71591fcf09383d7c7149 /pkg/gui
parent15229bbdab5d99ce7f390a7e215a572ab155a5ac (diff)
more removing of g
Diffstat (limited to 'pkg/gui')
-rw-r--r--pkg/gui/branches_panel.go12
-rw-r--r--pkg/gui/commits_panel.go2
-rw-r--r--pkg/gui/confirmation_panel.go24
-rw-r--r--pkg/gui/credentials_panel.go2
-rw-r--r--pkg/gui/files_panel.go50
-rw-r--r--pkg/gui/keybindings.go30
-rw-r--r--pkg/gui/layout.go2
-rw-r--r--pkg/gui/list_view.go6
-rw-r--r--pkg/gui/menu_panel.go6
-rw-r--r--pkg/gui/merge_panel.go14
-rw-r--r--pkg/gui/patch_building_panel.go6
-rw-r--r--pkg/gui/patch_options_panel.go2
-rw-r--r--pkg/gui/quitting.go14
-rw-r--r--pkg/gui/rebase_options_panel.go4
-rw-r--r--pkg/gui/recent_repos_panel.go3
-rw-r--r--pkg/gui/remotes_panel.go2
-rw-r--r--pkg/gui/staging_panel.go10
-rw-r--r--pkg/gui/stash_panel.go8
-rw-r--r--pkg/gui/status_panel.go6
-rw-r--r--pkg/gui/updates.go4
-rw-r--r--pkg/gui/view_helpers.go24
21 files changed, 114 insertions, 117 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 8752ada99..1365980be 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -277,10 +277,10 @@ func (gui *Gui) createNewBranchWithName(newBranchName string) error {
}
func (gui *Gui) handleDeleteBranch(g *gocui.Gui, v *gocui.View) error {
- return gui.deleteBranch(g, v, false)
+ return gui.deleteBranch(false)
}
-func (gui *Gui) deleteBranch(g *gocui.Gui, v *gocui.View, force bool) error {
+func (gui *Gui) deleteBranch(force bool) error {
selectedBranch := gui.getSelectedBranch()
if selectedBranch == nil {
return nil
@@ -289,10 +289,10 @@ func (gui *Gui) deleteBranch(g *gocui.Gui, v *gocui.View, force bool) error {
if checkedOutBranch.Name == selectedBranch.Name {
return gui.createErrorPanel(gui.Tr.SLocalize("CantDeleteCheckOutBranch"))
}
- return gui.deleteNamedBranch(g, v, selectedBranch, force)
+ return gui.deleteNamedBranch(selectedBranch, force)
}
-func (gui *Gui) deleteNamedBranch(g *gocui.Gui, v *gocui.View, selectedBranch *commands.Branch, force bool) error {
+func (gui *Gui) deleteNamedBranch(selectedBranch *commands.Branch, force bool) error {
title := gui.Tr.SLocalize("DeleteBranch")
var messageID string
if force {
@@ -308,7 +308,7 @@ func (gui *Gui) deleteNamedBranch(g *gocui.Gui, v *gocui.View, selectedBranch *c
)
return gui.ask(askOpts{
- returnToView: v,
+ returnToView: gui.getBranchesView(),
returnFocusOnClose: true,
title: title,
prompt: message,
@@ -316,7 +316,7 @@ func (gui *Gui) deleteNamedBranch(g *gocui.Gui, v *gocui.View, selectedBranch *c
if err := gui.GitCommand.DeleteBranch(selectedBranch.Name, force); err != nil {
errMessage := err.Error()
if !force && strings.Contains(errMessage, "is not fully merged") {
- return gui.deleteNamedBranch(g, v, selectedBranch, true)
+ return gui.deleteNamedBranch(selectedBranch, true)
}
return gui.createErrorPanel(errMessage)
}
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index e96170b83..6aec26ec7 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -512,7 +512,7 @@ func (gui *Gui) HandlePasteCommits(g *gocui.Gui, v *gocui.View) error {
})
}
-func (gui *Gui) handleSwitchToCommitFilesPanel(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleSwitchToCommitFilesPanel() error {
if err := gui.refreshCommitFilesView(); err != nil {
return err
}
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go
index 15c615bb5..e1aa29531 100644
--- a/pkg/gui/confirmation_panel.go
+++ b/pkg/gui/confirmation_panel.go
@@ -76,7 +76,7 @@ func (gui *Gui) wrappedConfirmationFunction(function func() error, returnFocusOn
}
}
- return gui.closeConfirmationPrompt(g, returnFocusOnClose)
+ return gui.closeConfirmationPrompt(returnFocusOnClose)
}
}
@@ -89,24 +89,24 @@ func (gui *Gui) wrappedPromptConfirmationFunction(function func(string) error, r
}
}
- return gui.closeConfirmationPrompt(g, returnFocusOnClose)
+ return gui.closeConfirmationPrompt(returnFocusOnClose)
}
}
-func (gui *Gui) closeConfirmationPrompt(g *gocui.Gui, returnFocusOnClose bool) error {
- view, err := g.View("confirmation")
+func (gui *Gui) closeConfirmationPrompt(returnFocusOnClose bool) error {
+ view, err := gui.g.View("confirmation")
if err != nil {
return nil // if it's already been closed we can just return
}
view.Editable = false
if returnFocusOnClose {
- if err := gui.returnFocus(g, view); err != nil {
+ if err := gui.returnFocus(view); err != nil {
panic(err)
}
}
- g.DeleteKeybinding("confirmation", gocui.KeyEnter, gocui.ModNone)
- g.DeleteKeybinding("confirmation", gocui.KeyEsc, gocui.ModNone)
- return g.DeleteView("confirmation")
+ gui.g.DeleteKeybinding("confirmation", gocui.KeyEnter, gocui.ModNone)
+ gui.g.DeleteKeybinding("confirmation", gocui.KeyEsc, gocui.ModNone)
+ return gui.g.DeleteView("confirmation")
}
func (gui *Gui) getMessageHeight(wrap bool, message string, width int) int {
@@ -123,8 +123,8 @@ func (gui *Gui) getMessageHeight(wrap bool, message string, width int) int {
return lineCount
}
-func (gui *Gui) getConfirmationPanelDimensions(g *gocui.Gui, wrap bool, prompt string) (int, int, int, int) {
- width, height := g.Size()
+func (gui *Gui) getConfirmationPanelDimensions(wrap bool, prompt string) (int, int, int, int) {
+ width, height := gui.g.Size()
// we want a minimum width up to a point, then we do it based on ratio.
panelWidth := 4 * width / 7
minWidth := 80
@@ -146,7 +146,7 @@ func (gui *Gui) getConfirmationPanelDimensions(g *gocui.Gui, wrap bool, prompt s
}
func (gui *Gui) prepareConfirmationPanel(currentView *gocui.View, title, prompt string, hasLoader bool) (*gocui.View, error) {
- x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(gui.g, true, prompt)
+ x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(true, prompt)
confirmationView, err := gui.g.SetView("confirmation", x0, y0, x1, y1, 0)
if err != nil {
if err.Error() != "unknown view" {
@@ -180,7 +180,7 @@ func (gui *Gui) createPopupPanel(opts createPopupPanelOpts) error {
gui.g.Update(func(g *gocui.Gui) error {
// delete the existing confirmation panel if it exists
if view, _ := g.View("confirmation"); view != nil {
- if err := gui.closeConfirmationPrompt(g, true); err != nil {
+ if err := gui.closeConfirmationPrompt(true); err != nil {
gui.Log.Error(err)
}
}
diff --git a/pkg/gui/credentials_panel.go b/pkg/gui/credentials_panel.go
index b5c7b62dc..ede5c865c 100644
--- a/pkg/gui/credentials_panel.go
+++ b/pkg/gui/credentials_panel.go
@@ -87,6 +87,6 @@ func (gui *Gui) handleCredentialsPopup(cmdErr error) {
// we are not logging this error because it may contain a password
gui.createErrorPanel(errMessage)
} else {
- _ = gui.closeConfirmationPrompt(gui.g, true)
+ _ = gui.closeConfirmationPrompt(true)
}
}
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 6354e17bb..f2e081245 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -166,7 +166,7 @@ func (gui *Gui) enterFile(forceSecondaryFocused bool, selectedLineIdx int) error
return nil
}
if file.HasInlineMergeConflicts {
- return gui.handleSwitchToMerge(gui.g, gui.getFilesView())
+ return gui.handleSwitchToMerge()
}
if file.HasMergeConflicts {
return gui.createErrorPanel(gui.Tr.SLocalize("FileStagingRequirements"))
@@ -178,7 +178,7 @@ func (gui *Gui) enterFile(forceSecondaryFocused bool, selectedLineIdx int) error
return gui.refreshStagingPanel(forceSecondaryFocused, selectedLineIdx)
}
-func (gui *Gui) handleFilePress(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleFilePress() error {
file, err := gui.getSelectedFile()
if err != nil {
if err == gui.Errors.ErrNoFiles {
@@ -188,7 +188,7 @@ func (gui *Gui) handleFilePress(g *gocui.Gui, v *gocui.View) error {
}
if file.HasInlineMergeConflicts {
- return gui.handleSwitchToMerge(g, v)
+ return gui.handleSwitchToMerge()
}
if file.HasUnstagedChanges {
@@ -284,13 +284,13 @@ func (gui *Gui) handleWIPCommitPress(g *gocui.Gui, filesView *gocui.View) error
return err
}
- return gui.handleCommitPress(g, filesView)
+ return gui.handleCommitPress()
}
-func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error {
+func (gui *Gui) handleCommitPress() error {
if len(gui.stagedFiles()) == 0 {
return gui.promptToStageAllAndRetry(func() error {
- return gui.handleCommitPress(gui.g, filesView)
+ return gui.handleCommitPress()
})
}
@@ -309,12 +309,12 @@ func (gui *Gui) handleCommitPress(g *gocui.Gui, filesView *gocui.View) error {
}
}
- g.Update(func(g *gocui.Gui) error {
+ gui.g.Update(func(g *gocui.Gui) error {
if _, err := g.SetViewOnTop("commitMessage"); err != nil {
return err
}
- if err := gui.switchFocus(filesView, commitMessageView); err != nil {
+ if err := gui.switchFocus(gui.getFilesView(), commitMessageView); err != nil {
return err
}
@@ -343,10 +343,10 @@ func (gui *Gui) promptToStageAllAndRetry(retry func() error) error {
})
}
-func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) error {
+func (gui *Gui) handleAmendCommitPress() error {
if len(gui.stagedFiles()) == 0 {
return gui.promptToStageAllAndRetry(func() error {
- return gui.handleAmendCommitPress(gui.g, filesView)
+ return gui.handleAmendCommitPress()
})
}
@@ -355,7 +355,7 @@ func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) erro
}
return gui.ask(askOpts{
- returnToView: filesView,
+ returnToView: gui.getFilesView(),
returnFocusOnClose: true,
title: strings.Title(gui.Tr.SLocalize("AmendLastCommit")),
prompt: gui.Tr.SLocalize("SureToAmend"),
@@ -375,21 +375,21 @@ func (gui *Gui) handleAmendCommitPress(g *gocui.Gui, filesView *gocui.View) erro
// handleCommitEditorPress - handle when the user wants to commit changes via
// their editor rather than via the popup panel
-func (gui *Gui) handleCommitEditorPress(g *gocui.Gui, filesView *gocui.View) error {
+func (gui *Gui) handleCommitEditorPress() error {
if len(gui.stagedFiles()) == 0 {
return gui.promptToStageAllAndRetry(func() error {
- return gui.handleCommitEditorPress(gui.g, filesView)
+ return gui.handleCommitEditorPress()
})
}
- gui.PrepareSubProcess(g, "git", "commit")
+ gui.PrepareSubProcess("git", "commit")
return nil
}
// PrepareSubProcess - prepare a subprocess for execution and tell the gui to switch to it
-func (gui *Gui) PrepareSubProcess(g *gocui.Gui, commands ...string) {
+func (gui *Gui) PrepareSubProcess(commands ...string) {
gui.SubProcess = gui.GitCommand.PrepareCommitSubProcess()
- g.Update(func(g *gocui.Gui) error {
+ gui.g.Update(func(g *gocui.Gui) error {
return gui.Errors.ErrSubProcess
})
}
@@ -521,7 +521,7 @@ func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
}
}
-func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool, upstream string, args string) error {
+func (gui *Gui) pushWithForceFlag(v *gocui.View, force bool, upstream string, args string) error {
if err := gui.createLoaderPanel(v, gui.Tr.SLocalize("PushWait")); err != nil {
return err
}
@@ -535,7 +535,7 @@ func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool, upstr
title: gui.Tr.SLocalize("ForcePush"),
prompt: gui.Tr.SLocalize("ForcePushPrompt"),
handleConfirm: func() error {
- return gui.pushWithForceFlag(gui.g, v, true, upstream, args)
+ return gui.pushWithForceFlag(v, true, upstream, args)
},
})
@@ -559,19 +559,19 @@ func (gui *Gui) pushFiles(g *gocui.Gui, v *gocui.View) error {
}
for branchName, branch := range conf.Branches {
if branchName == currentBranch.Name {
- return gui.pushWithForceFlag(g, v, false, "", fmt.Sprintf("%s %s", branch.Remote, branchName))
+ return gui.pushWithForceFlag(v, false, "", fmt.Sprintf("%s %s", branch.Remote, branchName))
}
}
if gui.GitCommand.PushToCurrent {
- return gui.pushWithForceFlag(g, v, false, "", "--set-upstream")
+ return gui.pushWithForceFlag(v, false, "", "--set-upstream")
} else {
return gui.prompt(v, gui.Tr.SLocalize("EnterUpstream"), "origin "+currentBranch.Name, func(response string) error {
- return gui.pushWithForceFlag(g, v, false, response, "")
+ return gui.pushWithForceFlag(v, false, response, "")
})
}
} else if currentBranch.Pullables == "0" {
- return gui.pushWithForceFlag(g, v, false, "", "")
+ return gui.pushWithForceFlag(v, false, "", "")
}
return gui.ask(askOpts{
@@ -580,12 +580,12 @@ func (gui *Gui) pushFiles(g *gocui.Gui, v *gocui.View) error {
title: gui.Tr.SLocalize("ForcePush"),
prompt: gui.Tr.SLocalize("ForcePushPrompt"),
handleConfirm: func() error {
- return gui.pushWithForceFlag(g, v, true, "", "")
+ return gui.pushWithForceFlag(v, true, "", "")
},
})
}
-func (gui *Gui) handleSwitchToMerge(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleSwitchToMerge() error {
file, err := gui.getSelectedFile()
if err != nil {
if err != gui.Errors.ErrNoFiles {
@@ -597,7 +597,7 @@ func (gui *Gui) handleSwitchToMerge(g *gocui.Gui, v *gocui.View) error {
return gui.createErrorPanel(gui.Tr.SLocalize("FileNoMergeCons"))
}
gui.changeMainViewsContext("merging")
- if err := gui.switchFocus(v, gui.getMainView()); err != nil {
+ if err := gui.switchFocus(gui.g.CurrentView(), gui.getMainView()); err != nil {
return err
}
return gui.refreshMergePanel()
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index a0e6f463f..6e4afceec 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -202,7 +202,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
ViewName: "",
Key: gui.getKey("universal.quit"),
Modifier: gocui.ModNone,
- Handler: gui.handleQuit,
+ Handler: gui.wrappedHandler(gui.handleQuit),
},
{
ViewName: "",
@@ -214,7 +214,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
ViewName: "",
Key: gui.getKey("universal.quit-alt1"),
Modifier: gocui.ModNone,
- Handler: gui.handleQuit,
+ Handler: gui.wrappedHandler(gui.handleQuit),
},
{
ViewName: "",
@@ -263,7 +263,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
{
ViewName: "",
Key: gui.getKey("universal.createRebaseOptionsMenu"),
- Handler: gui.handleCreateRebaseOptionsMenu,
+ Handler: gui.wrappedHandler(gui.handleCreateRebaseOptionsMenu),
Description: gui.Tr.SLocalize("ViewMergeRebaseOptions"),
},
{
@@ -353,13 +353,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
{
ViewName: "status",
Key: gui.getKey("status.recentRepos"),
- Handler: gui.handleCreateRecentReposMenu,
+ Handler: gui.wrappedHandler(gui.handleCreateRecentReposMenu),
Description: gui.Tr.SLocalize("SwitchRepo"),
},
{
ViewName: "files",
Key: gui.getKey("files.commitChanges"),
- Handler: gui.handleCommitPress,
+ Handler: gui.wrappedHandler(gui.handleCommitPress),
Description: gui.Tr.SLocalize("CommitChanges"),
},
{
@@ -371,19 +371,19 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
{
ViewName: "files",
Key: gui.getKey("files.amendLastCommit"),
- Handler: gui.handleAmendCommitPress,
+ Handler: gui.wrappedHandler(gui.handleAmendCommitPress),
Description: gui.Tr.SLocalize("AmendLastCommit"),
},
{
ViewName: "files",
Key: gui.getKey("files.commitChangesWithEditor"),
- Handler: gui.handleCommitEditorPress,
+ Handler: gui.wrappedHandler(gui.handleCommitEditorPress),
Description: gui.Tr.SLocalize("CommitChangesWithEditor"),
},
{
ViewName: "files",
Key: gui.getKey("universal.select"),
- Handler: gui.handleFilePress,
+ Handler: gui.wrappedHandler(gui.handleFilePress),
Description: gui.Tr.SLocalize("toggleStaged"),
},
{
@@ -765,7 +765,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
ViewName: "commits",
Contexts: []string{"branch-commits"},
Key: gui.getKey("universal.goInto"),
- Handler: gui.handleSwitchToCommitFilesPanel,
+ Handler: gui.wrappedHandler(gui.handleSwitchToCommitFilesPanel),
Description: gui.Tr.SLocalize("viewCommitFiles"),
},
{
@@ -964,7 +964,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
ViewName: "main",
Contexts: []string{"staging"},
Key: gui.getKey("universal.return"),
- Handler: gui.handleStagingEscape,
+ Handler: gui.wrappedHandler(gui.handleStagingEscape),
Description: gui.Tr.SLocalize("ReturnToFilesPanel"),
},
{
@@ -992,7 +992,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
ViewName: "main",
Contexts: []string{"patch-building"},
Key: gui.getKey("universal.return"),
- Handler: gui.handleEscapePatchBuildingPanel,
+ Handler: gui.wrappedHandler(gui.handleEscapePatchBuildingPanel),
Description: gui.Tr.SLocalize("ExitLineByLineMode"),
},
{
@@ -1147,7 +1147,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
ViewName: "main",
Contexts: []string{"staging"},
Key: gui.getKey("files.commitChanges"),
- Handler: gui.handleCommitPress,
+ Handler: gui.wrappedHandler(gui.handleCommitPress),
Description: gui.Tr.SLocalize("CommitChanges"),
},
{
@@ -1161,14 +1161,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
ViewName: "main",
Contexts: []string{"staging"},
Key: gui.getKey("files.commitChangesWithEditor"),
- Handler: gui.handleCommitEditorPress,
+ Handler: gui.wrappedHandler(gui.handleCommitEditorPress),
Description: gui.Tr.SLocalize("CommitChangesWithEditor"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
Key: gui.getKey("universal.return"),
- Handler: gui.handleEscapeMerge,
+ Handler: gui.wrappedHandler(gui.handleEscapeMerge),
Description: gui.Tr.SLocalize("ReturnToFilesPanel"),
},
{
@@ -1267,7 +1267,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Contexts: []string{"remotes"},
Key: gui.getKey("universal.goInto"),
Modifier: gocui.ModNone,
- Handler: gui.handleRemoteEnter,
+ Handler: gui.wrappedHandler(gui.handleRemoteEnter),
},
{
ViewName: "branches",
diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go
index 8eecdda48..b09a6a400 100644
--- a/pkg/gui/layout.go
+++ b/pkg/gui/layout.go
@@ -393,7 +393,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
// if you download humanlog and do tail -f development.log | humanlog
// this will let you see these branches as prettified json
// gui.Log.Info(utils.AsJson(gui.State.Branches[0:4]))
- return gui.resizeCurrentPopupPanel(g)
+ return gui.resizeCurrentPopupPanel()
}
func (gui *Gui) onInitialViewsCreation() error {
diff --git a/pkg/gui/list_view.go b/pkg/gui/list_view.go
index e22ec8519..d4f2ef069 100644
--- a/pkg/gui/list_view.go
+++ b/pkg/gui/list_view.go
@@ -123,7 +123,7 @@ func (gui *Gui) getListViews() []*listView {
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Files.SelectedLine },
handleFocus: gui.wrappedHandler(gui.focusAndSelectFile),
handleItemSelect: gui.wrappedHandler(gui.focusAndSelectFile),
- handleClickSelectedItem: gui.handleFilePress,
+ handleClickSelectedItem: gui.wrappedHandler(gui.handleFilePress),
gui: gui,
rendersToMainView: true,
},
@@ -144,7 +144,7 @@ func (gui *Gui) getListViews() []*listView {
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Remotes.SelectedLine },
handleFocus: gui.wrappedHandler(gui.renderRemotesWithSelection),
handleItemSelect: gui.wrappedHandler(gui.handleRemoteSelect),
- handleClickSelectedItem: gui.handleRemoteEnter,
+ handleClickSelectedItem: gui.wrappedHandler(gui.handleRemoteEnter),
gui: gui,
rendersToMainView: true,
},
@@ -176,7 +176,7 @@ func (gui *Gui) getListViews() []*listView {
getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Commits.SelectedLine },
handleFocus: gui.wrappedHandler(gui.handleCommitSelect),
handleItemSelect: gui.wrappedHandler(gui.handleCommitSelect),
- handleClickSelectedItem: gui.handleSwitchToCommitFilesPanel,
+ handleClickSelectedItem: gui.wrappedHandler(gui.handleSwitchToCommitFilesPanel),
gui: gui,
rendersToMainView: true,
},
diff --git a/pkg/gui/menu_panel.go b/pkg/gui/menu_panel.go
index bfa29cd75..98f4a5f61 100644
--- a/pkg/gui/menu_panel.go
+++ b/pkg/gui/menu_panel.go
@@ -42,7 +42,7 @@ func (gui *Gui) handleMenuClose(g *gocui.Gui, v *gocui.View) error {
if err != nil {
return err
}
- return gui.returnFocus(g, v)
+ return gui.returnFocus(v)
}
type createMenuOptions struct {
@@ -73,7 +73,7 @@ func (gui *Gui) createMenu(title string, items []*menuItem, createMenuOptions cr
list := utils.RenderDisplayStrings(stringArrays)
- x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(gui.g, false, list)
+ x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(false, list)
menuView, _ := gui.g.SetView("menu", x0, y0, x1, y1, 0)
menuView.Title = title
menuView.FgColor = theme.GocuiDefaultTextColor
@@ -99,7 +99,7 @@ func (gui *Gui) createMenu(title string, items []*menuItem, createMenuOptions cr
}
}
- return gui.returnFocus(gui.g, menuView)
+ return gui.returnFocus(menuView)
}
gui.State.Panels.Menu.OnPress = wrappedHandlePress
diff --git a/pkg/gui/merge_panel.go b/pkg/gui/merge_panel.go
index c40daab65..f7c1984b2 100644
--- a/pkg/gui/merge_panel.go
+++ b/pkg/gui/merge_panel.go
@@ -112,7 +112,7 @@ func (gui *Gui) isIndexToDelete(i int, conflict commands.Conflict, pick string)
(pick == "top" && i > conflict.Middle && i < conflict.End)
}
-func (gui *Gui) resolveConflict(g *gocui.Gui, conflict commands.Conflict, pick string) error {
+func (gui *Gui) resolveConflict(conflict commands.Conflict, pick string) error {
gitFile, err := gui.getSelectedFile()
if err != nil {
return err
@@ -179,7 +179,7 @@ func (gui *Gui) handlePickHunk(g *gocui.Gui, v *gocui.View) error {
if gui.State.Panels.Merging.ConflictTop {
pick = "top"
}
- err := gui.resolveConflict(g, conflict, pick)
+ err := gui.resolveConflict(conflict, pick)
if err != nil {
panic(err)
}
@@ -200,7 +200,7 @@ func (gui *Gui) handlePickBothHunks(g *gocui.Gui, v *gocui.View) error {
if err := gui.pushFileSnapshot(g); err != nil {
return err
}
- err := gui.resolveConflict(g, conflict, "both")
+ err := gui.resolveConflict(conflict, "both")
if err != nil {
panic(err)
}
@@ -298,7 +298,7 @@ func (gui *Gui) renderMergeOptions() error {
})
}
-func (gui *Gui) handleEscapeMerge(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleEscapeMerge() error {
gui.takeOverScrolling()
gui.State.Panels.Merging.EditHistory = stack.New()
@@ -308,7 +308,7 @@ func (gui *Gui) handleEscapeMerge(g *gocui.Gui, v *gocui.View) error {
// it's possible this method won't be called from the merging view so we need to
// ensure we only 'return' focus if we already have it
if gui.g.CurrentView() == gui.getMainView() {
- return gui.switchFocus(v, gui.getFilesView())
+ return gui.switchFocus(gui.getMainView(), gui.getFilesView())
}
return nil
}
@@ -323,13 +323,13 @@ func (gui *Gui) handleCompleteMerge() error {
// if we got conflicts after unstashing, we don't want to call any git
// commands to continue rebasing/merging here
if gui.GitCommand.WorkingTreeState() == "normal" {
- return gui.handleEscapeMerge(gui.g, gui.getMainView())
+ return gui.handleEscapeMerge()
}
// if there are no more files with merge conflicts, we should ask whether the user wants to continue
if !gui.anyFilesWithMergeConflicts() {
return gui.promptToContinue()
}
- return gui.handleEscapeMerge(gui.g, gui.getMainView())
+ return gui.handleEscapeMerge()
}
// promptToContinue asks the user if they want to continue the rebase/merge that's in progress
diff --git a/pkg/gui/patch_building_panel.go b/pkg/gui/patch_building_panel.go
index ad05f33c9..4d7e5de69 100644
--- a/pkg/gui/patch_building_panel.go
+++ b/pkg/gui/patch_building_panel.go
@@ -7,7 +7,7 @@ import (
func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int) error {
if !gui.GitCommand.PatchManager.CommitSelected() {
- return gui.handleEscapePatchBuildingPanel(gui.g, nil)
+ return gui.handleEscapePatchBuildingPanel()
}
gui.State.SplitMainPanel = true
@@ -38,7 +38,7 @@ func (gui *Gui) refreshPatchBuildingPanel(selectedLineIdx int) error {
}
if empty {
- return gui.handleEscapePatchBuildingPanel(gui.g, nil)
+ return gui.handleEscapePatchBuildingPanel()
}
return nil
@@ -75,7 +75,7 @@ func (gui *Gui) handleToggleSelectionForPatch(g *gocui.Gui, v *gocui.View) error
return nil
}
-func (gui *Gui) handleEscapePatchBuildingPanel(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleEscapePatchBuildingPanel() error {
gui.handleEscapeLineByLinePanel()
if gui.GitCommand.PatchManager.IsEmpty() {
diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go
index 6f71c21c4..b715a4b61 100644
--- a/pkg/gui/patch_options_panel.go
+++ b/pkg/gui/patch_options_panel.go
@@ -78,7 +78,7 @@ func (gui *Gui) validateNormalWorkingTreeState() (bool, error) {
func (gui *Gui) returnFocusFromLineByLinePanelIfNecessary() error {
if gui.State.MainContext == "patch-building" {
- return gui.handleEscapePatchBuildingPanel(gui.g, nil)
+ return gui.handleEscapePatchBuildingPanel()
}
return nil
}
diff --git a/pkg/gui/quitting.go b/pkg/gui/quitting.go
index 6514c0f8e..b39f3bcb8 100644
--- a/pkg/gui/quitting.go
+++ b/pkg/gui/quitting.go
@@ -26,12 +26,12 @@ func (gui *Gui) recordCurrentDirectory() error {
func (gui *Gui) handleQuitWithoutChangingDirectory(g *gocui.Gui, v *gocui.View) error {
gui.State.RetainOriginalDir = true
- return gui.quit(v)
+ return gui.quit()
}
-func (gui *Gui) handleQuit(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleQuit() error {
gui.State.RetainOriginalDir = false
- return gui.quit(v)
+ return gui.quit()
}
func (gui *Gui) handleTopLevelReturn(g *gocui.Gui, v *gocui.View) error {
@@ -43,20 +43,20 @@ func (gui *Gui) handleTopLevelReturn(g *gocui.Gui, v *gocui.View) error {
}
if gui.Config.GetUserConfig().GetBool("quitOnTopLevelReturn") {
- return gui.handleQuit(g, v)
+ return gui.handleQuit()
}
return nil
}
-func (gui *Gui) quit(v *gocui.View) error {
+func (gui *Gui) quit() error {
if gui.State.Updating {
- return gui.createUpdateQuitConfirmation(gui.g, v)
+ return gui.createUpdateQuitConfirmation()
}
if gui.Config.GetUserConfig().GetBool("confirmOnQuit") {
return gui.ask(askOpts{
- returnToView: v,
+ returnToView: gui.g.CurrentView(),
returnFocusOnClose: true,
title: "",
prompt: gui.Tr.SLocalize("ConfirmQuit"),
diff --git a/pkg/gui/rebase_options_panel.go b/pkg/gui/rebase_options_panel.go
index 4f95e2704..03422da24 100644
--- a/pkg/gui/rebase_options_panel.go
+++ b/pkg/gui/rebase_options_panel.go
@@ -3,11 +3,9 @@ package gui
import (
"fmt"
"strings"
-
- "github.com/jesseduffield/gocui"
)
-func (gui *Gui) handleCreateRebaseOptionsMenu(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handleCreateRebaseOptionsMenu() error {
options := []string{"continue", "abort"}
if gui.GitCommand.WorkingTreeState() == "rebasing" {
diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go
index 517650d5f..eed55b903 100644
--- a/pkg/gui/recent_repos_panel.go
+++ b/