1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-26 05:37:18 +02:00

statically define context keys

This commit is contained in:
Jesse Duffield 2020-08-20 19:42:58 +10:00
parent 433d54fcec
commit a59ac064d2
4 changed files with 123 additions and 123 deletions

View File

@ -156,7 +156,7 @@ func (gui *Gui) contextTree() ContextTree {
OnFocus: gui.handleStatusSelect,
Kind: SIDE_CONTEXT,
ViewName: "status",
Key: "status",
Key: STATUS_CONTEXT_KEY,
},
},
Files: SimpleContextNode{

View File

@ -42,27 +42,27 @@ func (gui *Gui) renderDiff() error {
// flicking through branches it will be using the local branch name.
func (gui *Gui) currentDiffTerminals() []string {
switch gui.currentContextKey() {
case "files":
case FILES_CONTEXT_KEY:
// not supporting files for now
case "commitFiles":
case COMMIT_FILES_CONTEXT_KEY:
// not supporting commit files for now
case "branchCommits":
case BRANCH_COMMITS_CONTEXT_KEY:
item := gui.getSelectedCommit()
if item != nil {
return []string{item.RefName()}
}
case "reflogCommits":
case REFLOG_COMMITS_CONTEXT_KEY:
item := gui.getSelectedReflogCommit()
if item != nil {
return []string{item.RefName()}
}
case "stash":
case STASH_CONTEXT_KEY:
item := gui.getSelectedStashEntry()
if item != nil {
return []string{item.RefName()}
}
case "localBranches":
case LOCAL_BRANCHES_CONTEXT_KEY:
branch := gui.getSelectedBranch()
if branch != nil {
names := []string{branch.RefName()}
@ -72,17 +72,17 @@ func (gui *Gui) currentDiffTerminals() []string {
return names
}
return nil
case "remotes":
case REMOTES_CONTEXT_KEY:
item := gui.getSelectedRemote()
if item != nil {
return []string{item.RefName()}
}
case "remoteBranches":
case REMOTE_BRANCHES_CONTEXT_KEY:
item := gui.getSelectedRemoteBranch()
if item != nil {
return []string{item.RefName()}
}
case "tags":
case TAGS_CONTEXT_KEY:
item := gui.getSelectedTag()
if item != nil {
return []string{item.RefName()}

View File

@ -466,126 +466,126 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("universal.select"),
Handler: gui.handleBranchPress,
Description: gui.Tr.SLocalize("checkout"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("branches.createPullRequest"),
Handler: gui.handleCreatePullRequestPress,
Description: gui.Tr.SLocalize("createPullRequest"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("branches.checkoutBranchByName"),
Handler: gui.handleCheckoutByName,
Description: gui.Tr.SLocalize("checkoutByName"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("branches.forceCheckoutBranch"),
Handler: gui.handleForceCheckout,
Description: gui.Tr.SLocalize("forceCheckout"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("universal.new"),
Handler: gui.handleNewBranch,
Description: gui.Tr.SLocalize("newBranch"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("universal.remove"),
Handler: gui.handleDeleteBranch,
Description: gui.Tr.SLocalize("deleteBranch"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("branches.rebaseBranch"),
Handler: gui.handleRebaseOntoLocalBranch,
Description: gui.Tr.SLocalize("rebaseBranch"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("branches.mergeIntoCurrentBranch"),
Handler: gui.handleMerge,
Description: gui.Tr.SLocalize("mergeIntoCurrentBranch"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("branches.viewGitFlowOptions"),
Handler: gui.handleCreateGitFlowMenu,
Description: gui.Tr.SLocalize("gitFlowOptions"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("branches.FastForward"),
Handler: gui.handleFastForward,
Description: gui.Tr.SLocalize("FastForward"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("commits.viewResetOptions"),
Handler: gui.handleCreateResetToBranchMenu,
Description: gui.Tr.SLocalize("viewResetOptions"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("branches.renameBranch"),
Handler: gui.handleRenameBranch,
Description: gui.Tr.SLocalize("renameBranch"),
},
{
ViewName: "branches",
Contexts: []string{"localBranches"},
Contexts: []string{LOCAL_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("universal.copyToClipboard"),
Handler: gui.handleClipboardCopyBranch,
Description: gui.Tr.SLocalize("copyBranchNameToClipboard"),
},
{
ViewName: "branches",
Contexts: []string{"tags"},
Contexts: []string{TAGS_CONTEXT_KEY},
Key: gui.getKey("universal.select"),
Handler: gui.handleCheckoutTag,
Description: gui.Tr.SLocalize("checkout"),
},
{
ViewName: "branches",
Contexts: []string{"tags"},
Contexts: []string{TAGS_CONTEXT_KEY},
Key: gui.getKey("universal.remove"),
Handler: gui.handleDeleteTag,
Description: gui.Tr.SLocalize("deleteTag"),
},
{
ViewName: "branches",
Contexts: []string{"tags"},
Contexts: []string{TAGS_CONTEXT_KEY},
Key: gui.getKey("branches.pushTag"),
Handler: gui.handlePushTag,
Description: gui.Tr.SLocalize("pushTag"),
},
{
ViewName: "branches",
Contexts: []string{"tags"},
Contexts: []string{TAGS_CONTEXT_KEY},
Key: gui.getKey("universal.new"),
Handler: gui.handleCreateTag,
Description: gui.Tr.SLocalize("createTag"),
},
{
ViewName: "branches",
Contexts: []string{"tags"},
Contexts: []string{TAGS_CONTEXT_KEY},
Key: gui.getKey("commits.viewResetOptions"),
Handler: gui.handleCreateResetToTagMenu,
Description: gui.Tr.SLocalize("viewResetOptions"),
@ -604,21 +604,21 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
},
{
ViewName: "branches",
Contexts: []string{"remoteBranches"},
Contexts: []string{REMOTE_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("universal.return"),
Handler: gui.handleRemoteBranchesEscape,
Description: gui.Tr.SLocalize("ReturnToRemotesList"),
},
{
ViewName: "branches",
Contexts: []string{"remoteBranches"},
Contexts: []string{REMOTE_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("commits.viewResetOptions"),
Handler: gui.handleCreateResetToRemoteBranchMenu,
Description: gui.Tr.SLocalize("viewResetOptions"),
},
{
ViewName: "branches",
Contexts: []string{"remotes"},
Contexts: []string{REMOTES_CONTEXT_KEY},
Key: gui.getKey("branches.fetchRemote"),
Handler: gui.handleFetchRemote,
Description: gui.Tr.SLocalize("fetchRemote"),
@ -637,147 +637,147 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.squashDown"),
Handler: gui.handleCommitSquashDown,
Description: gui.Tr.SLocalize("squashDown"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.renameCommit"),
Handler: gui.handleRenameCommit,
Description: gui.Tr.SLocalize("renameCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.renameCommitWithEditor"),
Handler: gui.handleRenameCommitEditor,
Description: gui.Tr.SLocalize("renameCommitEditor"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.viewResetOptions"),
Handler: gui.handleCreateCommitResetMenu,
Description: gui.Tr.SLocalize("resetToThisCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.markCommitAsFixup"),
Handler: gui.handleCommitFixup,
Description: gui.Tr.SLocalize("fixupCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.createFixupCommit"),
Handler: gui.handleCreateFixupCommit,
Description: gui.Tr.SLocalize("createFixupCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.squashAboveCommits"),
Handler: gui.handleSquashAllAboveFixupCommits,
Description: gui.Tr.SLocalize("squashAboveCommits"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("universal.remove"),
Handler: gui.handleCommitDelete,
Description: gui.Tr.SLocalize("deleteCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.moveDownCommit"),
Handler: gui.handleCommitMoveDown,
Description: gui.Tr.SLocalize("moveDownCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.moveUpCommit"),
Handler: gui.handleCommitMoveUp,
Description: gui.Tr.SLocalize("moveUpCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("universal.edit"),
Handler: gui.handleCommitEdit,
Description: gui.Tr.SLocalize("editCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.amendToCommit"),
Handler: gui.handleCommitAmendTo,
Description: gui.Tr.SLocalize("amendToCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.pickCommit"),
Handler: gui.handleCommitPick,
Description: gui.Tr.SLocalize("pickCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.revertCommit"),
Handler: gui.handleCommitRevert,
Description: gui.Tr.SLocalize("revertCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.cherryPickCopy"),
Handler: gui.handleCopyCommit,
Description: gui.Tr.SLocalize("cherryPickCopy"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("universal.copyToClipboard"),
Handler: gui.handleClipboardCopyCommit,
Description: gui.Tr.SLocalize("copyCommitShaToClipboard"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.cherryPickCopyRange"),
Handler: gui.handleCopyCommitRange,
Description: gui.Tr.SLocalize("cherryPickCopyRange"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.pasteCommits"),
Handler: gui.HandlePasteCommits,
Description: gui.Tr.SLocalize("pasteCommits"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("universal.goInto"),
Handler: gui.wrappedHandler(gui.handleSwitchToCommitFilesPanel),
Description: gui.Tr.SLocalize("viewCommitFiles"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.checkoutCommit"),
Handler: gui.handleCheckoutCommit,
Description: gui.Tr.SLocalize("checkoutCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("universal.new"),
Modifier: gocui.ModNone,
Handler: gui.wrappedHandler(gui.handleNewBranchOffCommit),
@ -785,28 +785,28 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.tagCommit"),
Handler: gui.handleTagCommit,
Description: gui.Tr.SLocalize("tagCommit"),
},
{
ViewName: "commits",
Contexts: []string{"branchCommits"},
Contexts: []string{BRANCH_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.resetCherryPick"),
Handler: gui.handleResetCherryPick,
Description: gui.Tr.SLocalize("resetCherryPick"),
},
{
ViewName: "commits",
Contexts: []string{"reflogCommits"},
Contexts: []string{REFLOG_COMMITS_CONTEXT_KEY},
Key: gui.getKey("universal.select"),
Handler: gui.handleCheckoutReflogCommit,
Description: gui.Tr.SLocalize("checkoutCommit"),
},
{
ViewName: "commits",
Contexts: []string{"reflogCommits"},
Contexts: []string{REFLOG_COMMITS_CONTEXT_KEY},
Key: gui.getKey("commits.viewResetOptions"),
Handler: gui.handleCreateReflogResetMenu,
Description: gui.Tr.SLocalize("viewResetOptions"),
@ -933,14 +933,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
},
{
ViewName: "secondary",
Contexts: []string{"normal"},
Contexts: []string{MAIN_NORMAL_CONTEXT_KEY},
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleMouseDownSecondary,
},
{
ViewName: "main",
Contexts: []string{"normal"},
Contexts: []string{MAIN_NORMAL_CONTEXT_KEY},
Key: gocui.MouseWheelDown,
Handler: gui.scrollDownMain,
Description: gui.Tr.SLocalize("ScrollDown"),
@ -948,7 +948,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
},
{
ViewName: "main",
Contexts: []string{"normal"},
Contexts: []string{MAIN_NORMAL_CONTEXT_KEY},
Key: gocui.MouseWheelUp,
Handler: gui.scrollUpMain,
Description: gui.Tr.SLocalize("ScrollUp"),
@ -956,154 +956,154 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
},
{
ViewName: "main",
Contexts: []string{"normal"},
Contexts: []string{MAIN_NORMAL_CONTEXT_KEY},
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleMouseDownMain,
},
{
ViewName: "secondary",
Contexts: []string{"staging"},
Contexts: []string{MAIN_STAGING_CONTEXT_KEY},
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleTogglePanelClick,
},
{
ViewName: "main",
Contexts: []string{"staging"},
Contexts: []string{MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.return"),
Handler: gui.wrappedHandler(gui.handleStagingEscape),
Description: gui.Tr.SLocalize("ReturnToFilesPanel"),
},
{
ViewName: "main",
Contexts: []string{"staging"},
Contexts: []string{MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.select"),
Handler: gui.handleToggleStagedSelection,
Description: gui.Tr.SLocalize("StageSelection"),
},
{
ViewName: "main",
Contexts: []string{"staging"},
Contexts: []string{MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.remove"),
Handler: gui.handleResetSelection,
Description: gui.Tr.SLocalize("ResetSelection"),
},
{
ViewName: "main",
Contexts: []string{"staging"},
Contexts: []string{MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.togglePanel"),
Handler: gui.handleTogglePanel,
Description: gui.Tr.SLocalize("TogglePanel"),
},
{
ViewName: "main",
Contexts: []string{"patchBuilding"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY},
Key: gui.getKey("universal.return"),
Handler: gui.wrappedHandler(gui.handleEscapePatchBuildingPanel),
Description: gui.Tr.SLocalize("ExitLineByLineMode"),
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.openFile"),
Handler: gui.wrappedHandler(gui.handleOpenFileAtLine),
Description: gui.Tr.SLocalize("openFile"),
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.prevItem"),
Handler: gui.handleSelectPrevLine,
Description: gui.Tr.SLocalize("PrevLine"),
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.nextItem"),
Handler: gui.handleSelectNextLine,
Description: gui.Tr.SLocalize("NextLine"),
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.prevItem-alt"),
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevLine,
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.nextItem-alt"),
Modifier: gocui.ModNone,
Handler: gui.handleSelectNextLine,
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gocui.MouseWheelUp,
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevLine,
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gocui.MouseWheelDown,
Modifier: gocui.ModNone,
Handler: gui.handleSelectNextLine,
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.prevBlock"),
Handler: gui.handleSelectPrevHunk,
Description: gui.Tr.SLocalize("PrevHunk"),
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.nextBlock"),
Handler: gui.handleSelectNextHunk,
Description: gui.Tr.SLocalize("NextHunk"),
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.prevBlock-alt"),
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevHunk,
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.nextBlock-alt"),
Modifier: gocui.ModNone,
Handler: gui.handleSelectNextHunk,
},
{
ViewName: "main",
Contexts: []string{"staging"},
Contexts: []string{MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.edit"),
Handler: gui.handleFileEdit,
Description: gui.Tr.SLocalize("editFile"),
},
{
ViewName: "main",
Contexts: []string{"staging"},
Contexts: []string{MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("universal.openFile"),
Handler: gui.handleFileOpen,
Description: gui.Tr.SLocalize("openFile"),
},
{
ViewName: "main",
Contexts: []string{"patchBuilding"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY},
Key: gui.getKey("universal.select"),
Handler: gui.handleToggleSelectionForPatch,
Description: gui.Tr.SLocalize("ToggleSelectionForPatch"),
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("main.toggleDragSelect"),
Handler: gui.handleToggleSelectRange,
Description: gui.Tr.SLocalize("ToggleDragSelect"),
@ -1111,203 +1111,203 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
// Alias 'V' -> 'v'
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("main.toggleDragSelect-alt"),
Handler: gui.handleToggleSelectRange,
Description: gui.Tr.SLocalize("ToggleDragSelect"),
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("main.toggleSelectHunk"),
Handler: gui.handleToggleSelectHunk,
Description: gui.Tr.SLocalize("ToggleSelectHunk"),
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleMouseDown,
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gocui.MouseLeft,
Modifier: gocui.ModMotion,
Handler: gui.handleMouseDrag,
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gocui.MouseWheelUp,
Modifier: gocui.ModNone,
Handler: gui.handleMouseScrollUp,
},
{
ViewName: "main",
Contexts: []string{"patchBuilding", "staging"},
Contexts: []string{MAIN_PATCH_BUILDING_CONTEXT_KEY, MAIN_STAGING_CONTEXT_KEY},
Key: gocui.MouseWheelDown,
Modifier: gocui.ModNone,
Handler: gui.handleMouseScrollDown,
},
{
ViewName: "main",
Contexts: []string{"staging"},
Contexts: []string{MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("files.commitChanges"),
Handler: gui.wrappedHandler(gui.handleCommitPress),
Description: gui.Tr.SLocalize("CommitChanges"),
},
{
ViewName: "main",
Contexts: []string{"staging"},
Contexts: []string{MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("files.commitChangesWithoutHook"),
Handler: gui.handleWIPCommitPress,
Description: gui.Tr.SLocalize("commitChangesWithoutHook"),
},
{
ViewName: "main",
Contexts: []string{"staging"},
Contexts: []string{MAIN_STAGING_CONTEXT_KEY},
Key: gui.getKey("files.commitChangesWithEditor"),
Handler: gui.wrappedHandler(gui.handleCommitEditorPress),
Description: gui.Tr.SLocalize("CommitChangesWithEditor"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("universal.return"),
Handler: gui.wrappedHandler(gui.handleEscapeMerge),
Description: gui.Tr.SLocalize("ReturnToFilesPanel"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("universal.select"),
Handler: gui.handlePickHunk,
Description: gui.Tr.SLocalize("PickHunk"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("main.pickBothHunks"),
Handler: gui.handlePickBothHunks,
Description: gui.Tr.SLocalize("PickBothHunks"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("universal.prevBlock"),
Handler: gui.handleSelectPrevConflict,
Description: gui.Tr.SLocalize("PrevConflict"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("universal.nextBlock"),
Handler: gui.handleSelectNextConflict,
Description: gui.Tr.SLocalize("NextConflict"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("universal.prevItem"),
Handler: gui.handleSelectTop,
Description: gui.Tr.SLocalize("SelectTop"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("universal.nextItem"),
Handler: gui.handleSelectBottom,
Description: gui.Tr.SLocalize("SelectBottom"),
},
{
ViewName: "main",
Contexts: []string{"mergin"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gocui.MouseWheelUp,
Modifier: gocui.ModNone,
Handler: gui.handleSelectTop,
},
{
ViewName: "main",
Contexts: []string{"mergin"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gocui.MouseWheelDown,
Modifier: gocui.ModNone,
Handler: gui.handleSelectBottom,
},
{
ViewName: "main",
Contexts: []string{"mergin"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("universal.prevBlock-alt"),
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevConflict,
},
{
ViewName: "main",
Contexts: []string{"mergin"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("universal.nextBlock-alt"),
Modifier: gocui.ModNone,
Handler: gui.handleSelectNextConflict,
},
{
ViewName: "main",
Contexts: []string{"mergin"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("universal.prevItem-alt"),
Modifier: gocui.ModNone,
Handler: gui.handleSelectTop,
},
{
ViewName: "main",
Contexts: []string{"mergin"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("universal.nextItem-alt"),
Modifier: gocui.ModNone,
Handler: gui.handleSelectBottom,
},
{
ViewName: "main",
Contexts: []string{"merging"},
Contexts: []string{MAIN_MERGING_CONTEXT_KEY},
Key: gui.getKey("universal.undo"),
Handler: gui.handlePopFileSnapshot,
Description: gui.Tr.SLocalize("undo"),
},
{
ViewName: "branches",
Contexts: []string{"remotes"},
Contexts: []string{REMOTES_CONTEXT_KEY},
Key: gui.getKey("universal.goInto"),
Modifier: gocui.ModNone,
Handler: gui.wrappedHandler(gui.handleRemoteEnter),
},
{
ViewName: "branches",
Contexts: []string{"remotes"},
Contexts: []string{REMOTES_CONTEXT_KEY},
Key: gui.getKey("universal.new"),
Handler: gui.handleAddRemote,
Description: gui.Tr.SLocalize("addNewRemote"),
},
{
ViewName: "branches",
Contexts: []string{"remotes"},
Contexts: []string{REMOTES_CONTEXT_KEY},
Key: gui.getKey("universal.remove"),
Handler: gui.handleRemoveRemote,
Description: gui.Tr.SLocalize("removeRemote"),
},
{
ViewName: "branches",
Contexts: []string{"remotes"},
Contexts: []string{REMOTES_CONTEXT_KEY},
Key: gui.getKey("universal.edit"),
Handler: gui.handleEditRemote,
Description: gui.Tr.SLocalize("editRemote"),
},
{
ViewName: "branches",
Contexts: []string{"remoteBranches"},
Contexts: []string{REMOTE_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("universal.select"),
Handler: gui.handleCheckoutRemoteBranch,
Description: gui.Tr.SLocalize("checkout"),
},
{
ViewName: "branches",
Contexts: []string{"remoteBranches"},
Contexts: []string{REMOTE_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("universal.new"),
Handler: gui.handleNewBranchOffRemote,
Description: gui.Tr.SLocalize("newBranch"),
@ -1315,28 +1315,28 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
{
ViewName: "branches",
Contexts: []string{"remoteBranches"},
Contexts: []string{REMOTE_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("branches.mergeIntoCurrentBranch"),
Handler: gui.handleMergeRemoteBranch,
Description: gui.Tr.SLocalize("mergeIntoCurrentBranch"),
},
{
ViewName: "branches",
Contexts: []string{"remoteBranches"},
Contexts: []string{REMOTE_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("universal.remove"),
Handler: gui.handleDeleteRemoteBranch,
Description: gui.Tr.SLocalize("deleteBranch"),
},
{
ViewName: "branches",
Contexts: []string{"remoteBranches"},
Contexts: []string{REMOTE_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("branches.rebaseBranch"),
Handler: gui.handleRebaseOntoRemoteBranch,
Description: gui.Tr.SLocalize("rebaseBranch"),
},
{
ViewName: "branches",
Contexts: []string{"remoteBranches"},
Contexts: []string{REMOTE_BRANCHES_CONTEXT_KEY},
Key: gui.getKey("branches.setUpstream"),
Handler: gui.handleSetBranchUpstream,
Description: gui.Tr.SLocalize("setUpstream"),

View File

@ -231,7 +231,7 @@ func (gui *Gui) menuListContext() *ListContext {
func (gui *Gui) filesListContext() *ListContext {
return &ListContext{
ViewName: "files",
ContextKey: "files",
ContextKey: FILES_CONTEXT_KEY,
GetItemsLength: func() int { return len(gui.State.Files) },
GetPanelState: func() IListPanelState { return gui.State.Panels.Files },
OnFocus: gui.focusAndSelectFile,
@ -248,7 +248,7 @@ func (gui *Gui) filesListContext() *ListContext {
func (gui *Gui) branchesListContext() *ListContext {
return &ListContext{
ViewName: "branches",
ContextKey: "localBranches",
ContextKey: LOCAL_BRANCHES_CONTEXT_KEY,
GetItemsLength: func() int { return len(gui.State.Branches) },
GetPanelState: func() IListPanelState { return gui.State.Panels.Branches },
OnFocus: gui.handleBranchSelect,
@ -264,7 +264,7 @@ func (gui *Gui) branchesListContext() *ListContext {
func (gui *Gui) remotesListContext() *ListContext {
return &ListContext{
ViewName: "branches",
ContextKey: "remotes",
ContextKey: REMOTES_CONTEXT_KEY,
GetItemsLength: func() int { return len(gui.State.Remotes) },
GetPanelState: func() IListPanelState { return gui.State.Panels.Remotes },
OnFocus: gui.handleRemoteSelect,
@ -281,7 +281,7 @@ func (gui *Gui) remotesListContext() *ListContext {
func (gui *Gui) remoteBranchesListContext() *ListContext {
return &ListContext{
ViewName: "branches",
ContextKey: "remoteBranches",
ContextKey: REMOTE_BRANCHES_CONTEXT_KEY,
GetItemsLength: func() int { return len(gui.State.RemoteBranches) },
GetPanelState: func() IListPanelState { return gui.State.Panels.RemoteBranches },
OnFocus: gui.handleRemoteBranchSelect,
@ -297,7 +297,7 @@ func (gui *Gui) remoteBranchesListContext() *ListContext {
func (gui *Gui) tagsListContext() *ListContext {
return &ListContext{
ViewName: "branches",
ContextKey: "tags",
ContextKey: TAGS_CONTEXT_KEY,
GetItemsLength: func() int { return len(gui.State.Tags) },
GetPanelState: func() IListPanelState { return gui.State.Panels.Tags },
OnFocus: gui.handleTagSelect,
@ -313,7 +313,7 @@ func (gui *Gui) tagsListContext() *ListContext {
func (gui *Gui) branchCommitsListContext() *ListContext {
return &ListContext{
ViewName: "commits",
ContextKey: "branchCommits",
ContextKey: BRANCH_COMMITS_CONTEXT_KEY,
GetItemsLength: func() int { return len(gui.State.Commits) },
GetPanelState: func() IListPanelState { return gui.State.Panels.Commits },
OnFocus: gui.handleCommitSelect,
@ -330,7 +330,7 @@ func (gui *Gui) branchCommitsListContext() *ListContext {
func (gui *Gui) reflogCommitsListContext() *ListContext {
return &ListContext{
ViewName: "commits",
ContextKey: "reflogCommits",
ContextKey: REFLOG_COMMITS_CONTEXT_KEY,
GetItemsLength: func() int { return len(gui.State.FilteredReflogCommits) },
GetPanelState: func() IListPanelState { return gui.State.Panels.ReflogCommits },
OnFocus: gui.handleReflogCommitSelect,
@ -346,7 +346,7 @@ func (gui *Gui) reflogCommitsListContext() *ListContext {
func (gui *Gui) stashListContext() *ListContext {
return &ListContext{
ViewName: "stash",
ContextKey: "stash",
ContextKey: STASH_CONTEXT_KEY,
GetItemsLength: func() int { return len(gui.State.StashEntries) },
GetPanelState: func() IListPanelState { return gui.State.Panels.Stash },
OnFocus: gui.handleStashEntrySelect,
@ -362,7 +362,7 @@ func (gui *Gui) stashListContext() *ListContext {
func (gui *Gui) commitFilesListContext() *ListContext {
return &ListContext{
ViewName: "commitFiles",
ContextKey: "commitFiles",
ContextKey: COMMIT_FILES_CONTEXT_KEY,
GetItemsLength: func() int { return len(gui.State.CommitFiles) },
GetPanelState: func() IListPanelState { return gui.State.Panels.CommitFiles },
OnFocus: gui.handleCommitFileSelect,