diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2024-01-02 14:00:36 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2024-01-28 08:12:01 +1100 |
commit | 7bddf532235cc67d847fd70d8f709b6401737936 (patch) | |
tree | c248ea926268ecd1e844d924fac438c6f1701edd /pkg | |
parent | 0aa6109d4d767cf77d4fb3eeefd0ac477d718ccf (diff) |
Improve keybinding descriptions
This adds a bunch of tooltips to keybindings and updates some keybinding descriptions (i.e. labels).
It's in preparation for displaying more keybindings on-screen (in the bottom right of the screen),
and so due in part to laziness it shortens some descriptions so that we don't need to manage both
a short and long description (for on-screen vs in-menu). Nonetheless I've added a ShortDescription
field for when we do want to have both a short and long description.
You'll notice that some keybindings I deemed unworthy of the options view have longer descriptions,
because I could get away with it.
Diffstat (limited to 'pkg')
35 files changed, 1488 insertions, 1170 deletions
diff --git a/pkg/constants/links.go b/pkg/constants/links.go index 1fef42b5d..c1335052b 100644 --- a/pkg/constants/links.go +++ b/pkg/constants/links.go @@ -8,6 +8,7 @@ type Docs struct { Undoing string Config string Tutorial string + CustomPatchDemo string } var Links = struct { @@ -31,5 +32,6 @@ var Links = struct { Undoing: "https://github.com/jesseduffield/lazygit/blob/master/docs/Undoing.md", Config: "https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md", Tutorial: "https://youtu.be/VDXvbHZYeKY", + CustomPatchDemo: "https://github.com/jesseduffield/lazygit#rebase-magic-custom-patches", }, } diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index 5837704b5..30caae930 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -16,6 +16,9 @@ func (gui *Gui) Helpers() *helpers.Helpers { return gui.helpers } +// Note, the order of controllers determines the order in which keybindings appear +// in the keybinding menu: the earlier that the controller is attached to a context, +// the lower in the list the keybindings will appear. func (gui *Gui) resetHelpersAndControllers() { helperCommon := gui.c recordDirectoryHelper := helpers.NewRecordDirectoryHelper(helperCommon) @@ -199,6 +202,18 @@ func (gui *Gui) resetHelpersAndControllers() { controllers.AttachControllers(context, searchControllerFactory.Create(context)) } + for _, context := range []controllers.CanViewWorktreeOptions{ + gui.State.Contexts.LocalCommits, + gui.State.Contexts.ReflogCommits, + gui.State.Contexts.SubCommits, + gui.State.Contexts.Stash, + gui.State.Contexts.Branches, + gui.State.Contexts.RemoteBranches, + gui.State.Contexts.Tags, + } { + controllers.AttachControllers(context, controllers.NewWorktreeOptionsController(common, context)) + } + // allow for navigating between side window contexts for _, context := range []types.Context{ gui.State.Contexts.Status, @@ -247,18 +262,6 @@ func (gui *Gui) resetHelpersAndControllers() { controllers.AttachControllers(context, controllers.NewBasicCommitsController(common, context)) } - for _, context := range []controllers.CanViewWorktreeOptions{ - gui.State.Contexts.LocalCommits, - gui.State.Contexts.ReflogCommits, - gui.State.Contexts.SubCommits, - gui.State.Contexts.Stash, - gui.State.Contexts.Branches, - gui.State.Contexts.RemoteBranches, - gui.State.Contexts.Tags, - } { - controllers.AttachControllers(context, controllers.NewWorktreeOptionsController(common, context)) - } - controllers.AttachControllers(gui.State.Contexts.ReflogCommits, reflogCommitsController, ) @@ -306,11 +309,6 @@ func (gui *Gui) resetHelpersAndControllers() { submodulesController, ) - controllers.AttachControllers(gui.State.Contexts.LocalCommits, - localCommitsController, - bisectController, - ) - controllers.AttachControllers(gui.State.Contexts.Branches, branchesController, gitFlowController, @@ -374,11 +372,11 @@ func (gui *Gui) resetHelpersAndControllers() { ) controllers.AttachControllers(gui.State.Contexts.Global, - syncController, undoController, globalController, contextLinesController, jumpToSideWindowController, + syncController, ) controllers.AttachControllers(gui.State.Contexts.Snake, diff --git a/pkg/gui/controllers/basic_commits_controller.go b/pkg/gui/controllers/basic_commits_controller.go index 6c378ecf0..c62818df9 100644 --- a/pkg/gui/controllers/basic_commits_controller.go +++ b/pkg/gui/controllers/basic_commits_controller.go @@ -5,7 +5,9 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/utils" ) // This controller is for all contexts that contain a list of commits. @@ -48,13 +50,15 @@ func (self *BasicCommitsController) GetKeybindings(opts types.KeybindingsOpts) [ Key: opts.GetKey(opts.Config.Commits.CheckoutCommit), Handler: self.withItem(self.checkout), GetDisabledReason: self.require(self.singleItemSelected()), - Description: self.c.Tr.CheckoutCommit, + Description: self.c.Tr.Checkout, + Tooltip: self.c.Tr.CheckoutCommitTooltip, }, { Key: opts.GetKey(opts.Config.Commits.CopyCommitAttributeToClipboard), Handler: self.withItem(self.copyCommitAttribute), GetDisabledReason: self.require(self.singleItemSelected()), Description: self.c.Tr.CopyCommitAttributeToClipboard, + Tooltip: self.c.Tr.CopyCommitAttributeToClipboardTooltip, OpensMenu: true, }, { @@ -74,12 +78,19 @@ func (self *BasicCommitsController) GetKeybindings(opts types.KeybindingsOpts) [ Handler: self.withItem(self.createResetMenu), GetDisabledReason: self.require(self.singleItemSelected()), Description: self.c.Tr.ViewResetOptions, + Tooltip: self.c.Tr.ResetTooltip, OpensMenu: true, }, { Key: opts.GetKey(opts.Config.Commits.CherryPickCopy), Handler: self.withItem(self.copyRange), Description: self.c.Tr.CherryPickCopy, + Tooltip: utils.ResolvePlaceholderString(self.c.Tr.CherryPickCopyTooltip, + map[string]string{ + "paste": keybindings.Label(opts.Config.Commits.PasteCommits), + "escape": keybindings.Label(opts.Config.Universal.Return), + }, + ), }, { Key: opts.GetKey(opts.Config.Commits.ResetCherryPick), diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index dbd15ef93..002aca4fb 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -48,6 +48,7 @@ func (self *BranchesController) GetKeybindings(opts types.KeybindingsOpts) []*ty self.notPulling, ), Description: self.c.Tr.Checkout, + Tooltip: self.c.Tr.CheckoutTooltip, }, { Key: opts.GetKey(opts.Config.Universal.New), @@ -78,18 +79,21 @@ func (self *BranchesController) GetKeybindings(opts types.KeybindingsOpts) []*ty Key: opts.GetKey(opts.Config.Branches.CheckoutBranchByName), Handler: self.checkoutByName, Description: self.c.Tr.CheckoutByName, + Tooltip: self.c.Tr.CheckoutByNameTooltip, }, { Key: opts.GetKey(opts.Config.Branches.ForceCheckoutBranch), Handler: self.forceCheckout, GetDisabledReason: self.require(self.singleItemSelected()), Description: self.c.Tr.ForceCheckout, + Tooltip: self.c.Tr.ForceCheckoutTooltip, }, { Key: opts.GetKey(opts.Config.Universal.Remove), Handler: self.withItem(self.delete), GetDisabledReason: self.require(self.singleItemSelected(self.branchIsReal)), - Description: self.c.Tr.ViewDeleteOptions, + Description: self.c.Tr.Delete, + Tooltip: self.c.Tr.BranchDeleteTooltip, OpensMenu: true, }, { @@ -99,24 +103,27 @@ func (self *BranchesController) GetKeybindings(opts types.KeybindingsOpts) []*ty self.singleItemSelected(self.notRebasingOntoSelf), ), Description: self.c.Tr.RebaseBranch, + Tooltip: self.c.Tr.RebaseBranchTooltip, }, { Key: opts.GetKey(opts.Config.Branches.MergeIntoCurrentBranch), Handler: opts.Guards.OutsideFilterMode(self.merge), GetDisabledReason: self.require(self.singleItemSelected()), - Description: self.c.Tr.MergeIntoCurrentBranch, + Description: self.c.Tr.Merge, + Tooltip: self.c.Tr.MergeBranchTooltip, }, { Key: opts.GetKey(opts.Config.Branches.FastForward), Handler: self.withItem(self.fastForward), GetDisabledReason: self.require(self.singleItemSelected(self.branchIsReal)), Description: self.c.Tr.FastForward, + Tooltip: self.c.Tr.FastForwardTooltip, }, { Key: opts.GetKey(opts.Config.Branches.CreateTag), Handler: self.withItem(self.createTag), GetDisabledReason: self.require(self.singleItemSelected()), - Description: self.c.Tr.CreateTag, + Description: self.c.Tr.NewTag, }, { Key: opts.GetKey(opts.Config.Branches.SortOrder), @@ -142,6 +149,7 @@ func (self *BranchesController) GetKeybindings(opts types.KeybindingsOpts) []*ty GetDisabledReason: self.require(self.singleItemSelected()), Description: self.c.Tr.ViewBranchUpstreamOptions, Tooltip: self.c.Tr.ViewBranchUpstreamOptionsTooltip, + ShortDescription: self.c.Tr.Upstream, OpensMenu: true, }, } diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index b3c628cf5..3ff1e50e3 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -5,9 +5,11 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/patch" + "github.com/jesseduffield/lazygit/pkg/constants" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/filetree" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/utils" ) type CommitFilesController struct { @@ -39,25 +41,29 @@ func (self *CommitFilesController) GetKeybindings(opts types.KeybindingsOpts) [] Key: opts.GetKey(opts.Config.CommitFiles.CheckoutCommitFile), Handler: self.withItem(self.checkout), GetDisabledReason: self.require(self.singleItemSelected()), - Description: self.c.Tr.CheckoutCommitFile, + Description: self.c.Tr.Checkout, + Tooltip: self.c.Tr.CheckoutCommitFileTooltip, }, { Key: opts.GetKey(opts.Config.Universal.Remove), Handler: self.withItem(self.discard), GetDisabledReason: self.require(self.singleItemSelected()), - Description: self.c.Tr.DiscardOldFileChange, + Description: self.c.Tr.Remove, + Tooltip: self.c.Tr.DiscardOldFileChangeTooltip, }, { Key: opts.GetKey(opts.Config.Universal.OpenFile), Handler: self.withItem(self.open), GetDisabledReason: self.require(self.singleItemSelected()), Description: self.c.Tr.OpenFile, + Tooltip: self.c.Tr.OpenFileTooltip, }, { Key: opts.GetKey(opts.Config.Universal.Edit), Handler: self.withItem(self.edit), GetDisabledReason: self.require(self.singleItemSelected()), - Description: self.c.Tr.EditFile, + Description: self.c.Tr.Edit, + Tooltip: self.c.Tr.EditFileTooltip, }, { Key: opts.GetKey(opts.Config.Universal.OpenDiffTool), @@ -70,22 +76,30 @@ func (self *CommitFilesController) GetKeybindings(opts types.KeybindingsOpts) [] Handler: self.withItem(self.toggleForPatch), GetDisabledReason: self.require(self.singleItemSelected()), Description: self.c.Tr.ToggleAddToPatch, + Tooltip: utils.ResolvePlaceholderString(self.c.Tr.ToggleAddToPatchTooltip, + map[string]string{"doc": constants.Links.Docs.CustomPatchDemo}, + ), }, { Key: opts.GetKey(opts.Config.Files.ToggleStagedAll), Handler: self.withItem(self.toggleAllForPatch), Description: self.c.Tr.ToggleAllInPatch, + Tooltip: utils.ResolvePlaceholderString(self.c.Tr.ToggleAllInPatchTooltip, + map[string]string{"doc": constants.Links.Docs.CustomPatchDemo}, + ), }, { Key: opts.GetKey(opts.Config.Universal.GoInto), Handler: self.withItem(self.enter), GetDisabledReason: self.require(self.singleItemSelected()), - Description: self.c.Tr.EnterFile, + Description: self.c.Tr.EnterCommitFile, + Tooltip: self.c.Tr.EnterCommitFileTooltip, }, { Key: opts.GetKey(opts.Config.Files.ToggleTreeView), Handler: self.toggleTreeView, Description: self.c.Tr.ToggleTreeView, + Tooltip: self.c.Tr.ToggleTreeViewTooltip, }, } diff --git a/pkg/gui/controllers/context_lines_controller.go b/pkg/gui/controllers/context_lines_controller.go index ddb507b31..2dd538260 100644 --- a/pkg/gui/controllers/context_lines_controller.go +++ b/pkg/gui/controllers/context_lines_controller.go @@ -45,11 +45,13 @@ func (self *ContextLinesController) GetKeybindings(opts types.KeybindingsOpts) [ Key: opts.GetKey(opts.Config.Universal.IncreaseContextInDiffView), Handler: self.Increase, Description: self.c.Tr.IncreaseContextInDiffView, + Tooltip: self.c.Tr.IncreaseContextInDiffViewTooltip, }, { Key: opts.GetKey(opts.Config.Universal.DecreaseContextInDiffView), Handler: self.Decrease, Description: self.c.Tr.DecreaseContextInDiffView, + Tooltip: self.c.Tr.DecreaseContextInDiffViewTooltip, }, } diff --git a/pkg/gui/controllers/custom_patch_options_menu_action.go b/pkg/gui/controllers/custom_patch_options_menu_action.go index 5710b44b7..701c3c7d1 100644 --- a/pkg/gui/controllers/custom_patch_options_menu_action.go +++ b/pkg/gui/controllers/custom_patch_options_menu_action.go @@ -25,16 +25,19 @@ func (self *CustomPatchOptionsMenuAction) Call() error { menuItems := []*types.MenuItem{ { Label: self.c.Tr.ResetPatch, + Tooltip: self.c.Tr.ResetPatchTooltip, OnPress: self.c.Helpers().PatchBuilding.Reset, Key: 'c', }, { Label: self.c.Tr.ApplyPatch, + Tooltip: self.c.Tr.ApplyPatchTooltip, OnPress: func() error { return self.handleApplyPatch(false) }, Key: 'a', }, { Label: self.c.Tr.ApplyPatchInReverse, + Tooltip: self.c.Tr.ApplyPatchInReverseTooltip, OnPress: func() error { return self.handleApplyPatch(true) }, Key: 'r', }, @@ -44,16 +47,19 @@ func (self *CustomPatchOptionsMenuAction) Call() error { menuItems = append(menuItems, []*types.MenuItem{ { Label: fmt.Sprintf(self.c.Tr.RemovePatchFromOriginalCommit, self.c.Git().Patch.PatchBuilder.To), + Tooltip: self.c.Tr.RemovePatchFromOriginalCommitTooltip, OnPress: self.handleDeletePatchFromCommit, Key: 'd', }, { Label: self.c.Tr.MovePatchOutIntoIndex, + Tooltip: self.c.Tr.MovePatchOutIntoIndexTooltip, OnPress: self.handleMovePatchIntoWorkingTree, Key: 'i', }, { Label: self.c.Tr.MovePatchIntoNewCommit, + Tooltip: self.c.Tr.MovePatchIntoNewCommitTooltip, OnPress: self.handlePullPatchIntoNewCommit, Key: 'n', }, @@ -75,6 +81,7 @@ func (self *CustomPatchOptionsMenuAction) Call() error { []*types.MenuItem{ { Label: fmt.Sprintf(self.c.Tr.MovePatchToSelectedCommit, selectedCommit.Sha), + Tooltip: self.c.Tr.MovePatchToSelectedCommitTooltip, OnPress: self.handleMovePatchToSelectedCommit, Key: 'm', DisabledReason: disabledReason, diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index bc797c219..c450b6fe9 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -41,7 +41,8 @@ func (self *FilesController) GetKeybindings(opts types.KeybindingsOpts) []*types Key: opts.GetKey(opts.Config.Universal.Select), Handler: self.withItems(self.press), GetDisabledReason: self.require(self.itemsSelected()), - Description: self.c.Tr.ToggleStaged, + Description: self.c.Tr.Stage, + Tooltip: self.c.Tr.StageTooltip, }, { Key: opts.GetKey(opts.Config.Files.OpenStatusFilter), @@ -57,7 +58,8 @@ func (self *FilesController) GetKeybindings(opts types.KeybindingsOpts) []*types { Key: opts.GetKey(opts.Config.Files.CommitChanges), Handler: self.c.Helpers().WorkingTree.HandleCommitPress, - Description: self.c.Tr.CommitChanges, + Description: self.c.Tr.Commit, + Tooltip: self.c.Tr.CommitTooltip, }, { Key: opts.GetKey(opts.Config.Files.CommitChangesWithoutHook), @@ -84,13 +86,15 @@ func (self *FilesController) GetKeybindings(opts types.KeybindingsOpts) []*types Key: opts.GetKey(opts.Config.Universal.Edit), Handler: self.withItem(self.edit), GetDisabledReason: self.require(self.singleItemSelected()), - Description: self.c.Tr.EditFile, + Description: self.c.Tr.Edit, + Tooltip: self.c.Tr.EditFileTooltip, }, { Key: opts.GetKey(opts.Config.Universal.OpenFile), Handler: self.Open, GetDisabledReason: self.require(self.singleItemSelected()), Description: self.c.Tr.OpenFile, + Tooltip: self.c.Tr.OpenFileTooltip, }, { Key: opts.GetKey(opts.Config.Files.IgnoreFile), @@ -107,30 +111,35 @@ func (self *FilesController) GetKeybindings(opts types.KeybindingsOpts) []*types { Key: opts.GetKey(opts.Config.Files.StashAllChanges), Handler: self.stash, - Description: self.c.Tr.StashAllChanges, + Description: self.c.Tr.Stash, + Tooltip: self.c.Tr.StashTooltip, }, { Key: opts.GetKey(opts.Config.Files.ViewStashOptions), Handler: self.createStashMenu, Description: self.c.Tr.ViewStashOptions, + Tooltip: self.c.Tr.ViewStashOptionsTooltip, OpensMenu: true, }, { Key: opts.GetKey(opts.Config.Files.ToggleStagedAll), Handler: self.toggleStagedAll, Description: self.c.Tr.ToggleStagedAll, + Tooltip: self.c.Tr.ToggleStagedAllTooltip, }, { Key: opts.GetKey(opts.Config.Universal.GoInto), Handler: self.enter, GetDisabledReason: self.require(self.singleItemSelected()), Description: self.c.Tr.FileEnter, + Tooltip: self.c.Tr.FileEnterTooltip, }, { Key: opts.GetKey(opts.Config.Universal.Remove), Handler: self.withItems(self.remove), GetDisabledReason: self.require(self.itemsSelected(self.canRemove)), - Description: self.c.Tr.ViewDiscardOptions, + Description: self.c.Tr.Discard, + Tooltip: self.c.Tr.DiscardFileChangesTooltip, OpensMenu: true, }, { @@ -142,13 +151,15 @@ func (self *FilesController) GetKeybindings(opts types.KeybindingsOpts) []*types { Key: opts.GetKey(opts.Config.Files.ViewResetOptions), Handler: self.createResetMenu, - Description: self.c.Tr.ViewResetOptions, + Description: self.c.Tr.Reset, + Tooltip: self.c.Tr.FileResetOptionsTooltip, OpensMenu: true, }, { Key: opts.GetKey(opts.Config.Files.ToggleTreeView), Handler: self.toggleTreeView, Description: self.c.Tr.ToggleTreeView, + Tooltip: self.c.Tr.ToggleTreeViewTooltip, }, { Key: opts.GetKey(opts.Config.Universal.OpenDiffTool), @@ -160,11 +171,13 @@ func (self *FilesController) GetKeybindings(opts types.KeybindingsOpts) []*types Key: opts.GetKey(opts.Config.Files.OpenMergeTool), Handler: self.c.Helpers().WorkingTree.OpenMergeTool, Description: self.c.Tr.OpenMergeTool, + Tooltip: self.c.Tr.OpenMergeToolTooltip, }, { Key: opts.GetKey(opts.Config.Files.Fetch), Handler: self.fetch, Description: self.c.Tr.Fetch, + Tooltip: self.c.Tr.FetchTooltip, }, } } diff --git a/pkg/gui/controllers/global_controller.go b/pkg/gui/controllers/global_controller.go index f8e9b3e6b..ba02ac26a 100644 --- a/pkg/gui/controllers/global_controller.go +++ b/pkg/gui/controllers/global_controller.go @@ -25,6 +25,8 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type Key: opts.GetKey(opts.Config.Universal.ExecuteCustomCommand), Handler: self.customCommand, Description: self.c.Tr.ExecuteCustomCommand, + Tooltip: self.c.Tr.ExecuteCustomCommandTooltip, + OpensMenu: true, }, { Key: opts.GetKey(opts.Config.Universal.CreatePatchOptionsMenu), @@ -36,12 +38,14 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type Key: opts.GetKey(opts.Config.Universal.CreateRebaseOptionsMenu), Handler: self.c.Helpers().MergeAndRebase.CreateRebaseOptionsMenu, Description: self.c.Tr.ViewMergeRebaseOptions, + Tooltip: self.c.Tr.ViewMergeRebaseOptionsTooltip, OpensMenu: true, }, { Key: opts.GetKey(opts.Config.Universal.Refresh), Handler: self.refresh, Description: self.c.Tr.Refresh, + Tooltip: self.c.Tr.RefreshTooltip, }, { Key: opts.GetKey(opts.Config.Universal.NextScreenMode), @@ -65,32 +69,37 @@ func (self *GlobalController) GetKeybindings(opts types.KeybindingsOpts) []*type Modifier: gocui.ModNone, // we have the description on the alt key and not the main key for legacy reasons // (the original main key was 'x' but we've reassigned that to other purposes) - Description: self.c.Tr.OpenMenu, - Handler: self.createOptionsMenu, + Description: self.c.Tr.OpenKeybindingsMenu, + Handler: self.createOptionsMenu, + ShortDescription: self.c.Tr.Keybindings, }, { ViewName: "", Key: opts.GetKey(opts.Config.Universal.FilteringMenu), Handler: self.createFilteringMenu, Description: self.c.Tr.OpenFilteringMenu, + Tooltip: self.c.Tr.OpenFilteringMenuTooltip, OpensMenu: true, }, { Key: opts.GetKey(opts.Config.Universal.DiffingMenu), Handler: self.createDiffingMenu, - Description: self.c.Tr.OpenDiffingMenu, + Description: self.c.Tr.ViewDiffingOptions, + Tooltip: self.c.Tr.ViewDiffingOptionsTooltip, OpensMenu: true, }, { Key: opts.GetKey(opts.Config.Universal.DiffingMenuAlt), Handler: self.creat |