diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-27 17:19:31 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-27 18:16:16 +1100 |
commit | 3e5d4b2c749322351c781c4427852ff4393fcd4f (patch) | |
tree | 87958b5eece97e30cc32620a0a52d038aafc6216 /pkg/gui/controllers | |
parent | e94312b664c3e8daa0a27d6c48fda2d137fe98ac (diff) |
add menu keybindings for various things
Diffstat (limited to 'pkg/gui/controllers')
-rw-r--r-- | pkg/gui/controllers/basic_commits_controller.go | 4 | ||||
-rw-r--r-- | pkg/gui/controllers/bisect_controller.go | 6 | ||||
-rw-r--r-- | pkg/gui/controllers/files_controller.go | 2 | ||||
-rw-r--r-- | pkg/gui/controllers/files_remove_controller.go | 4 | ||||
-rw-r--r-- | pkg/gui/controllers/git_flow_controller.go | 4 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/merge_and_rebase_helper.go | 21 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/refs_helper.go | 20 | ||||
-rw-r--r-- | pkg/gui/controllers/submodules_controller.go | 3 | ||||
-rw-r--r-- | pkg/gui/controllers/workspace_reset_controller.go | 6 |
9 files changed, 60 insertions, 10 deletions
diff --git a/pkg/gui/controllers/basic_commits_controller.go b/pkg/gui/controllers/basic_commits_controller.go index 68c2698fd..bfc9655de 100644 --- a/pkg/gui/controllers/basic_commits_controller.go +++ b/pkg/gui/controllers/basic_commits_controller.go @@ -103,24 +103,28 @@ func (self *BasicCommitsController) copyCommitAttribute(commit *models.Commit) e OnPress: func() error { return self.copyCommitSHAToClipboard(commit) }, + Key: 's', }, { DisplayString: self.c.Tr.LcCommitURL, OnPress: func() error { return self.copyCommitURLToClipboard(commit) }, + Key: 'u', }, { DisplayString: self.c.Tr.LcCommitDiff, OnPress: func() error { return self.copyCommitDiffToClipboard(commit) }, + Key: 'd', }, { DisplayString: self.c.Tr.LcCommitMessage, OnPress: func() error { return self.copyCommitMessageToClipboard(commit) }, + Key: 'm', }, }, }) diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index 5dae02a38..67975f129 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -76,6 +76,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c return self.afterMark(selectCurrentAfter, waitToReselect) }, + Key: 'b', }, { DisplayString: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.OldTerm()), @@ -87,6 +88,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c return self.afterMark(selectCurrentAfter, waitToReselect) }, + Key: 'g', }, { DisplayString: fmt.Sprintf(self.c.Tr.Bisect.Skip, commit.ShortSha()), @@ -98,12 +100,14 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c return self.afterMark(selectCurrentAfter, waitToReselect) }, + Key: 's', }, { DisplayString: self.c.Tr.Bisect.ResetOption, OnPress: func() error { return self.helpers.Bisect.Reset() }, + Key: 'r', }, } @@ -131,6 +135,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, return self.helpers.Bisect.PostBisectCommandRefresh() }, + Key: 'b', }, { DisplayString: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.OldTerm()), @@ -146,6 +151,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, return self.helpers.Bisect.PostBisectCommandRefresh() }, + Key: 'g', }, }, }) diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 2c2590699..88e91771f 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -562,6 +562,7 @@ func (self *FilesController) createStashMenu() error { self.c.LogAction(self.c.Tr.Actions.StashAllChanges) return self.handleStashSave(self.git.Stash.Save) }, + Key: 's', }, { DisplayString: self.c.Tr.LcStashStagedChanges, @@ -569,6 +570,7 @@ func (self *FilesController) createStashMenu() error { self.c.LogAction(self.c.Tr.Actions.StashStagedChanges) return self.handleStashSave(self.git.Stash.SaveStagedChanges) }, + Key: 'S', }, }, }) diff --git a/pkg/gui/controllers/files_remove_controller.go b/pkg/gui/controllers/files_remove_controller.go index c2416bfaf..54af72fa0 100644 --- a/pkg/gui/controllers/files_remove_controller.go +++ b/pkg/gui/controllers/files_remove_controller.go @@ -51,6 +51,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error { } return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) }, + Key: 'd', }, } @@ -65,6 +66,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) }, + Key: 'u', }) } } else { @@ -93,6 +95,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error { } return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) }, + Key: 'd', }, } @@ -107,6 +110,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) }, + Key: 'u', }) } } diff --git a/pkg/gui/controllers/git_flow_controller.go b/pkg/gui/controllers/git_flow_controller.go index a6d8f1da4..a0b0f3074 100644 --- a/pkg/gui/controllers/git_flow_controller.go +++ b/pkg/gui/controllers/git_flow_controller.go @@ -72,18 +72,22 @@ func (self *GitFlowController) handleCreateGitFlowMenu(branch *models.Branch) er { DisplayString: "start feature", OnPress: startHandler("feature"), + Key: 'f', }, { DisplayString: "start hotfix", OnPress: startHandler("hotfix"), + Key: 'h', }, { DisplayString: "start bugfix", OnPress: startHandler("bugfix"), + Key: 'b', }, { DisplayString: "start release", OnPress: startHandler("release"), + Key: 'r', }, }, }) diff --git a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go index 636c1c5fe..73d2c160d 100644 --- a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go +++ b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go @@ -46,18 +46,29 @@ const ( ) func (self *MergeAndRebaseHelper) CreateRebaseOptionsMenu() error { - options := []string{REBASE_OPTION_CONTINUE, REBASE_OPTION_ABORT} + type optionAndKey struct { + option string + key types.Key + } + + options := []optionAndKey{ + {option: REBASE_OPTION_CONTINUE, key: 'c'}, + {option: REBASE_OPTION_ABORT, key: 'a'}, + } if self.git.Status.WorkingTreeState() == enums.REBASE_MODE_REBASING { - options = append(options, REBASE_OPTION_SKIP) + options = append(options, optionAndKey{ + option: REBASE_OPTION_SKIP, key: 's', + }) } - menuItems := slices.Map(options, func(option string) *types.MenuItem { + menuItems := slices.Map(options, func(row optionAndKey) *types.MenuItem { return &types.MenuItem{ - DisplayString: option, + DisplayString: row.option, OnPress: func() error { - return self.genericMergeCommand(option) + return self.genericMergeCommand(row.option) }, + Key: row.key, } }) diff --git a/pkg/gui/controllers/helpers/refs_helper.go b/pkg/gui/controllers/helpers/refs_helper.go index 0838dd6f0..134112fb5 100644 --- a/pkg/gui/controllers/helpers/refs_helper.go +++ b/pkg/gui/controllers/helpers/refs_helper.go @@ -134,17 +134,27 @@ func (self *RefsHelper) ResetToRef(ref string, strength string, envVars []string } func (self *RefsHelper) CreateGitResetMenu(ref string) error { - strengths := []string{"soft", "mixed", "hard"} - menuItems := slices.Map(strengths, func(strength string) *types.MenuItem { + type strengthWithKey struct { + strength string + key types.Key + } + strengths := []strengthWithKey{ + {strength: "soft", key: 's'}, + {strength: "mixed", key: 'm'}, + {strength: "hard", key: 'h'}, + } + + menuItems := slices.Map(strengths, func(row strengthWithKey) *types.MenuItem { return &types.MenuItem{ DisplayStrings: []string{ - fmt.Sprintf("%s reset", strength), - style.FgRed.Sprintf("reset --%s %s", strength, ref), + fmt.Sprintf("%s reset", row.strength), + style.FgRed.Sprintf("reset --%s %s", row.strength, ref), }, OnPress: func() error { self.c.LogAction("Reset") - return self.ResetToRef(ref, strength, []string{}) + return self.ResetToRef(ref, row.strength, []string{}) }, + Key: row.key, } }) diff --git a/pkg/gui/controllers/submodules_controller.go b/pkg/gui/controllers/submodules_controller.go index 10b25df2b..33f0febc3 100644 --- a/pkg/gui/controllers/submodules_controller.go +++ b/pkg/gui/controllers/submodules_controller.go @@ -158,6 +158,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error { return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}}) }) }, + Key: 'i', }, { DisplayStrings: []string{self.c.Tr.LcBulkUpdateSubmodules, style.FgYellow.Sprint(self.git.Submodule.BulkUpdateCmdObj().ToString())}, @@ -171,6 +172,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error { return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}}) }) }, + Key: 'u', }, { DisplayStrings: []string{self.c.Tr.LcBulkDeinitSubmodules, style.FgRed.Sprint(self.git.Submodule.BulkDeinitCmdObj().ToString())}, @@ -184,6 +186,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error { return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}}) }) }, + Key: 'd', }, }, }) diff --git a/pkg/gui/controllers/workspace_reset_controller.go b/pkg/gui/controllers/workspace_reset_controller.go index 9153e34e8..32dd959df 100644 --- a/pkg/gui/controllers/workspace_reset_controller.go +++ b/pkg/gui/controllers/workspace_reset_controller.go @@ -31,6 +31,7 @@ func (self *FilesController) createResetMenu() error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) }, + Key: 'D', }, { DisplayStrings: []string{ @@ -45,6 +46,7 @@ func (self *FilesController) createResetMenu() error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) }, + Key: 'u', }, { DisplayStrings: []string{ @@ -59,6 +61,7 @@ func (self *FilesController) createResetMenu() error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) }, + Key: 'c', }, { DisplayStrings: []string{ @@ -73,6 +76,7 @@ func (self *FilesController) createResetMenu() error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) }, + Key: 's', }, { DisplayStrings: []string{ @@ -87,6 +91,7 @@ func (self *FilesController) createResetMenu() error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) }, + Key: 'm', }, { DisplayStrings: []string{ @@ -101,6 +106,7 @@ func (self *FilesController) createResetMenu() error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) }, + Key: 'h', }, } |