diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index d0294de01..1ff49da51 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -265,6 +265,94 @@ update: reporting: 'undetermined' # one of: 'on' | 'off' | 'undetermined' splashUpdatesIndex: 0 confirmOnQuit: false +keybinding: + universal: + quit: 'q' + quit-alt1: '' + return: '' + quitWithoutChangingDirectory: 'Q' + togglePanel: '' + prevItem: '' + nextItem: '' + prevItem-alt: 'k' + nextItem-alt: 'j' + prevBlock: '' + nextBlock: '' + prevBlock-alt: 'h' + nextBlock-alt: 'l' + optionMenu: 'x' + optionMenu-alt1: '?' + select: '' + remove: 'd' + new: 'n' + edit: 'e' + openFile: 'o' + scrollUpMain: '' + scrollDownMain: '' + scrollUpMain-alt1: 'K' + scrollDownMain-alt1: 'J' + scrollUpMain-alt2: '' + scrollDownMain-alt2: '' + createRebaseOptionsMenu: 'm' + pushFiles: 'P' + pullFiles: 'p' + refresh: 'R' + createPatchOptionsMenu: '' + status: + checkForUpdate: 'u' + recentRepos: 's' + files: + commitChanges: 'c' + commitChangesWithoutHook: 'w' + amendLastCommit: 'A' + commitChangesWithEditor: 'C' + ignoreFile: 'i' + refreshFiles: 'r' + stashAllChanges: 's' + viewStashOptions: 'S' + toggleStagedAll: 'a' + viewResetOptions: 'D' + fetch: 'f' + executeCustomCommand: 'X' + branches: + createPullRequest: 'o' + checkoutBranchesByName: 'c' + forceCheckoutBranch: 'F' + rebaseBranch: 'r' + mergeIntoCurrentBranch: 'M' + FastForward: 'f' + pushTag: 'P' + nextBranchTab: ']' + prevBranchTab: '[' + setUpstream: 'u' + commits: + squashDown: 's' + renameCommit: 'r' + renameCommitWithEditor: 'R' + resetToThisCommit: 'g' + fixupCommit: 'f' + createFixupCommit: 'F' + squashAboveCommits: 'S' + moveDownCommit: '' + moveUpCommit: '' + amendToCommit: 'A' + pickCommit: 'p' + revertCommit: 't' + cherryPickCopy: 'c' + cherryPickCopyRange: 'C' + pasteCommits: 'v' + viewCommitFiles: '' + tagCommit: 'T' + stash: + popStash: 'g' + commitFiles: + checkoutCommitFile: 'c' + main: + toggleDragSelect: 'v' + toggleDragSelect-alt: 'V' + toggleSelectHunk: 'a' + PickBothHunks: 'b' + undo: 'z' `) } diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 2f82bcfb9..fb36b36bb 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -2,6 +2,7 @@ package gui import ( "github.com/jesseduffield/gocui" + "strings" ) // Binding - a keybinding mapping a key and modifier to a handler. The keypress @@ -66,108 +67,188 @@ func (b *Binding) GetKey() string { return string(key) } +var keymap = map[string]interface{}{ + "": gocui.KeyCtrlA, + "": gocui.KeyCtrlB, + "": gocui.KeyCtrlC, + "": gocui.KeyCtrlD, + "": gocui.KeyCtrlE, + "": gocui.KeyCtrlF, + "": gocui.KeyCtrlG, + "": gocui.KeyCtrlH, + "": gocui.KeyCtrlI, + "": gocui.KeyCtrlJ, + "": gocui.KeyCtrlK, + "": gocui.KeyCtrlL, + "": gocui.KeyCtrlM, + "": gocui.KeyCtrlN, + "": gocui.KeyCtrlO, + "": gocui.KeyCtrlP, + "": gocui.KeyCtrlQ, + "": gocui.KeyCtrlR, + "": gocui.KeyCtrlS, + "": gocui.KeyCtrlT, + "": gocui.KeyCtrlU, + "": gocui.KeyCtrlV, + "": gocui.KeyCtrlW, + "": gocui.KeyCtrlX, + "": gocui.KeyCtrlY, + "": gocui.KeyCtrlZ, + "": gocui.KeyCtrlTilde, + "": gocui.KeyCtrl2, + "": gocui.KeyCtrl3, + "": gocui.KeyCtrl4, + "": gocui.KeyCtrl5, + "": gocui.KeyCtrl6, + "": gocui.KeyCtrl7, + "": gocui.KeyCtrl8, + "": gocui.KeyCtrlSpace, + "": gocui.KeyCtrlBackslash, + "": gocui.KeyCtrlLsqBracket, + "": gocui.KeyCtrlRsqBracket, + "": gocui.KeyCtrlSlash, + "": gocui.KeyCtrlUnderscore, + "": gocui.KeyBackspace, + "": gocui.KeyTab, + "": gocui.KeyEnter, + "": gocui.KeyEsc, + "": gocui.KeySpace, + "": gocui.KeyF1, + "": gocui.KeyF2, + "": gocui.KeyF3, + "": gocui.KeyF4, + "": gocui.KeyF5, + "": gocui.KeyF6, + "": gocui.KeyF7, + "": gocui.KeyF8, + "": gocui.KeyF9, + "": gocui.KeyF10, + "": gocui.KeyF11, + "": gocui.KeyF12, + "": gocui.KeyInsert, + "": gocui.KeyDelete, + "": gocui.KeyHome, + "": gocui.KeyEnd, + "": gocui.KeyPgup, + "": gocui.KeyPgdn, + "": gocui.KeyArrowUp, + "": gocui.KeyArrowDown, + "": gocui.KeyArrowLeft, + "": gocui.KeyArrowRight, +} + +func (gui *Gui) getKey(name string) interface{} { + key := gui.Config.GetUserConfig().GetString("keybinding." + name) + if len(key) > 1 { + return keymap[strings.ToLower(key)] + } else if len(key) == 1 { + return []rune(key)[0] + } + return nil +} + // GetInitialKeybindings is a function. func (gui *Gui) GetInitialKeybindings() []*Binding { bindings := []*Binding{ { ViewName: "", - Key: 'q', + Key: gui.getKey("universal.quit"), Modifier: gocui.ModNone, Handler: gui.handleQuit, }, { ViewName: "", - Key: 'Q', + Key: gui.getKey("universal.quitWithoutChangingDirectory"), Modifier: gocui.ModNone, Handler: gui.handleQuitWithoutChangingDirectory, }, { ViewName: "", - Key: gocui.KeyCtrlC, + Key: gui.getKey("universal.quit-alt1"), Modifier: gocui.ModNone, Handler: gui.handleQuit, }, { ViewName: "", - Key: gocui.KeyEsc, + Key: gui.getKey("universal.return"), Modifier: gocui.ModNone, Handler: gui.handleQuit, }, { ViewName: "", - Key: gocui.KeyPgup, + Key: gui.getKey("universal.scrollUpMain"), Modifier: gocui.ModNone, Handler: gui.scrollUpMain, Alternative: "fn+up", }, { ViewName: "", - Key: gocui.KeyPgdn, + Key: gui.getKey("universal.scrollDownMain"), Modifier: gocui.ModNone, Handler: gui.scrollDownMain, Alternative: "fn+down", }, { ViewName: "", - Key: 'K', + Key: gui.getKey("universal.scrollUpMain-alt1"), Modifier: gocui.ModNone, Handler: gui.scrollUpMain, }, { ViewName: "", - Key: 'J', + Key: gui.getKey("universal.scrollDownMain-alt1"), Modifier: gocui.ModNone, Handler: gui.scrollDownMain, }, { ViewName: "", - Key: gocui.KeyCtrlU, + Key: gui.getKey("universal.scrollUpMain-alt2"), Modifier: gocui.ModNone, Handler: gui.scrollUpMain, }, { ViewName: "", - Key: gocui.KeyCtrlD, + Key: gui.getKey("universal.scrollDownMain-alt2"), Modifier: gocui.ModNone, Handler: gui.scrollDownMain, }, { ViewName: "", - Key: 'm', + Key: gui.getKey("universal.createRebaseOptionsMenu"), Modifier: gocui.ModNone, Handler: gui.handleCreateRebaseOptionsMenu, Description: gui.Tr.SLocalize("ViewMergeRebaseOptions"), }, { ViewName: "", - Key: 'P', + Key: gui.getKey("universal.pushFiles"), Modifier: gocui.ModNone, Handler: gui.pushFiles, Description: gui.Tr.SLocalize("push"), }, { ViewName: "", - Key: 'p', + Key: gui.getKey("universal.pullFiles"), Modifier: gocui.ModNone, Handler: gui.handlePullFiles, Description: gui.Tr.SLocalize("pull"), }, { ViewName: "", - Key: 'R', + Key: gui.getKey("universal.refresh"), Modifier: gocui.ModNone, Handler: gui.handleRefresh, Description: gui.Tr.SLocalize("refresh"), }, { ViewName: "", - Key: 'x', + Key: gui.getKey("universal.optionMenu"), Modifier: gocui.ModNone, Handler: gui.handleCreateOptionsMenu, }, { ViewName: "", - Key: '?', + Key: gui.getKey("universal.optionMenu-alt1"), Modifier: gocui.ModNone, Handler: gui.handleCreateOptionsMenu, }, @@ -179,153 +260,153 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { }, { ViewName: "", - Key: gocui.KeyCtrlP, + Key: gui.getKey("universal.createPatchOptionsMenu"), Modifier: gocui.ModNone, Handler: gui.handleCreatePatchOptionsMenu, }, { ViewName: "status", - Key: 'e', + Key: gui.getKey("universal.edit"), Modifier: gocui.ModNone, Handler: gui.handleEditConfig, Description: gui.Tr.SLocalize("EditConfig"), }, { ViewName: "status", - Key: 'o', + Key: gui.getKey("universal.openFile"), Modifier: gocui.ModNone, Handler: gui.handleOpenConfig, Description: gui.Tr.SLocalize("OpenConfig"), }, { ViewName: "status", - Key: 'u', + Key: gui.getKey("status.checkForUpdate"), Modifier: gocui.ModNone, Handler: gui.handleCheckForUpdate, Description: gui.Tr.SLocalize("checkForUpdate"), }, { ViewName: "status", - Key: 's', + Key: gui.getKey("status.recentRepos"), Modifier: gocui.ModNone, Handler: gui.handleCreateRecentReposMenu, Description: gui.Tr.SLocalize("SwitchRepo"), }, { ViewName: "files", - Key: 'c', + Key: gui.getKey("files.commitChanges"), Modifier: gocui.ModNone, Handler: gui.handleCommitPress, Description: gui.Tr.SLocalize("CommitChanges"), }, { ViewName: "files", - Key: 'w', + Key: gui.getKey("files.commitChangesWithoutHook"), Modifier: gocui.ModNone, Handler: gui.handleWIPCommitPress, Description: gui.Tr.SLocalize("commitChangesWithoutHook"), }, { ViewName: "files", - Key: 'A', + Key: gui.getKey("files.amendLastCommit"), Modifier: gocui.ModNone, Handler: gui.handleAmendCommitPress, Description: gui.Tr.SLocalize("AmendLastCommit"), }, { ViewName: "files", - Key: 'C', + Key: gui.getKey("files.commitChangesWithEditor"), Modifier: gocui.ModNone, Handler: gui.handleCommitEditorPress, Description: gui.Tr.SLocalize("CommitChangesWithEditor"), }, { ViewName: "files", - Key: gocui.KeySpace, + Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, Handler: gui.handleFilePress, Description: gui.Tr.SLocalize("toggleStaged"), }, { ViewName: "files", - Key: 'd', + Key: gui.getKey("universal.remove"), Modifier: gocui.ModNone, Handler: gui.handleCreateDiscardMenu, Description: gui.Tr.SLocalize("viewDiscardOptions"), }, { ViewName: "files", - Key: 'e', + Key: gui.getKey("universal.edit"), Modifier: gocui.ModNone, Handler: gui.handleFileEdit, Description: gui.Tr.SLocalize("editFile"), }, { ViewName: "files", - Key: 'o', + Key: gui.getKey("universal.openFile"), Modifier: gocui.ModNone, Handler: gui.handleFileOpen, Description: gui.Tr.SLocalize("openFile"), }, { ViewName: "files", - Key: 'i', + Key: gui.getKey("files.ignoreFile"), Modifier: gocui.ModNone, Handler: gui.handleIgnoreFile, Description: gui.Tr.SLocalize("ignoreFile"), }, { ViewName: "files", - Key: 'r', + Key: gui.getKey("files.refreshFiles"), Modifier: gocui.ModNone, Handler: gui.handleRefreshFiles, Description: gui.Tr.SLocalize("refreshFiles"), }, { ViewName: "files", - Key: 's', + Key: gui.getKey("files.stashAllChanges"), Modifier: gocui.ModNone, Handler: gui.handleStashChanges, Description: gui.Tr.SLocalize("stashAllChanges"), }, { ViewName: "files", - Key: 'S', + Key: gui.getKey("files.viewStashOptions"), Modifier: gocui.ModNone, Handler: gui.handleCreateStashMenu, Description: gui.Tr.SLocalize("viewStashOptions"), }, { ViewName: "files", - Key: 'a', + Key: gui.getKey("files.toggleStagedAll"), Modifier: gocui.ModNone, Handler: gui.handleStageAll, Description: gui.Tr.SLocalize("toggleStagedAll"), }, { ViewName: "files", - Key: 'D', + Key: gui.getKey("files.viewResetOptions"), Modifier: gocui.ModNone, Handler: gui.handleCreateResetMenu, Description: gui.Tr.SLocalize("viewResetOptions"), }, { ViewName: "files", - Key: gocui.KeyEnter, + Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, Handler: gui.handleEnterFile, Description: gui.Tr.SLocalize("StageLines"), }, { ViewName: "files", - Key: 'f', + Key: gui.getKey("files.fetch"), Modifier: gocui.ModNone, Handler: gui.handleGitFetch, Description: gui.Tr.SLocalize("fetch"), }, { ViewName: "files", - Key: 'X', + Key: gui.getKey("files.executeCustomCommand"), Modifier: gocui.ModNone, Handler: gui.handleCustomCommand, Description: gui.Tr.SLocalize("executeCustomCommand"), @@ -333,7 +414,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"local-branches"}, - Key: gocui.KeySpace, + Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, Handler: gui.handleBranchPress, Description: gui.Tr.SLocalize("checkout"), @@ -341,7 +422,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"local-branches"}, - Key: 'o', + Key: gui.getKey("branches.createPullRequest"), Modifier: gocui.ModNone, Handler: gui.handleCreatePullRequestPress, Description: gui.Tr.SLocalize("createPullRequest"), @@ -349,7 +430,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"local-branches"}, - Key: 'c', + Key: gui.getKey("branches.checkoutBranchesByName"), Modifier: gocui.ModNone, Handler: gui.handleCheckoutByName, Description: gui.Tr.SLocalize("checkoutByName"), @@ -357,7 +438,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"local-branches"}, - Key: 'F', + Key: gui.getKey("branches.forceCheckoutBranch"), Modifier: gocui.ModNone, Handler: gui.handleForceCheckout, Description: gui.Tr.SLocalize("forceCheckout"), @@ -365,7 +446,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"local-branches"}, - Key: 'n', + Key: gui.getKey("universal.new"), Modifier: gocui.ModNone, Handler: gui.handleNewBranch, Description: gui.Tr.SLocalize("newBranch"), @@ -373,7 +454,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"local-branches"}, - Key: 'd', + Key: gui.getKey("universal.remove"), Modifier: gocui.ModNone, Handler: gui.handleDeleteBranch, Description: gui.Tr.SLocalize("deleteBranch"), @@ -381,7 +462,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"local-branches"}, - Key: 'r', + Key: gui.getKey("branches.rebaseBranch"), Modifier: gocui.ModNone, Handler: gui.handleRebaseOntoLocalBranch, Description: gui.Tr.SLocalize("rebaseBranch"), @@ -389,7 +470,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"local-branches"}, - Key: 'M', + Key: gui.getKey("branches.mergeIntoCurrentBranch"), Modifier: gocui.ModNone, Handler: gui.handleMerge, Description: gui.Tr.SLocalize("mergeIntoCurrentBranch"), @@ -397,7 +478,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"local-branches"}, - Key: 'f', + Key: gui.getKey("branches.FastForward"), Modifier: gocui.ModNone, Handler: gui.handleFastForward, Description: gui.Tr.SLocalize("FastForward"), @@ -405,7 +486,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"tags"}, - Key: gocui.KeySpace, + Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, Handler: gui.handleCheckoutTag, Description: gui.Tr.SLocalize("checkout"), @@ -413,7 +494,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"tags"}, - Key: 'd', + Key: gui.getKey("universal.remove"), Modifier: gocui.ModNone, Handler: gui.handleDeleteTag, Description: gui.Tr.SLocalize("deleteTag"), @@ -421,7 +502,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"tags"}, - Key: 'P', + Key: gui.getKey("branches.pushTag"), Modifier: gocui.ModNone, Handler: gui.handlePushTag, Description: gui.Tr.SLocalize("pushTag"), @@ -429,188 +510,188 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"tags"}, - Key: 'n', + Key: gui.getKey("universal.new"), Modifier: gocui.ModNone, Handler: gui.handleCreateTag, Description: gui.Tr.SLocalize("createTag"), }, { ViewName: "branches", - Key: ']', + Key: gui.getKey("branches.nextBranchTab"), Modifier: gocui.ModNone, Handler: gui.handleNextBranchesTab, }, { ViewName: "branches", - Key: '[', + Key: gui.getKey("branches.prevBranchTab"), Modifier: gocui.ModNone, Handler: gui.handlePrevBranchesTab, }, { ViewName: "branches", Contexts: []string{"remote-branches"}, - Key: gocui.KeyEsc, + Key: gui.getKey("universal.return"), Modifier: gocui.ModNone, Handler: gui.handleRemoteBranchesEscape, Description: gui.Tr.SLocalize("ReturnToRemotesList"), }, { ViewName: "commits", - Key: 's', + Key: gui.getKey("commits.squashDown"), Modifier: gocui.ModNone, Handler: gui.handleCommitSquashDown, Description: gui.Tr.SLocalize("squashDown"), }, { ViewName: "commits", - Key: 'r', + Key: gui.getKey("commits.renameCommit"), Modifier: gocui.ModNone, Handler: gui.handleRenameCommit, Description: gui.Tr.SLocalize("renameCommit"), }, { ViewName: "commits", - Key: 'R', + Key: gui.getKey("commits.renameCommitWithEditor"), Modifier: gocui.ModNone, Handler: gui.handleRenameCommitEditor, Description: gui.Tr.SLocalize("renameCommitEditor"), }, { ViewName: "commits", - Key: 'g', + Key: gui.getKey("commits.resetToThisCommit"), Modifier: gocui.ModNone, Handler: gui.handleCreateCommitResetMenu, Description: gui.Tr.SLocalize("resetToThisCommit"), }, { ViewName: "commits", - Key: 'f', + Key: gui.getKey("commits.fixupCommit"), Modifier: gocui.ModNone, Handler: gui.handleCommitFixup, Description: gui.Tr.SLocalize("fixupCommit"), }, { ViewName: "commits", - Key: 'F', + Key: gui.getKey("commits.createFixupCommit"), Modifier: gocui.ModNone, Handler: gui.handleCreateFixupCommit, Description: gui.Tr.SLocalize("createFixupCommit"), }, { ViewName: "commits", - Key: 'S', + Key: gui.getKey("commits.squashAboveCommits"), Modifier: gocui.ModNone, Handler: gui.handleSquashAllAboveFixupCommits, Description: gui.Tr.SLocalize("squashAboveCommits"), }, { ViewName: "commits", - Key: 'd', + Key: gui.getKey("universal.remove"), Modifier: gocui.ModNone, Handler: gui.handleCommitDelete, Description: gui.Tr.SLocalize("deleteCommit"), }, { ViewName: "commits", - Key: gocui.KeyCtrlJ, + Key: gui.getKey("commits.moveDownCommit"), Modifier: gocui.ModNone, Handler: gui.handleCommitMoveDown, Description: gui.Tr.SLocalize("moveDownCommit"), }, { ViewName: "commits", - Key: gocui.KeyCtrlK, + Key: gui.getKey("commits.moveUpCommit"), Modifier: gocui.ModNone, Handler: gui.handleCommitMoveUp, Description: gui.Tr.SLocalize("moveUpCommit"), }, { ViewName: "commits", - Key: 'e', + Key: gui.getKey("universal.edit"), Modifier: gocui.ModNone, Handler: gui.handleCommitEdit, Description: gui.Tr.SLocalize("editCommit"), }, { ViewName: "commits", - Key: 'A', + Key: gui.getKey("commits.amendToCommit"), Modifier: gocui.ModNone, Handler: gui.handleCommitAmendTo, Description: gui.Tr.SLocalize("amendToCommit"), }, { ViewName: "commits", - Key: 'p', + Key: gui.getKey("commits.pickCommit"), Modifier: gocui.ModNone, Handler: gui.handleCommitPick, Description: gui.Tr.SLocalize("pickCommit"), }, { ViewName: "commits", - Key: 't', + Key: gui.getKey("commits.revertCommit"), Modifier: gocui.ModNone, Handler: gui.handleCommitRevert, Description: gui.Tr.SLocalize("revertCommit"), }, { ViewName: "commits", - Key: 'c', + Key: gui.getKey("commits.cherryPickCopy"), Modifier: gocui.ModNone, Handler: gui.handleCopyCommit, Description: gui.Tr.SLocalize("cherryPickCopy"), }, { ViewName: "commits", - Key: 'C', + Key: gui.getKey("commits.cherryPickCopyRange"), Modifier: gocui.ModNone, Handler: gui.handleCopyCommitRange, Description: gui.Tr.SLocalize("cherryPickCopyRange"), }, { ViewName: "commits", - Key: 'v', + Key: gui.getKey("commits.pasteCommits"), Modifier: gocui.ModNone, Handler: gui.HandlePasteCommits, Description: gui.Tr.SLocalize("pasteCommits"), }, { ViewName: "commits", - Key: gocui.KeyEnter, + Key: gui.getKey("commits.viewCommitFiles"), Modifier: gocui.ModNone, Handler: gui.handleSwitchToCommitFilesPanel, Description: gui.Tr.SLocalize("viewCommitFiles"), }, { ViewName: "commits", - Key: gocui.KeySpace, + Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, Handler: gui.handleToggleDiffCommit, Description: gui.Tr.SLocalize("CommitsDiff"), }, { ViewName: "commits", - Key: 'T', + Key: gui.getKey("commits.tagCommit"), Modifier: gocui.ModNone, Handler: gui.handleTagCommit, Description: gui.Tr.SLocalize("tagCommit"), }, { ViewName: "stash", - Key: gocui.KeySpace, + Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, Handler: gui.handleStashApply, Description: gui.Tr.SLocalize("apply"), }, { ViewName: "stash", - Key: 'g', + Key: gui.getKey("stash.popStash"), Modifier: gocui.ModNone, Handler: gui.handleStashPop, Description: gui.Tr.SLocalize("pop"), }, { ViewName: "stash", - Key: 'd', + Key: gui.getKey("universal.remove"), Modifier: gocui.ModNone, Handler: gui.handleStashDrop, Description: gui.Tr.SLocalize("drop"), @@ -641,13 +722,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { }, { ViewName: "menu", - Key: gocui.KeyEsc, + Key: gui.getKey("universal.return"), Modifier: gocui.ModNone, Handler: gui.handleMenuClose, }, { ViewName: "menu", - Key: 'q', + Key: gui.getKey("universal.quit"), Modifier: gocui.ModNone, Handler: gui.handleMenuClose, }, @@ -659,35 +740,35 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { }, { ViewName: "commitFiles", - Key: gocui.KeyEsc, + Key: gui.getKey("universal.return"), Modifier: gocui.ModNone, Handler: gui.handleSwitchToCommitsPanel, Description: gui.Tr.SLocalize("goBack"), }, { ViewName: "commitFiles", - Key: 'c', + Key: gui.getKey("commitFiles.checkoutCommitFile"), Modifier: gocui.ModNone, Handler: gui.handleCheckoutCommitFile, Description: gui.Tr.SLocalize("checkoutCommitFile"), }, { ViewName: "commitFiles", - Key: 'd', + Key: gui.getKey("universal.remove"), Modifier: gocui.ModNone, Handler: gui.handleDiscardOldFileChange, Description: gui.Tr.SLocalize("discardOldFileChange"), }, { ViewName: "commitFiles", - Key: 'o', + Key: gui.getKey("universal.openFile"), Modifier: gocui.ModNone, Handler: gui.handleOpenOldCommitFile, Description: gui.Tr.SLocalize("openFile"), }, { ViewName: "commitFiles", - Key: gocui.KeySpace, + Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, Handler: gui.handleToggleFileForPatch, Description: gui.Tr.SLocalize("toggleAddToPatch"), @@ -753,7 +834,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"staging"}, - Key: gocui.KeyEsc, + Key: gui.getKey("universal.return"), Modifier: gocui.ModNone, Handler: gui.handleStagingEscape, Description: gui.Tr.SLocalize("ReturnToFilesPanel"), @@ -761,7 +842,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"staging"}, - Key: gocui.KeySpace, + Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, Handler: gui.handleStageSelection, Description: gui.Tr.SLocalize("StageSelection"), @@ -769,7 +850,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"staging"}, - Key: 'd', + Key: gui.getKey("universal.remove"), Modifier: gocui.ModNone, Handler: gui.handleResetSelection, Description: gui.Tr.SLocalize("ResetSelection"), @@ -777,7 +858,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"staging"}, - Key: gocui.KeyTab, + Key: gui.getKey("universal.togglePanel"), Modifier: gocui.ModNone, Handler: gui.handleTogglePanel, Description: gui.Tr.SLocalize("TogglePanel"), @@ -785,7 +866,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building"}, - Key: gocui.KeyEsc, + Key: gui.getKey("universal.return"), Modifier: gocui.ModNone, Handler: gui.handleEscapePatchBuildingPanel, Description: gui.Tr.SLocalize("ExitLineByLineMode"), @@ -793,7 +874,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building", "staging"}, - Key: gocui.KeyArrowUp, + Key: gui.getKey("universal.prevItem"), Modifier: gocui.ModNone, Handler: gui.handleSelectPrevLine, Description: gui.Tr.SLocalize("PrevLine"), @@ -801,7 +882,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building", "staging"}, - Key: gocui.KeyArrowDown, + Key: gui.getKey("universal.nextItem"), Modifier: gocui.ModNone, Handler: gui.handleSelectNextLine, Description: gui.Tr.SLocalize("NextLine"), @@ -809,14 +890,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building", "staging"}, - Key: 'k', + Key: gui.getKey("universal.prevItem-alt"), Modifier: gocui.ModNone, Handler: gui.handleSelectPrevLine, }, { ViewName: "main", Contexts: []string{"patch-building", "staging"}, - Key: 'j', + Key: gui.getKey("universal.nextItem-alt"), Modifier: gocui.ModNone, Handler: gui.handleSelectNextLine, }, @@ -837,7 +918,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building", "staging"}, - Key: gocui.KeyArrowLeft, + Key: gui.getKey("universal.prevBlock"), Modifier: gocui.ModNone, Handler: gui.handleSelectPrevHunk, Description: gui.Tr.SLocalize("PrevHunk"), @@ -845,7 +926,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building", "staging"}, - Key: gocui.KeyArrowRight, + Key: gui.getKey("universal.nextBlock"), Modifier: gocui.ModNone, Handler: gui.handleSelectNextHunk, Description: gui.Tr.SLocalize("NextHunk"), @@ -853,21 +934,21 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building", "staging"}, - Key: 'h', + Key: gui.getKey("universal.prevBlock-alt"), Modifier: gocui.ModNone, Handler: gui.handleSelectPrevHunk, }, { ViewName: "main", Contexts: []string{"patch-building", "staging"}, - Key: 'l', + Key: gui.getKey("universal.nextBlock-alt"), Modifier: gocui.ModNone, Handler: gui.handleSelectNextHunk, }, { ViewName: "main", Contexts: []string{"staging"}, - Key: 'e', + Key: gui.getKey("universal.edit"), Modifier: gocui.ModNone, Handler: gui.handleFileEdit, Description: gui.Tr.SLocalize("editFile"), @@ -875,7 +956,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"staging"}, - Key: 'o', + Key: gui.getKey("universal.openFile"), Modifier: gocui.ModNone, Handler: gui.handleFileOpen, Description: gui.Tr.SLocalize("openFile"), @@ -883,7 +964,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building"}, - Key: gocui.KeySpace, + Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, Handler: gui.handleAddSelectionToPatch, Description: gui.Tr.SLocalize("StageSelection"), @@ -891,7 +972,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building"}, - Key: 'd', + Key: gui.getKey("universal.remove"), Modifier: gocui.ModNone, Handler: gui.handleRemoveSelectionFromPatch, Description: gui.Tr.SLocalize("ResetSelection"), @@ -899,7 +980,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building", "staging"}, - Key: 'v', + Key: gui.getKey("main.toggleDragSelect"), Modifier: gocui.ModNone, Handler: gui.handleToggleSelectRange, Description: gui.Tr.SLocalize("ToggleDragSelect"), @@ -908,7 +989,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building", "staging"}, - Key: 'V', + Key: gui.getKey("main.toggleDragSelect-alt"), Modifier: gocui.ModNone, Handler: gui.handleToggleSelectRange, Description: gui.Tr.SLocalize("ToggleDragSelect"), @@ -916,7 +997,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"patch-building", "staging"}, - Key: 'a', + Key: gui.getKey("main.toggleSelectHunk"), Modifier: gocui.ModNone, Handler: gui.handleToggleSelectHunk, Description: gui.Tr.SLocalize("ToggleSelectHunk"), @@ -952,7 +1033,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"merging"}, - Key: gocui.KeyEsc, + Key: gui.getKey("universal.return"), Modifier: gocui.ModNone, Handler: gui.handleEscapeMerge, Description: gui.Tr.SLocalize("ReturnToFilesPanel"), @@ -960,7 +1041,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"merging"}, - Key: gocui.KeySpace, + Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, Handler: gui.handlePickHunk, Description: gui.Tr.SLocalize("PickHunk"), @@ -968,7 +1049,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"merging"}, - Key: 'b', + Key: gui.getKey("main.PickBothHunks"), Modifier: gocui.ModNone, Handler: gui.handlePickBothHunks, Description: gui.Tr.SLocalize("PickBothHunks"), @@ -976,7 +1057,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"merging"}, - Key: gocui.KeyArrowLeft, + Key: gui.getKey("universal.prevBlock"), Modifier: gocui.ModNone, Handler: gui.handleSelectPrevConflict, Description: gui.Tr.SLocalize("PrevConflict"), @@ -984,7 +1065,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"merging"}, - Key: gocui.KeyArrowRight, + Key: gui.getKey("universal.nextBlock"), Modifier: gocui.ModNone, Handler: gui.handleSelectNextConflict, Description: gui.Tr.SLocalize("NextConflict"), @@ -992,7 +1073,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"merging"}, - Key: gocui.KeyArrowUp, + Key: gui.getKey("universal.prevItem"), Modifier: gocui.ModNone, Handler: gui.handleSelectTop, Description: gui.Tr.SLocalize("SelectTop"), @@ -1000,7 +1081,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"merging"}, - Key: gocui.KeyArrowDown, + Key: gui.getKey("universal.nextItem"), Modifier: gocui.ModNone, Handler: gui.handleSelectBottom, Description: gui.Tr.SLocalize("SelectBottom"), @@ -1022,35 +1103,35 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "main", Contexts: []string{"mergin"}, - Key: 'h', + Key: gui.getKey("universal.prevBlock-alt"), Modifier: gocui.ModNone, Handler: gui.handleSelectPrevConflict, }, { ViewName: "main", Contexts: []string{"mergin"}, - Key: 'l', + Key: gui.getKey("universal.nextBlock-alt"), Modifier: gocui.ModNone, Handler: gui.handleSelectNextConflict, }, { ViewName: "main", Contexts: []string{"mergin"}, - Key: 'k', + Key: gui.getKey("universal.prevItem-alt"), Modifier: gocui.ModNone, Handler: gui.handleSelectTop, }, { ViewName: "main", Contexts: []string{"mergin"}, - Key: 'j', + Key: gui.getKey("universal.nextItem-alt"), Modifier: gocui.ModNone, Handler: gui.handleSelectBottom, }, { ViewName: "main", Contexts: []string{"merging"}, - Key: 'z', + Key: gui.getKey("main.undo"), Modifier: gocui.ModNone, Handler: gui.handlePopFileSnapshot, Description: gui.Tr.SLocalize("Undo"), @@ -1065,7 +1146,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"remotes"}, - Key: 'n', + Key: gui.getKey("universal.new"), Modifier: gocui.ModNone, Handler: gui.handleAddRemote, Description: gui.Tr.SLocalize("addNewRemote"), @@ -1073,7 +1154,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"remotes"}, - Key: 'd', + Key: gui.getKey("universal.remove"), Modifier: gocui.ModNone, Handler: gui.handleRemoveRemote, Description: gui.Tr.SLocalize("removeRemote"), @@ -1081,7 +1162,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"remotes"}, - Key: 'e', + Key: gui.getKey("universal.edit"), Modifier: gocui.ModNone, Handler: gui.handleEditRemote, Description: gui.Tr.SLocalize("editRemote"), @@ -1089,7 +1170,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"remote-branches"}, - Key: gocui.KeySpace, + Key: gui.getKey("universal.select"), Modifier: gocui.ModNone, Handler: gui.handleCheckoutRemoteBranch, Description: gui.Tr.SLocalize("checkout"), @@ -1097,7 +1178,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"remote-branches"}, - Key: 'M', + Key: gui.getKey("branches.mergeIntoCurrentBranch"), Modifier: gocui.ModNone, Handler: gui.handleMergeRemoteBranch, Description: gui.Tr.SLocalize("mergeIntoCurrentBranch"), @@ -1105,7 +1186,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"remote-branches"}, - Key: 'd', + Key: gui.getKey("universal.remove"), Modifier: gocui.ModNone, Handler: gui.handleDeleteRemoteBranch, Description: gui.Tr.SLocalize("deleteBranch"), @@ -1113,7 +1194,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"remote-branches"}, - Key: 'r', + Key: gui.getKey("branches.rebaseBranch"), Modifier: gocui.ModNone, Handler: gui.handleRebaseOntoRemoteBranch, Description: gui.Tr.SLocalize("rebaseBranch"), @@ -1121,7 +1202,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { { ViewName: "branches", Contexts: []string{"remote-branches"}, - Key: 'u', + Key: gui.getKey("branches.setUpstream"), Modifier: gocui.ModNone, Handler: gui.handleSetBranchUpstream, Description: gui.Tr.SLocalize("setUpstream"), @@ -1148,11 +1229,11 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "stash", "menu"} { bindings = append(bindings, []*Binding{ - {ViewName: viewName, Key: gocui.KeyTab, Modifier: gocui.ModNone, Handler: gui.nextView}, - {ViewName: viewName, Key: gocui.KeyArrowLeft, Modifier: gocui.ModNone, Handler: gui.previousView}, - {ViewName: viewName, Key: gocui.KeyArrowRight, Modifier: gocui.ModNone, Handler: gui.nextView}, - {ViewName: viewName, Key: 'h', Modifier: gocui.ModNone, Handler: gui.previousView}, - {ViewName: viewName, Key: 'l', Modifier: gocui.ModNone, Handler: gui.nextView}, + {ViewName: viewName, Key: gui.getKey("universal.togglePanel"), Modifier: gocui.ModNone, Handler: gui.nextView}, + {ViewName: viewName, Key: gui.getKey("universal.prevBlock"), Modifier: gocui.ModNone, Handler: gui.previousView}, + {ViewName: viewName, Key: gui.getKey("universal.nextBlock"), Modifier: gocui.ModNone, Handler: gui.nextView}, + {ViewName: viewName, Key: gui.getKey("universal.prevBlock-alt"), Modifier: gocui.ModNone, Handler: gui.previousView}, + {ViewName: viewName, Key: gui.getKey("universal.nextBlock-alt"), Modifier: gocui.ModNone, Handler: gui.nextView}, }...) } @@ -1163,11 +1244,11 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { for _, listView := range gui.getListViews() { bindings = append(bindings, []*Binding{ - {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: 'k', Modifier: gocui.ModNone, Handler: listView.handlePrevLine}, - {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gocui.KeyArrowUp, Modifier: gocui.ModNone, Handler: listView.handlePrevLine}, + {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.prevItem-alt"), Modifier: gocui.ModNone, Handler: listView.handlePrevLine}, + {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.prevItem"), Modifier: gocui.ModNone, Handler: listView.handlePrevLine}, {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gocui.MouseWheelUp, Modifier: gocui.ModNone, Handler: listView.handlePrevLine}, - {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: 'j', Modifier: gocui.ModNone, Handler: listView.handleNextLine}, - {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gocui.KeyArrowDown, Modifier: gocui.ModNone, Handler: listView.handleNextLine}, + {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.nextItem-alt"), Modifier: gocui.ModNone, Handler: listView.handleNextLine}, + {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gui.getKey("universal.nextItem"), Modifier: gocui.ModNone, Handler: listView.handleNextLine}, {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gocui.MouseWheelDown, Modifier: gocui.ModNone, Handler: listView.handleNextLine}, {ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gocui.MouseLeft, Modifier: gocui.ModNone, Handler: listView.handleClick}, }...)