diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-04-15 20:30:24 +1000 |
---|---|---|
committer | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2020-04-15 10:44:56 +0000 |
commit | 2974a57943cc673972bc346b23527a95086ccdfe (patch) | |
tree | e527acbd62fbb7c156c3df552ea85f99e55512ea /pkg | |
parent | fcdcd1c335974bab0499be5549021e6938653554 (diff) |
support copying stuff to clipboard
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/os.go | 11 | ||||
-rw-r--r-- | pkg/config/app_config.go | 1 | ||||
-rw-r--r-- | pkg/config/config_default_platform.go | 3 | ||||
-rw-r--r-- | pkg/config/config_linux.go | 3 | ||||
-rw-r--r-- | pkg/config/config_windows.go | 3 | ||||
-rw-r--r-- | pkg/gui/branches_panel.go | 9 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 9 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 146 | ||||
-rw-r--r-- | pkg/i18n/english.go | 6 |
9 files changed, 56 insertions, 135 deletions
diff --git a/pkg/commands/os.go b/pkg/commands/os.go index 517372662..98317312d 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -454,3 +454,14 @@ func RunLineOutputCmd(cmd *exec.Cmd, onLine func(line string) (bool, error)) err cmd.Wait() return nil } + +func (c *OSCommand) CopyToClipboard(str string) error { + commandTemplate := c.Config.GetUserConfig().GetString("os.copyToClipboardCommand") + templateValues := map[string]string{ + "str": c.Quote(str), + } + + command := utils.ResolvePlaceholderString(commandTemplate, templateValues) + + return c.RunCommand(command) +} diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 9db3ce547..76f2fb76f 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -322,6 +322,7 @@ keybinding: redo: '<c-z>' filteringMenu: <c-s> diffingMenu: '<c-e>' + copyToClipboard: '<c-o>' status: checkForUpdate: 'u' recentRepos: '<enter>' diff --git a/pkg/config/config_default_platform.go b/pkg/config/config_default_platform.go index df205c0d7..0eccd96ab 100644 --- a/pkg/config/config_default_platform.go +++ b/pkg/config/config_default_platform.go @@ -7,5 +7,6 @@ func GetPlatformDefaultConfig() []byte { return []byte( `os: openCommand: 'open {{filename}}' - openLinkCommand: 'open {{link}}'`) + openLinkCommand: 'open {{link}}' + copyToClipboardCommand: 'bash -c "echo -n {{str}} | pbcopy"'`) } diff --git a/pkg/config/config_linux.go b/pkg/config/config_linux.go index 2dfbdb1c6..8f3223cfc 100644 --- a/pkg/config/config_linux.go +++ b/pkg/config/config_linux.go @@ -5,5 +5,6 @@ func GetPlatformDefaultConfig() []byte { return []byte( `os: openCommand: 'sh -c "xdg-open {{filename}} >/dev/null"' - openLinkCommand: 'sh -c "xdg-open {{link}} >/dev/null"'`) + openLinkCommand: 'sh -c "xdg-open {{link}} >/dev/null"' + copyToClipboardCommand: 'bash -c "echo -n {{str}} | xclip -selection clipboard"'`) } diff --git a/pkg/config/config_windows.go b/pkg/config/config_windows.go index 6f6560316..d56483af8 100644 --- a/pkg/config/config_windows.go +++ b/pkg/config/config_windows.go @@ -5,5 +5,6 @@ func GetPlatformDefaultConfig() []byte { return []byte( `os: openCommand: 'cmd /c "start "" {{filename}}"' - openLinkCommand: 'cmd /c "start "" {{link}}"'`) + openLinkCommand: 'cmd /c "start "" {{link}}"' + copyToClipboardCommand: 'cmd \c "echo -n {{str}} > /dev/clipboard"`) } diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index c3bbcb059..75c01d0e1 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -520,3 +520,12 @@ func (gui *Gui) currentBranch() *commands.Branch { } return gui.State.Branches[0] } + +func (gui *Gui) handleClipboardCopyBranch(g *gocui.Gui, v *gocui.View) error { + branch := gui.getSelectedBranch() + if branch == nil { + return nil + } + + return gui.OSCommand.CopyToClipboard(branch.Name) +} diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index cda71eb42..c7ea04b20 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -703,3 +703,12 @@ func (gui *Gui) handleGotoBottomForCommitsPanel(g *gocui.Gui, v *gocui.View) err return nil } + +func (gui *Gui) handleClipboardCopyCommit(g *gocui.Gui, v *gocui.View) error { + commit := gui.getSelectedCommit() + if commit == nil { + return nil + } + + return gui.OSCommand.CopyToClipboard(commit.Sha) +} diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 5ee8466d3..01447a67b 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -222,7 +222,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "", Key: gui.getKey("universal.scrollUpMain"), - Modifier: gocui.ModNone, Handler: gui.scrollUpMain, Alternative: "fn+up", Description: gui.Tr.SLocalize("scrollUpMainPanel"), @@ -230,7 +229,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "", Key: gui.getKey("universal.scrollDownMain"), - Modifier: gocui.ModNone, Handler: gui.scrollDownMain, Alternative: "fn+down", Description: gui.Tr.SLocalize("scrollDownMainPanel"), @@ -262,42 +260,36 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "", Key: gui.getKey("universal.createRebaseOptionsMenu"), - Modifier: gocui.ModNone, Handler: gui.handleCreateRebaseOptionsMenu, Description: gui.Tr.SLocalize("ViewMergeRebaseOptions"), }, { ViewName: "", Key: gui.getKey("universal.createPatchOptionsMenu"), - Modifier: gocui.ModNone, Handler: gui.handleCreatePatchOptionsMenu, Description: gui.Tr.SLocalize("ViewPatchOptions"), }, { ViewName: "", Key: gui.getKey("universal.pushFiles"), - Modifier: gocui.ModNone, Handler: gui.pushFiles, Description: gui.Tr.SLocalize("push"), }, { ViewName: "", Key: gui.getKey("universal.pullFiles"), - Modifier: gocui.ModNone, Handler: gui.handlePullFiles, Description: gui.Tr.SLocalize("pull"), }, { ViewName: "", Key: gui.getKey("universal.refresh"), - Modifier: gocui.ModNone, Handler: gui.handleRefresh, Description: gui.Tr.SLocalize("refresh"), }, { ViewName: "", Key: gui.getKey("universal.optionMenu"), - Modifier: gocui.ModNone, Handler: gui.handleCreateOptionsMenu, Description: gui.Tr.SLocalize("openMenu"), }, @@ -316,182 +308,156 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "", Key: gui.getKey("universal.undo"), - Modifier: gocui.ModNone, Handler: gui.reflogUndo, Description: gui.Tr.SLocalize("undoReflog"), }, { ViewName: "", Key: gui.getKey("universal.redo"), - Modifier: gocui.ModNone, Handler: gui.reflogRedo, Description: gui.Tr.SLocalize("redoReflog"), }, { ViewName: "status", Key: gui.getKey("universal.edit"), - Modifier: gocui.ModNone, Handler: gui.handleEditConfig, Description: gui.Tr.SLocalize("EditConfig"), }, { ViewName: "", Key: gui.getKey("universal.nextScreenMode"), - Modifier: gocui.ModNone, Handler: gui.nextScreenMode, Description: gui.Tr.SLocalize("nextScreenMode"), }, { ViewName: "", Key: gui.getKey("universal.prevScreenMode"), - Modifier: gocui.ModNone, Handler: gui.prevScreenMode, Description: gui.Tr.SLocalize("prevScreenMode"), }, { ViewName: "status", Key: gui.getKey("universal.openFile"), - Modifier: gocui.ModNone, Handler: gui.handleOpenConfig, Description: gui.Tr.SLocalize("OpenConfig"), }, { ViewName: "status", Key: gui.getKey("status.checkForUpdate"), - Modifier: gocui.ModNone, Handler: gui.handleCheckForUpdate, Description: gui.Tr.SLocalize("checkForUpdate"), }, { ViewName: "status", Key: gui.getKey("status.recentRepos"), - Modifier: gocui.ModNone, Handler: gui.handleCreateRecentReposMenu, Description: gui.Tr.SLocalize("SwitchRepo"), }, { ViewName: "files", Key: gui.getKey("files.commitChanges"), - Modifier: gocui.ModNone, Handler: gui.handleCommitPress, Description: gui.Tr.SLocalize("CommitChanges"), }, { ViewName: "files", Key: gui.getKey("files.commitChangesWithoutHook"), - Modifier: gocui.ModNone, Handler: gui.handleWIPCommitPress, Description: gui.Tr.SLocalize("commitChangesWithoutHook"), }, { ViewName: "files", Key: gui.getKey("files.amendLastCommit"), - Modifier: gocui.ModNone, Handler: gui.handleAmendCommitPress, Description: gui.Tr.SLocalize("AmendLastCommit"), }, { ViewName: "files", Key: gui.getKey("files.commitChangesWithEditor"), - Modifier: gocui.ModNone, Handler: gui.handleCommitEditorPress, Description: gui.Tr.SLocalize("CommitChangesWithEditor"), }, { ViewName: "files", Key: gui.getKey("universal.select"), - Modifier: gocui.ModNone, Handler: gui.handleFilePress, Description: gui.Tr.SLocalize("toggleStaged"), }, { ViewName: "files", Key: gui.getKey("universal.remove"), - Modifier: gocui.ModNone, Handler: gui.handleCreateDiscardMenu, Description: gui.Tr.SLocalize("viewDiscardOptions"), }, { ViewName: "files", Key: gui.getKey("universal.edit"), - Modifier: gocui.ModNone, Handler: gui.handleFileEdit, Description: gui.Tr.SLocalize("editFile"), }, { ViewName: "files", Key: gui.getKey("universal.openFile"), - Modifier: gocui.ModNone, Handler: gui.handleFileOpen, Description: gui.Tr.SLocalize("openFile"), }, { ViewName: "files", Key: gui.getKey("files.ignoreFile"), - Modifier: gocui.ModNone, Handler: gui.handleIgnoreFile, Description: gui.Tr.SLocalize("ignoreFile"), }, { ViewName: "files", Key: gui.getKey("files.refreshFiles"), - Modifier: gocui.ModNone, Handler: gui.handleRefreshFiles, Description: gui.Tr.SLocalize("refreshFiles"), }, { ViewName: "files", Key: gui.getKey("files.stashAllChanges"), - Modifier: gocui.ModNone, Handler: gui.handleStashChanges, Description: gui.Tr.SLocalize("stashAllChanges"), }, { ViewName: "files", Key: gui.getKey("files.viewStashOptions"), - Modifier: gocui.ModNone, Handler: gui.handleCreateStashMenu, Description: gui.Tr.SLocalize("viewStashOptions"), }, { ViewName: "files", Key: gui.getKey("files.toggleStagedAll"), - Modifier: gocui.ModNone, Handler: gui.handleStageAll, Description: gui.Tr.SLocalize("toggleStagedAll"), }, { ViewName: "files", Key: gui.getKey("files.viewResetOptions"), - Modifier: gocui.ModNone, Handler: gui.handleCreateResetMenu, Description: gui.Tr.SLocalize("viewResetOptions"), }, { ViewName: "files", Key: gui.getKey("universal.goInto"), - Modifier: gocui.ModNone, Handler: gui.handleEnterFile, Description: gui.Tr.SLocalize("StageLines"), }, { ViewName: "files", Key: gui.getKey("files.fetch"), - Modifier: gocui.ModNone, Handler: gui.handleGitFetch, Description: gui.Tr.SLocalize("fetch"), }, { ViewName: "", Key: gui.getKey("universal.executeCustomCommand"), - Modifier: gocui.ModNone, Handler: gui.handleCustomCommand, Description: gui.Tr.SLocalize("executeCustomCommand"), }, { ViewName: "files", Key: gui.getKey("commits.viewResetOptions"), - Modifier: gocui.ModNone, Handler: gui.handleCreateResetToUpstreamMenu, Description: gui.Tr.SLocalize("viewResetToUpstreamOptions"), }, @@ -499,7 +465,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("universal.select"), - Modifier: gocui.ModNone, Handler: gui.handleBranchPress, Description: gui.Tr.SLocalize("checkout"), }, @@ -507,7 +472,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("branches.createPullRequest"), - Modifier: gocui.ModNone, Handler: gui.handleCreatePullRequestPress, Description: gui.Tr.SLocalize("createPullRequest"), }, @@ -515,7 +479,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("branches.checkoutBranchByName"), - Modifier: gocui.ModNone, Handler: gui.handleCheckoutByName, Description: gui.Tr.SLocalize("checkoutByName"), }, @@ -523,7 +486,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("branches.forceCheckoutBranch"), - Modifier: gocui.ModNone, Handler: gui.handleForceCheckout, Description: gui.Tr.SLocalize("forceCheckout"), }, @@ -531,7 +493,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("universal.new"), - Modifier: gocui.ModNone, Handler: gui.handleNewBranch, Description: gui.Tr.SLocalize("newBranch"), }, @@ -539,7 +500,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("universal.remove"), - Modifier: gocui.ModNone, Handler: gui.handleDeleteBranch, Description: gui.Tr.SLocalize("deleteBranch"), }, @@ -547,7 +507,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("branches.rebaseBranch"), - Modifier: gocui.ModNone, Handler: gui.handleRebaseOntoLocalBranch, Description: gui.Tr.SLocalize("rebaseBranch"), }, @@ -555,7 +514,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("branches.mergeIntoCurrentBranch"), - Modifier: gocui.ModNone, Handler: gui.handleMerge, Description: gui.Tr.SLocalize("mergeIntoCurrentBranch"), }, @@ -563,7 +521,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("branches.viewGitFlowOptions"), - Modifier: gocui.ModNone, Handler: gui.handleCreateGitFlowMenu, Description: gui.Tr.SLocalize("gitFlowOptions"), }, @@ -571,7 +528,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("branches.FastForward"), - Modifier: gocui.ModNone, Handler: gui.handleFastForward, Description: gui.Tr.SLocalize("FastForward"), }, @@ -579,7 +535,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("commits.viewResetOptions"), - Modifier: gocui.ModNone, Handler: gui.handleCreateResetToBranchMenu, Description: gui.Tr.SLocalize("viewResetOptions"), }, @@ -587,15 +542,20 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"local-branches"}, Key: gui.getKey("branches.renameBranch"), - Modifier: gocui.ModNone, Handler: gui.handleRenameBranch, Description: gui.Tr.SLocalize("renameBranch"), }, { ViewName: "branches", + Contexts: []string{"local-branches"}, + Key: gui.getKey("universal.copyToClipboard"), + Handler: gui.handleClipboardCopyBranch, + Description: gui.Tr.SLocalize("copyBranchNameToClipboard"), + }, + { + ViewName: "branches", Contexts: []string{"tags"}, Key: gui.getKey("universal.select"), - Modifier: gocui.ModNone, Handler: gui.handleCheckoutTag, Description: gui.Tr.SLocalize("checkout"), }, @@ -603,7 +563,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"tags"}, Key: gui.getKey("universal.remove"), - Modifier: gocui.ModNone, Handler: gui.handleDeleteTag, Description: gui.Tr.SLocalize("deleteTag"), }, @@ -611,7 +570,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"tags"}, Key: gui.getKey("branches.pushTag"), - Modifier: gocui.ModNone, Handler: gui.handlePushTag, Description: gui.Tr.SLocalize("pushTag"), }, @@ -619,7 +577,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"tags"}, Key: gui.getKey("universal.new"), - Modifier: gocui.ModNone, Handler: gui.handleCreateTag, Description: gui.Tr.SLocalize("createTag"), }, @@ -627,21 +584,18 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"tags"}, Key: gui.getKey("commits.viewResetOptions"), - Modifier: gocui.ModNone, Handler: gui.handleCreateResetToTagMenu, Description: gui.Tr.SLocalize("viewResetOptions"), }, { ViewName: "branches", Key: gui.getKey("universal.nextTab"), - Modifier: gocui.ModNone, Handler: gui.handleNextBranchesTab, Description: gui.Tr.SLocalize("nextTab"), }, { ViewName: "branches", Key: gui.getKey("universal.prevTab"), - Modifier: gocui.ModNone, Handler: gui.handlePrevBranchesTab, Description: gui.Tr.SLocalize("prevTab"), }, @@ -649,7 +603,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"remote-branches"}, Key: gui.getKey("universal.return"), - Modifier: gocui.ModNone, Handler: gui.handleRemoteBranchesEscape, Description: gui.Tr.SLocalize("ReturnToRemotesList"), }, @@ -657,7 +610,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"remote-branches"}, Key: gui.getKey("commits.viewResetOptions"), - Modifier: gocui.ModNone, Handler: gui.handleCreateResetToRemoteBranchMenu, Description: gui.Tr.SLocalize("viewResetOptions"), }, @@ -665,21 +617,18 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"remotes"}, Key: gui.getKey("branches.fetchRemote"), - Modifier: gocui.ModNone, Handler: gui.handleFetchRemote, Description: gui.Tr.SLocalize("fetchRemote"), }, { ViewName: "commits", Key: gui.getKey("universal.nextTab"), - Modifier: gocui.ModNone, Handler: gui.handleNextCommitsTab, Description: gui.Tr.SLocalize("nextTab"), }, { ViewName: "commits", Key: gui.getKey("universal.prevTab"), - Modifier: gocui.ModNone, Handler: gui.handlePrevCommitsTab, Description: gui.Tr.SLocalize("prevTab"), }, @@ -687,7 +636,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.squashDown"), - Modifier: gocui.ModNone, Handler: gui.handleCommitSquashDown, Description: gui.Tr.SLocalize("squashDown"), }, @@ -695,7 +643,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.renameCommit"), - Modifier: gocui.ModNone, Handler: gui.handleRenameCommit, Description: gui.Tr.SLocalize("renameCommit"), }, @@ -703,7 +650,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.renameCommitWithEditor"), - Modifier: gocui.ModNone, Handler: gui.handleRenameCommitEditor, Description: gui.Tr.SLocalize("renameCommitEditor"), }, @@ -711,7 +657,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.viewResetOptions"), - Modifier: gocui.ModNone, Handler: gui.handleCreateCommitResetMenu, Description: gui.Tr.SLocalize("resetToThisCommit"), }, @@ -719,7 +664,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.markCommitAsFixup"), - Modifier: gocui.ModNone, Handler: gui.handleCommitFixup, Description: gui.Tr.SLocalize("fixupCommit"), }, @@ -727,7 +671,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.createFixupCommit"), - Modifier: gocui.ModNone, Handler: gui.handleCreateFixupCommit, Description: gui.Tr.SLocalize("createFixupCommit"), }, @@ -735,7 +678,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.squashAboveCommits"), - Modifier: gocui.ModNone, Handler: gui.handleSquashAllAboveFixupCommits, Description: gui.Tr.SLocalize("squashAboveCommits"), }, @@ -743,7 +685,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("universal.remove"), - Modifier: gocui.ModNone, Handler: gui.handleCommitDelete, Description: gui.Tr.SLocalize("deleteCommit"), }, @@ -751,7 +692,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.moveDownCommit"), - Modifier: gocui.ModNone, Handler: gui.handleCommitMoveDown, Description: gui.Tr.SLocalize("moveDownCommit"), }, @@ -759,7 +699,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.moveUpCommit"), - Modifier: gocui.ModNone, Handler: gui.handleCommitMoveUp, Description: gui.Tr.SLocalize("moveUpCommit"), }, @@ -767,7 +706,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("universal.edit"), - Modifier: gocui.ModNone, Handler: gui.handleCommitEdit, Description: gui.Tr.SLocalize("editCommit"), }, @@ -775,7 +713,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.amendToCommit"), - Modifier: gocui.ModNone, Handler: gui.handleCommitAmendTo, Description: gui.Tr.SLocalize("amendToCommit"), }, @@ -783,7 +720,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.pickCommit"), - Modifier: gocui.ModNone, Handler: gui.handleCommitPick, Description: gui.Tr.SLocalize("pickCommit"), }, @@ -791,7 +727,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.revertCommit"), - Modifier: gocui.ModNone, Handler: gui.handleCommitRevert, Description: gui.Tr.SLocalize("revertCommit"), }, @@ -799,15 +734,20 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.cherryPickCopy"), - Modifier: gocui.ModNone, Handler: gui.handleCopyCommit, Description: gui.Tr.SLocalize("cherryPickCopy"), }, { ViewName: "commits", Contexts: []string{"branch-commits"}, + Key: gui.getKey("universal.copyToClipboard"), + Handler: gui.handleClipboardCopyCommit, + Description: gui.Tr.SLocalize("copyCommitShaToClipboard"), + }, + { + ViewName: "commits", + Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.cherryPickCopyRange"), - Modifier: gocui.ModNone, Handler: gui.handleCopyCommitRange, Description: gui.Tr.SLocalize("cherryPickCopyRange"), }, @@ -815,7 +755,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.pasteCommits"), - Modifier: gocui.ModNone, Handler: gui.HandlePasteCommits, Description: gui.Tr.SLocalize("pasteCommits"), }, @@ -823,7 +762,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("universal.goInto"), - Modifier: gocui.ModNone, Handler: gui.handleSwitchToCommitFilesPanel, Description: gui.Tr.SLocalize("viewCommitFiles"), }, @@ -831,7 +769,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.checkoutCommit"), - Modifier: gocui.ModNone, Handler: gui.handleCheckoutCommit, Description: gui.Tr.SLocalize("checkoutCommit"), }, @@ -839,7 +776,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.tagCommit"), - Modifier: gocui.ModNone, Handler: gui.handleTagCommit, Description: gui.Tr.SLocalize("tagCommit"), }, @@ -847,7 +783,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"branch-commits"}, Key: gui.getKey("commits.resetCherryPick"), - Modifier: gocui.ModNone, Handler: gui.handleResetCherryPick, Description: gui.Tr.SLocalize("resetCherryPick"), }, @@ -855,7 +790,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"reflog-commits"}, Key: gui.getKey("universal.select"), - Modifier: gocui.ModNone, Handler: gui.handleCheckoutReflogCommit, Description: gui.Tr.SLocalize("checkoutCommit"), }, @@ -863,28 +797,24 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "commits", Contexts: []string{"reflog-commits"}, Key: gui.getKey("commits.viewResetOptions"), - Modifier: gocui.ModNone, Handler: gui.handleCreateReflogResetMenu, Description: gui.Tr.SLocalize("viewResetOptions"), }, { ViewName: "stash", Key: gui.getKey("universal.select"), - Modifier: gocui.ModNone, Handler: gui.handleStashApply, Description: gui.Tr.SLocalize("apply"), }, { ViewName: "stash", Key: gui.getKey("stash.popStash"), - Modifier: gocui.ModNone, Handler: gui.handleStashPop, Description: gui.Tr.SLocalize("pop"), }, { ViewName: "stash", Key: gui.getKey("universal.remove"), - Modifier: gocui.ModNone, Handler: gui.handleStashDrop, Description: gui.Tr.SLocalize("drop"), }, @@ -915,14 +845,12 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "menu", Key: gui.getKey("universal.return"), - Modifier: gocui.ModNone, Handler: gui.handleMenuClose, Description: gui.Tr.SLocalize("closeMenu"), }, { ViewName: "menu", Key: gui.getKey("universal.quit"), - Modifier: gocui.ModNone, Handler: gui.handleMenuClose, Description: gui.Tr.SLocalize("closeMenu"), }, @@ -935,56 +863,48 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "commitFiles", Key: gui.getKey("universal.return"), - Modifier: gocui.ModNone, Handler: gui.handleSwitchToCommitsPanel, Description: gui.Tr.SLocalize("goBack"), }, { ViewName: "commitFiles", Key: gui.getKey("commitFiles.checkoutCommitFile"), - Modifier: gocui.ModNone, Handler: gui.handleCheckoutCommitFile, Description: gui.Tr.SLocalize("checkoutCommitFile"), }, { ViewName: "commitFiles", Key: gui.getKey("universal.remove"), - Modifier: gocui.ModNone, Handler: gui.handleDiscardOldFileChange, Description: gui.Tr.SLocalize("discardOldFileChange"), }, { ViewName: "commitFiles", Key: gui.getKey("universal.openFile"), - Modifier: gocui.ModNone, Handler: gui.handleOpenOldCommitFile, Description: gui.Tr.SLocalize("openFile"), }, { ViewName: "commitFiles", Key: gui.getKey("universal.select"), - Modifier: gocui.ModNone, Handler: gui.handleToggleFileForPatch, Description: gui.Tr.SLocalize("toggleAddToPatch"), }, { ViewName: "commitFiles", Key: gui.getKey("universal.goInto"), - Modifier: gocui.ModNone, Handler: gui.handleEnterCommitFile, Description: gui.Tr.SLocalize("enterFile"), }, { ViewName: "", Key: gui.getKey("universal.filteringMenu"), - Modifier: gocui.ModNone, Handler: gui.handleCreateFilteringMenuPanel, Description: gui.Tr.SLocalize("openScopingMenu"), }, { ViewName: "", Key: gui.getKey("universal.diffingMenu"), - Modifier: gocui.ModNone, Handler: gui.handleCreateDiffingMenuPanel, Description: gui.Tr.SLocalize("openDiffingMenu"), }, @@ -1011,7 +931,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"normal"}, Key: gocui.MouseWheelDown, - Modifier: gocui.ModNone, Handler: gui.scrollDownMain, Description: gui.Tr.SLocalize("ScrollDown"), Alternative: "fn+up", @@ -1020,7 +939,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"normal"}, Key: gocui.MouseWheelUp, - Modifier: gocui.ModNone, Handler: gui.scrollUpMain, Description: gui.Tr.SLocalize("ScrollUp"), Alternative: "fn+down", @@ -1043,7 +961,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"staging"}, Key: gui.getKey("universal.return"), - Modifier: gocui.ModNone, Handler: gui.handleStagingEscape, Description: gui.Tr.SLocalize("ReturnToFilesPanel"), }, @@ -1051,7 +968,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"staging"}, Key: gui.getKey("universal.select"), - Modifier: gocui.ModNone, Handler: gui.handleToggleStagedSelection, Description: gui.Tr.SLocalize("StageSelection"), }, @@ -1059,7 +975,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"staging"}, Key: gui.getKey("universal.remove"), - Modifier: gocui.ModNone, Handler: gui.handleResetSelection, Description: gui.Tr.SLocalize("ResetSelection"), }, @@ -1067,7 +982,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"staging"}, Key: gui.getKey("universal.togglePanel"), - Modifier: gocui.ModNone, Handler: gui.handleTogglePanel, Description: gui.Tr.SLocalize("TogglePanel"), }, @@ -1075,7 +989,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"patch-building"}, Key: gui.getKey("universal.return"), - Modifier: gocui.ModNone, Handler: gui.handleEscapePatchBuildingPanel, Description: gui.Tr.SLocalize("ExitLineByLineMode"), }, @@ -1083,7 +996,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"patch-building", "staging"}, Key: gui.getKey("universal.prevItem"), - Modifier: gocui.ModNone, Handler: gui.handleSelectPrevLine, Description: gui.Tr.SLocalize("PrevLine"), }, @@ -1091,7 +1003,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"patch-building", "staging"}, Key: gui.getKey("universal.nextItem"), - Modifier: gocui.ModNone, Handler: gui.handleSelectNextLine, Description: gui.Tr.SLocalize("NextLine"), }, @@ -1127,7 +1038,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"patch-building", "staging"}, Key: gui.getKey("universal.prevBlock"), - Modifier: gocui.ModNone, Handler: gui.handleSelectPrevHunk, Description: gui.Tr.SLocalize("PrevHunk"), }, @@ -1135,7 +1045,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"patch-building", "staging"}, Key: gui.getKey("universal.nextBlock"), - Modifier: gocui.ModNone, Handler: gui.handleSelectNextHunk, Description: gui.Tr.SLocalize("NextHunk"), }, @@ -1157,7 +1066,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"staging"}, Key: gui.getKey("universal.edit"), - Modifier: gocui.ModNone, Handler: gui.handleFileEdit, Description: gui.Tr.SLocalize("editFile"), }, @@ -1165,7 +1073,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"staging"}, Key: gui.getKey("universal.openFile"), - Modifier: gocui.ModNone, Handler: gui.handleFileOpen, Description: gui.Tr.SLocalize("openFile"), }, @@ -1173,7 +1080,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"patch-building"}, Key: gui.getKey("universal.select"), - Modifier: gocui.ModNone, Handler: gui.handleToggleSelectionForPatch, Description: gui.Tr.SLocalize("ToggleSelectionForPatch"), }, @@ -1181,7 +1087,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"patch-building", "staging"}, Key: gui.getKey("main.toggleDragSelect"), - Modifier: gocui.ModNone, Handler: gui.handleToggleSelectRange, Description: gui.Tr.SLocalize("ToggleDragSelect"), }, @@ -1190,7 +1095,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"patch-building", "staging"}, Key: gui.getKey("main.toggleDragSelect-alt"), - Modifier: gocui.ModNone, Handler: gui.handleToggleSelectRange, Description: gui.Tr.SLocalize("ToggleDragSelect"), }, @@ -1198,7 +1102,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"patch-building", "staging"}, Key: gui.getKey("main.toggleSelectHunk"), - Modifier: gocui.ModNone, Handler: gui.handleToggleSelectHunk, Description: gui.Tr.SLocalize("ToggleSelectHunk"), }, @@ -1234,7 +1137,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"staging"}, Key: gui.getKey("files.commitChanges"), - Modifier: gocui.ModNone, Handler: gui.handleCommitPress, Description: gui.Tr.SLocalize("CommitChanges"), }, @@ -1242,7 +1144,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"staging"}, Key: gui.getKey("files.commitChangesWithoutHook"), - Modifier: gocui.ModNone, Handler: gui.handleWIPCommitPress, Description: gui.Tr.SLocalize("commitChangesWithoutHook"), }, @@ -1250,7 +1151,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"staging"}, Key: gui.getKey("files.commitChangesWithEditor"), - Modifier: gocui.ModNone, Handler: gui.handleCommitEditorPress, Description: gui.Tr.SLocalize("CommitChangesWithEditor"), }, @@ -1258,7 +1158,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"merging"}, Key: gui.getKey("universal.return"), - Modifier: gocui.ModNone, Handler: gui.handleEscapeMerge, Description: gui.Tr.SLocalize("ReturnToFilesPanel"), }, @@ -1266,7 +1165,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"merging"}, Key: gui.getKey("universal.select"), - Modifier: gocui.ModNone, Handler: gui.handlePickHunk, Description: gui.Tr.SLocalize("PickHunk"), }, @@ -1274,7 +1172,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"merging"}, Key: gui.getKey("main.pickBothHunks"), - Modifier: gocui.ModNone, Handler: gui.handlePickBothHunks, Description: gui.Tr.SLocalize("PickBothHunks"), }, @@ -1282,7 +1179,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"merging"}, Key: gui.getKey("universal.prevBlock"), - Modifier: gocui.ModNone, Handler: gui.handleSelectPrevConflict, Description: gui.Tr.SLocalize("PrevConflict"), }, @@ -1290,7 +1186,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"merging"}, Key: gui.getKey("universal.nextBlock"), - Modifier: gocui.ModNone, Handler: gui.handleSelectNextConflict, Description: gui.Tr.SLocalize("NextConflict"), }, @@ -1298,7 +1193,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"merging"}, Key: gui.getKey("universal.prevItem"), - Modifier: gocui.ModNone, Handler: gui.handleSelectTop, Description: gui.Tr.SLocalize("SelectTop"), }, @@ -1306,7 +1200,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"merging"}, Key: gui.getKey("universal.nextItem"), - Modifier: gocui.ModNone, Handler: gui.handleSelectBottom, Description: gui.Tr.SLocalize("SelectBottom"), }, @@ -1356,7 +1249,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "main", Contexts: []string{"merging"}, Key: gui.getKey("universal.undo"), - Modifier: gocui.ModNone, Handler: gui.handlePopFileSnapshot, Description: gui.Tr.SLocalize("undo"), }, @@ -1371,7 +1263,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"remotes"}, Key: gui.getKey("universal.new"), - Modifier: gocui.ModNone, Handler: gui.handleAddRemote, Description: gui.Tr.SLocalize("addNewRemote"), }, @@ -1379,7 +1270,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"remotes"}, Key: gui.getKey("universal.remove"), - Modifier: gocui.ModNone, Handler: gui.handleRemoveRemote, Description: gui.Tr.SLocalize("removeRemote"), }, @@ -1387,7 +1277,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"remotes"}, Key: gui.getKey("universal.edit"), - Modifier: gocui.ModNone, Handler: gui.handleEditRemote, Description: gui.Tr.SLocalize("editRemote"), }, @@ -1395,7 +1284,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"remote-branches"}, Key: gui.getKey("universal.select"), - Modifier: gocui.ModNone, Handler: gui.handleCheckoutRemoteBranch, Description: gui.Tr.SLocalize("checkout"), }, @@ -1403,7 +1291,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"remote-branches"}, Key: gui.getKey("branches.mergeIntoCurrentBranch"), - Modifier: gocui.ModNone, Handler: gui.handleMergeRemoteBranch, Description: gui.Tr.SLocalize("mergeIntoCurrentBranch"), }, @@ -1411,7 +1298,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"remote-branches"}, Key: gui.getKey("universal.remove"), - Modifier: gocui.ModNone, Handler: gui.handleDeleteRemoteBranch, Description: gui.Tr.SLocalize("deleteBranch"), }, @@ -1419,7 +1305,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"remote-branches"}, Key: gui.getKey("branches.rebaseBranch"), - Modifier: gocui.ModNone, Handler: gui.handleRebaseOntoRemoteBranch, Description: gui.Tr.SLocalize("rebaseBranch"), }, @@ -1427,7 +1312,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: "branches", Contexts: []string{"remote-branches"}, Key: gui.getKey("branches.setUpstream"), - Modifier: gocui.ModNone, Handler: gui.handleSetBranchUpstream, Description: gui.Tr.SLocalize("setUpstream"), }, @@ -1529,7 +1413,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.startSearch"), - Modifier: gocui.ModNone, Handler: openSearchHandler, Description: gui.Tr.SLocalize("startSearch"), }, @@ -1537,7 +1420,6 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.gotoBottom"), - Modifier: gocui.ModNone, Handler: gotoBottomHandler, Description: gui.Tr.SLocalize("gotoBottom"), }, diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index a7b4e0705..7a2f5c88a 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -1131,6 +1131,12 @@ func addEnglish(i18nObject *i18n.Bundle) error { }, &i18n.Message{ ID: "showingGitDiff", Other: "showing output for:", + }, &i18n.Message{ + ID: "copyCommitShaToClipboard", + Other: "copy commit SHA to clipboard", + }, &i18n.Message{ + ID: "copyBranchNameToClipboard", + Other: "copy branch name to clipboard", }, ) } |