1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/gui/keybindings.go

1275 lines
37 KiB
Go
Raw Normal View History

package gui
2018-08-08 11:18:41 +02:00
import (
"github.com/jesseduffield/gocui"
2019-12-05 04:01:01 +02:00
"strings"
)
2018-08-08 11:18:41 +02:00
// Binding - a keybinding mapping a key and modifier to a handler. The keypress
// is only handled if the given view has focus, or handled globally if the view
// is ""
type Binding struct {
2018-08-29 11:56:28 +02:00
ViewName string
2019-11-16 03:41:04 +02:00
Contexts []string
2018-08-29 11:56:28 +02:00
Handler func(*gocui.Gui, *gocui.View) error
Key interface{} // FIXME: find out how to get `gocui.Key | rune`
Modifier gocui.Modifier
2018-08-28 20:13:01 +02:00
Description string
Alternative string
2018-08-08 11:18:41 +02:00
}
// GetDisplayStrings returns the display string of a file
func (b *Binding) GetDisplayStrings(isFocused bool) []string {
return []string{b.GetKey(), b.Description}
}
2018-11-30 02:47:14 +02:00
// GetKey is a function.
func (b *Binding) GetKey() string {
key := 0
switch b.Key.(type) {
case rune:
key = int(b.Key.(rune))
case gocui.Key:
if b.Key.(gocui.Key) == gocui.KeyCtrlJ {
return "ctrl+j"
}
if b.Key.(gocui.Key) == gocui.KeyCtrlK {
return "ctrl+k"
}
key = int(b.Key.(gocui.Key))
}
// special keys
switch key {
case 27:
return "esc"
case 13:
return "enter"
case 32:
return "space"
2019-03-02 06:11:53 +02:00
case 65514:
return "►"
case 65515:
return "◄"
case 65517:
return "▲"
case 65516:
return "▼"
case 65508:
return "PgUp"
case 65507:
return "PgDn"
case 9:
return "tab"
}
return string(key)
}
2019-12-05 04:01:01 +02:00
var keymap = map[string]interface{}{
"<c-a>": gocui.KeyCtrlA,
"<c-b>": gocui.KeyCtrlB,
"<c-c>": gocui.KeyCtrlC,
"<c-d>": gocui.KeyCtrlD,
"<c-e>": gocui.KeyCtrlE,
"<c-f>": gocui.KeyCtrlF,
"<c-g>": gocui.KeyCtrlG,
"<c-h>": gocui.KeyCtrlH,
"<c-i>": gocui.KeyCtrlI,
"<c-j>": gocui.KeyCtrlJ,
"<c-k>": gocui.KeyCtrlK,
"<c-l>": gocui.KeyCtrlL,
"<c-m>": gocui.KeyCtrlM,
"<c-n>": gocui.KeyCtrlN,
"<c-o>": gocui.KeyCtrlO,
"<c-p>": gocui.KeyCtrlP,
"<c-q>": gocui.KeyCtrlQ,
"<c-r>": gocui.KeyCtrlR,
"<c-s>": gocui.KeyCtrlS,
"<c-t>": gocui.KeyCtrlT,
"<c-u>": gocui.KeyCtrlU,
"<c-v>": gocui.KeyCtrlV,
"<c-w>": gocui.KeyCtrlW,
"<c-x>": gocui.KeyCtrlX,
"<c-y>": gocui.KeyCtrlY,
"<c-z>": gocui.KeyCtrlZ,
"<c-~>": gocui.KeyCtrlTilde,
"<c-2>": gocui.KeyCtrl2,
"<c-3>": gocui.KeyCtrl3,
"<c-4>": gocui.KeyCtrl4,
"<c-5>": gocui.KeyCtrl5,
"<c-6>": gocui.KeyCtrl6,
"<c-7>": gocui.KeyCtrl7,
"<c-8>": gocui.KeyCtrl8,
"<c-space>": gocui.KeyCtrlSpace,
"<c-\\>": gocui.KeyCtrlBackslash,
"<c-[>": gocui.KeyCtrlLsqBracket,
"<c-]>": gocui.KeyCtrlRsqBracket,
"<c-/>": gocui.KeyCtrlSlash,
"<c-_>": gocui.KeyCtrlUnderscore,
"<backspace>": gocui.KeyBackspace,
"<tab>": gocui.KeyTab,
"<enter>": gocui.KeyEnter,
"<esc>": gocui.KeyEsc,
"<space>": gocui.KeySpace,
"<f1>": gocui.KeyF1,
"<f2>": gocui.KeyF2,
"<f3>": gocui.KeyF3,
"<f4>": gocui.KeyF4,
"<f5>": gocui.KeyF5,
"<f6>": gocui.KeyF6,
"<f7>": gocui.KeyF7,
"<f8>": gocui.KeyF8,
"<f9>": gocui.KeyF9,
"<f10>": gocui.KeyF10,
"<f11>": gocui.KeyF11,
"<f12>": gocui.KeyF12,
"<insert>": gocui.KeyInsert,
"<delete>": gocui.KeyDelete,
"<home>": gocui.KeyHome,
"<end>": gocui.KeyEnd,
"<pgup>": gocui.KeyPgup,
"<pgdown>": gocui.KeyPgdn,
"<up>": gocui.KeyArrowUp,
"<down>": gocui.KeyArrowDown,
"<left>": gocui.KeyArrowLeft,
"<right>": 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{
2018-09-01 12:10:03 +02:00
{
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.quit"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleQuit,
2019-11-16 03:41:04 +02:00
},
{
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.quitWithoutChangingDirectory"),
Modifier: gocui.ModNone,
Handler: gui.handleQuitWithoutChangingDirectory,
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 12:10:03 +02:00
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.quit-alt1"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleQuit,
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 12:10:03 +02:00
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.return"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleQuit,
2019-11-16 03:41:04 +02:00
},
{
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.scrollUpMain"),
Modifier: gocui.ModNone,
Handler: gui.scrollUpMain,
Alternative: "fn+up",
2019-11-16 03:41:04 +02:00
},
{
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.scrollDownMain"),
Modifier: gocui.ModNone,
Handler: gui.scrollDownMain,
Alternative: "fn+down",
2019-11-16 03:41:04 +02:00
},
{
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.scrollUpMain-alt1"),
Modifier: gocui.ModNone,
Handler: gui.scrollUpMain,
2019-11-16 03:41:04 +02:00
},
{
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.scrollDownMain-alt1"),
Modifier: gocui.ModNone,
Handler: gui.scrollDownMain,
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 12:10:03 +02:00
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.scrollUpMain-alt2"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
Handler: gui.scrollUpMain,
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 12:10:03 +02:00
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.scrollDownMain-alt2"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
Handler: gui.scrollDownMain,
2019-11-16 03:41:04 +02:00
},
{
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.createRebaseOptionsMenu"),
Modifier: gocui.ModNone,
Handler: gui.handleCreateRebaseOptionsMenu,
Description: gui.Tr.SLocalize("ViewMergeRebaseOptions"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-05 13:23:06 +02:00
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.pushFiles"),
2018-09-05 13:23:06 +02:00
Modifier: gocui.ModNone,
Handler: gui.pushFiles,
2018-09-05 13:01:21 +02:00
Description: gui.Tr.SLocalize("push"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-05 13:23:06 +02:00
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.pullFiles"),
2018-09-05 13:23:06 +02:00
Modifier: gocui.ModNone,
Handler: gui.handlePullFiles,
2018-09-05 13:01:21 +02:00
Description: gui.Tr.SLocalize("pull"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-05 13:23:06 +02:00
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.refresh"),
2018-09-05 13:23:06 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleRefresh,
2018-09-05 13:01:21 +02:00
Description: gui.Tr.SLocalize("refresh"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 12:10:03 +02:00
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.optionMenu"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
2018-09-18 13:07:25 +02:00
Handler: gui.handleCreateOptionsMenu,
2019-11-16 03:41:04 +02:00
},
{
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.optionMenu-alt1"),
Modifier: gocui.ModNone,
Handler: gui.handleCreateOptionsMenu,
2019-11-16 03:41:04 +02:00
},
{
2019-11-10 07:20:35 +02:00
ViewName: "",
Key: gocui.MouseMiddle,
Modifier: gocui.ModNone,
Handler: gui.handleCreateOptionsMenu,
2019-11-16 03:41:04 +02:00
},
{
ViewName: "",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.createPatchOptionsMenu"),
Modifier: gocui.ModNone,
Handler: gui.handleCreatePatchOptionsMenu,
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 12:10:03 +02:00
ViewName: "status",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.edit"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleEditConfig,
Description: gui.Tr.SLocalize("EditConfig"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 12:10:03 +02:00
ViewName: "status",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.openFile"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleOpenConfig,
Description: gui.Tr.SLocalize("OpenConfig"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 12:10:03 +02:00
ViewName: "status",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("status.checkForUpdate"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCheckForUpdate,
Description: gui.Tr.SLocalize("checkForUpdate"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "status",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("status.recentRepos"),
Modifier: gocui.ModNone,
2018-09-19 11:15:29 +02:00
Handler: gui.handleCreateRecentReposMenu,
Description: gui.Tr.SLocalize("SwitchRepo"),
},
{
2018-09-01 12:10:03 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.commitChanges"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCommitPress,
Description: gui.Tr.SLocalize("CommitChanges"),
},
{
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.commitChangesWithoutHook"),
Modifier: gocui.ModNone,
Handler: gui.handleWIPCommitPress,
Description: gui.Tr.SLocalize("commitChangesWithoutHook"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-12 15:20:35 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.amendLastCommit"),
2018-09-12 15:20:35 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleAmendCommitPress,
Description: gui.Tr.SLocalize("AmendLastCommit"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 12:10:03 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.commitChangesWithEditor"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCommitEditorPress,
Description: gui.Tr.SLocalize("CommitChangesWithEditor"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-03 18:44:56 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.select"),
2018-09-03 18:44:56 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleFilePress,
Description: gui.Tr.SLocalize("toggleStaged"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:03:43 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.remove"),
2018-09-01 14:03:43 +02:00
Modifier: gocui.ModNone,
2019-03-18 11:44:33 +02:00
Handler: gui.handleCreateDiscardMenu,
Description: gui.Tr.SLocalize("viewDiscardOptions"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.edit"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleFileEdit,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("editFile"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.openFile"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleFileOpen,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("openFile"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.ignoreFile"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleIgnoreFile,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("ignoreFile"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.refreshFiles"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleRefreshFiles,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("refreshFiles"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.stashAllChanges"),
Modifier: gocui.ModNone,
Handler: gui.handleStashChanges,
Description: gui.Tr.SLocalize("stashAllChanges"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.viewStashOptions"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCreateStashMenu,
Description: gui.Tr.SLocalize("viewStashOptions"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.toggleStagedAll"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleStageAll,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("toggleStagedAll"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.viewResetOptions"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCreateResetMenu,
Description: gui.Tr.SLocalize("viewResetOptions"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "files",
2019-12-05 04:33:00 +02:00
Key: gocui.KeyEnter,
Modifier: gocui.ModNone,
Handler: gui.handleEnterFile,
Description: gui.Tr.SLocalize("StageLines"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.fetch"),
Modifier: gocui.ModNone,
Handler: gui.handleGitFetch,
Description: gui.Tr.SLocalize("fetch"),
2019-11-16 03:41:04 +02:00
},
{
2019-03-12 12:43:56 +02:00
ViewName: "files",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("files.executeCustomCommand"),
2019-03-12 12:43:56 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCustomCommand,
Description: gui.Tr.SLocalize("executeCustomCommand"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-03 18:44:56 +02:00
ViewName: "branches",
2019-11-16 05:00:27 +02:00
Contexts: []string{"local-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.select"),
2018-09-03 18:44:56 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleBranchPress,
Description: gui.Tr.SLocalize("checkout"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "branches",
2019-11-16 05:00:27 +02:00
Contexts: []string{"local-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.createPullRequest"),
Modifier: gocui.ModNone,
Handler: gui.handleCreatePullRequestPress,
Description: gui.Tr.SLocalize("createPullRequest"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "branches",
2019-11-16 05:00:27 +02:00
Contexts: []string{"local-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.checkoutBranchesByName"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCheckoutByName,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("checkoutByName"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "branches",
2019-11-16 05:00:27 +02:00
Contexts: []string{"local-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.forceCheckoutBranch"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleForceCheckout,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("forceCheckout"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "branches",
2019-11-16 05:00:27 +02:00
Contexts: []string{"local-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.new"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleNewBranch,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("newBranch"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "branches",
2019-11-16 05:00:27 +02:00
Contexts: []string{"local-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.remove"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleDeleteBranch,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("deleteBranch"),
2019-11-16 03:41:04 +02:00
},
{
2018-11-29 18:57:51 +02:00
ViewName: "branches",
2019-11-16 05:00:27 +02:00
Contexts: []string{"local-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.rebaseBranch"),
2018-11-29 18:57:51 +02:00
Modifier: gocui.ModNone,
2019-11-17 05:04:57 +02:00
Handler: gui.handleRebaseOntoLocalBranch,
2018-11-29 18:57:51 +02:00
Description: gui.Tr.SLocalize("rebaseBranch"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "branches",
2019-11-16 05:00:27 +02:00
Contexts: []string{"local-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.mergeIntoCurrentBranch"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleMerge,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("mergeIntoCurrentBranch"),
2019-11-16 03:41:04 +02:00
},
{
2018-12-07 09:52:31 +02:00
ViewName: "branches",
2019-11-16 05:00:27 +02:00
Contexts: []string{"local-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.FastForward"),
2018-12-07 09:52:31 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleFastForward,
Description: gui.Tr.SLocalize("FastForward"),
2019-11-16 03:41:04 +02:00
},
2019-11-18 00:38:36 +02:00
{
ViewName: "branches",
Contexts: []string{"tags"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.select"),
2019-11-18 00:38:36 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCheckoutTag,
Description: gui.Tr.SLocalize("checkout"),
},
{
ViewName: "branches",
Contexts: []string{"tags"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.remove"),
2019-11-18 00:38:36 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleDeleteTag,
Description: gui.Tr.SLocalize("deleteTag"),
},
{
ViewName: "branches",
Contexts: []string{"tags"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.pushTag"),
2019-11-18 00:38:36 +02:00
Modifier: gocui.ModNone,
Handler: gui.handlePushTag,
2019-11-21 13:09:02 +02:00
Description: gui.Tr.SLocalize("pushTag"),
2019-11-18 00:38:36 +02:00
},
{
ViewName: "branches",
Contexts: []string{"tags"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.new"),
2019-11-18 00:38:36 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCreateTag,
Description: gui.Tr.SLocalize("createTag"),
},
2019-11-16 07:20:05 +02:00
{
ViewName: "branches",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.nextBranchTab"),
2019-11-16 07:20:05 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleNextBranchesTab,
},
{
ViewName: "branches",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.prevBranchTab"),
2019-11-16 07:20:05 +02:00
Modifier: gocui.ModNone,
Handler: gui.handlePrevBranchesTab,
},
2019-11-16 08:35:59 +02:00
{
ViewName: "branches",
Contexts: []string{"remote-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.return"),
2019-11-16 08:35:59 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleRemoteBranchesEscape,
Description: gui.Tr.SLocalize("ReturnToRemotesList"),
},
2019-11-16 03:41:04 +02:00
{
2018-09-01 14:20:45 +02:00
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.squashDown"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCommitSquashDown,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("squashDown"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.renameCommit"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleRenameCommit,
Description: gui.Tr.SLocalize("renameCommit"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-03 18:01:07 +02:00
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.renameCommitWithEditor"),
2018-09-03 18:01:07 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleRenameCommitEditor,
Description: gui.Tr.SLocalize("renameCommitEditor"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.resetToThisCommit"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCreateCommitResetMenu,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("resetToThisCommit"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.fixupCommit"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCommitFixup,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("fixupCommit"),
2019-11-16 03:41:04 +02:00
},
{
2019-04-07 03:35:34 +02:00
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.createFixupCommit"),
2019-04-07 03:35:34 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCreateFixupCommit,
Description: gui.Tr.SLocalize("createFixupCommit"),
2019-11-16 03:41:04 +02:00
},
{
2019-04-07 03:35:34 +02:00
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.squashAboveCommits"),
2019-04-07 03:35:34 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSquashAllAboveFixupCommits,
Description: gui.Tr.SLocalize("squashAboveCommits"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.remove"),
Modifier: gocui.ModNone,
Handler: gui.handleCommitDelete,
Description: gui.Tr.SLocalize("deleteCommit"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.moveDownCommit"),
Modifier: gocui.ModNone,
Handler: gui.handleCommitMoveDown,
Description: gui.Tr.SLocalize("moveDownCommit"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.moveUpCommit"),
Modifier: gocui.ModNone,
Handler: gui.handleCommitMoveUp,
Description: gui.Tr.SLocalize("moveUpCommit"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.edit"),
Modifier: gocui.ModNone,
Handler: gui.handleCommitEdit,
Description: gui.Tr.SLocalize("editCommit"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.amendToCommit"),
Modifier: gocui.ModNone,
Handler: gui.handleCommitAmendTo,
Description: gui.Tr.SLocalize("amendToCommit"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.pickCommit"),
Modifier: gocui.ModNone,
Handler: gui.handleCommitPick,
Description: gui.Tr.SLocalize("pickCommit"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.revertCommit"),
Modifier: gocui.ModNone,
Handler: gui.handleCommitRevert,
Description: gui.Tr.SLocalize("revertCommit"),
2019-11-16 03:41:04 +02:00
},
{
2019-02-24 04:51:52 +02:00
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.cherryPickCopy"),
2019-02-24 04:51:52 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCopyCommit,
Description: gui.Tr.SLocalize("cherryPickCopy"),
2019-11-16 03:41:04 +02:00
},
{
2019-02-24 04:51:52 +02:00
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.cherryPickCopyRange"),
2019-02-24 04:51:52 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCopyCommitRange,
Description: gui.Tr.SLocalize("cherryPickCopyRange"),
2019-11-16 03:41:04 +02:00
},
{
2019-02-24 04:51:52 +02:00
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.pasteCommits"),
2019-02-24 04:51:52 +02:00
Modifier: gocui.ModNone,
Handler: gui.HandlePasteCommits,
Description: gui.Tr.SLocalize("pasteCommits"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.viewCommitFiles"),
Modifier: gocui.ModNone,
Handler: gui.handleSwitchToCommitFilesPanel,
2019-03-11 00:28:47 +02:00
Description: gui.Tr.SLocalize("viewCommitFiles"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.select"),
Modifier: gocui.ModNone,
Handler: gui.handleToggleDiffCommit,
Description: gui.Tr.SLocalize("CommitsDiff"),
2019-11-16 03:41:04 +02:00
},
2019-11-18 00:38:36 +02:00
{
ViewName: "commits",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commits.tagCommit"),
2019-11-18 00:38:36 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleTagCommit,
Description: gui.Tr.SLocalize("tagCommit"),
},
2019-11-16 03:41:04 +02:00
{
2018-09-01 14:20:45 +02:00
ViewName: "stash",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.select"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleStashApply,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("apply"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "stash",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("stash.popStash"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleStashPop,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("pop"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 14:20:45 +02:00
ViewName: "stash",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.remove"),
2018-09-01 14:20:45 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleStashDrop,
2018-09-01 14:03:43 +02:00
Description: gui.Tr.SLocalize("drop"),
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 12:10:03 +02:00
ViewName: "commitMessage",
Key: gocui.KeyEnter,
Modifier: gocui.ModNone,
Handler: gui.handleCommitConfirm,
2019-11-16 03:41:04 +02:00
},
{
2018-09-01 12:10:03 +02:00
ViewName: "commitMessage",
Key: gocui.KeyEsc,
Modifier: gocui.ModNone,
Handler: gui.handleCommitClose,
2019-11-16 03:41:04 +02:00
},
{
ViewName: "credentials",
2018-10-20 17:37:55 +02:00
Key: gocui.KeyEnter,
Modifier: gocui.ModNone,
Handler: gui.handleSubmitCredential,
2019-11-16 03:41:04 +02:00
},
{
ViewName: "credentials",
2018-10-20 17:37:55 +02:00
Key: gocui.KeyEsc,
Modifier: gocui.ModNone,
Handler: gui.handleCloseCredentialsView,
2019-11-16 03:41:04 +02:00
},
{
2018-09-05 11:12:11 +02:00
ViewName: "menu",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.return"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
2018-09-05 11:12:11 +02:00
Handler: gui.handleMenuClose,
2019-11-16 03:41:04 +02:00
},
{
2018-09-05 11:12:11 +02:00
ViewName: "menu",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.quit"),
2018-09-01 12:10:03 +02:00
Modifier: gocui.ModNone,
2018-09-05 11:12:11 +02:00
Handler: gui.handleMenuClose,
2019-11-16 03:41:04 +02:00
},
{
ViewName: "information",
2019-02-25 13:11:35 +02:00
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleDonate,
2019-11-16 03:41:04 +02:00
},
{
2019-03-11 00:28:47 +02:00
ViewName: "commitFiles",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.return"),
Modifier: gocui.ModNone,
Handler: gui.handleSwitchToCommitsPanel,
2019-03-11 00:28:47 +02:00
Description: gui.Tr.SLocalize("goBack"),
2019-11-16 03:41:04 +02:00
},
{
2019-03-11 00:53:46 +02:00
ViewName: "commitFiles",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("commitFiles.checkoutCommitFile"),
2019-03-11 00:53:46 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleCheckoutCommitFile,
Description: gui.Tr.SLocalize("checkoutCommitFile"),
2019-11-16 03:41:04 +02:00
},
{
ViewName: "commitFiles",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.remove"),
Modifier: gocui.ModNone,
Handler: gui.handleDiscardOldFileChange,
Description: gui.Tr.SLocalize("discardOldFileChange"),
2018-09-01 12:10:03 +02:00
},
{
ViewName: "commitFiles",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.openFile"),
Modifier: gocui.ModNone,
Handler: gui.handleOpenOldCommitFile,
Description: gui.Tr.SLocalize("openFile"),
},
{
ViewName: "commitFiles",
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.select"),
Modifier: gocui.ModNone,
Handler: gui.handleToggleFileForPatch,
Description: gui.Tr.SLocalize("toggleAddToPatch"),
},
{
ViewName: "commitFiles",
Key: gocui.KeyEnter,
Modifier: gocui.ModNone,
Handler: gui.handleEnterCommitFile,
Description: gui.Tr.SLocalize("enterFile"),
},
2019-11-10 07:50:36 +02:00
{
ViewName: "secondary",
Key: gocui.MouseWheelUp,
Modifier: gocui.ModNone,
Handler: gui.scrollUpSecondary,
},
{
ViewName: "secondary",
Key: gocui.MouseWheelDown,
Modifier: gocui.ModNone,
Handler: gui.scrollDownSecondary,
},
2019-11-16 03:41:04 +02:00
{
ViewName: "secondary",
Contexts: []string{"normal"},
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleMouseDownSecondary,
},
{
ViewName: "main",
Contexts: []string{"normal"},
Key: gocui.MouseWheelDown,
Modifier: gocui.ModNone,
Handler: gui.scrollDownMain,
Description: gui.Tr.SLocalize("ScrollDown"),
Alternative: "fn+up",
},
{
ViewName: "main",
Contexts: []string{"normal"},
Key: gocui.MouseWheelUp,
Modifier: gocui.ModNone,
Handler: gui.scrollUpMain,
Description: gui.Tr.SLocalize("ScrollUp"),
Alternative: "fn+down",
},
{
ViewName: "main",
Contexts: []string{"normal"},
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleMouseDownMain,
},
{
ViewName: "secondary",
Contexts: []string{"staging"},
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleTogglePanelClick,
},
{
ViewName: "main",
Contexts: []string{"staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.return"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleStagingEscape,
Description: gui.Tr.SLocalize("ReturnToFilesPanel"),
},
{
ViewName: "main",
Contexts: []string{"staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.select"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleStageSelection,
Description: gui.Tr.SLocalize("StageSelection"),
},
{
ViewName: "main",
Contexts: []string{"staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.remove"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleResetSelection,
Description: gui.Tr.SLocalize("ResetSelection"),
},
{
ViewName: "main",
Contexts: []string{"staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.togglePanel"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleTogglePanel,
Description: gui.Tr.SLocalize("TogglePanel"),
},
{
ViewName: "main",
Contexts: []string{"patch-building"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.return"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleEscapePatchBuildingPanel,
Description: gui.Tr.SLocalize("ExitLineByLineMode"),
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.prevItem"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevLine,
Description: gui.Tr.SLocalize("PrevLine"),
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.nextItem"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectNextLine,
Description: gui.Tr.SLocalize("NextLine"),
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.prevItem-alt"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevLine,
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.nextItem-alt"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectNextLine,
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
Key: gocui.MouseWheelUp,
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevLine,
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
Key: gocui.MouseWheelDown,
Modifier: gocui.ModNone,
Handler: gui.handleSelectNextLine,
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.prevBlock"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevHunk,
Description: gui.Tr.SLocalize("PrevHunk"),
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.nextBlock"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectNextHunk,
Description: gui.Tr.SLocalize("NextHunk"),
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.prevBlock-alt"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevHunk,
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.nextBlock-alt"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectNextHunk,
},
{
ViewName: "main",
Contexts: []string{"staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.edit"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleFileEdit,
Description: gui.Tr.SLocalize("editFile"),
},
{
ViewName: "main",
Contexts: []string{"staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.openFile"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleFileOpen,
Description: gui.Tr.SLocalize("openFile"),
},
{
ViewName: "main",
Contexts: []string{"patch-building"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.select"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleAddSelectionToPatch,
Description: gui.Tr.SLocalize("StageSelection"),
},
{
ViewName: "main",
Contexts: []string{"patch-building"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.remove"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleRemoveSelectionFromPatch,
Description: gui.Tr.SLocalize("ResetSelection"),
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("main.toggleDragSelect"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleToggleSelectRange,
Description: gui.Tr.SLocalize("ToggleDragSelect"),
},
2019-11-27 21:35:41 +02:00
// Alias 'V' -> 'v'
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("main.toggleDragSelect-alt"),
2019-11-27 21:35:41 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleToggleSelectRange,
Description: gui.Tr.SLocalize("ToggleDragSelect"),
},
2019-11-16 03:41:04 +02:00
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("main.toggleSelectHunk"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleToggleSelectHunk,
Description: gui.Tr.SLocalize("ToggleSelectHunk"),
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleMouseDown,
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
Key: gocui.MouseLeft,
Modifier: gocui.ModMotion,
Handler: gui.handleMouseDrag,
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
Key: gocui.MouseWheelUp,
Modifier: gocui.ModNone,
Handler: gui.handleMouseScrollUp,
},
{
ViewName: "main",
Contexts: []string{"patch-building", "staging"},
Key: gocui.MouseWheelDown,
Modifier: gocui.ModNone,
Handler: gui.handleMouseScrollDown,
},
{
ViewName: "main",
Contexts: []string{"merging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.return"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleEscapeMerge,
Description: gui.Tr.SLocalize("ReturnToFilesPanel"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.select"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handlePickHunk,
Description: gui.Tr.SLocalize("PickHunk"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("main.PickBothHunks"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handlePickBothHunks,
Description: gui.Tr.SLocalize("PickBothHunks"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.prevBlock"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevConflict,
Description: gui.Tr.SLocalize("PrevConflict"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.nextBlock"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectNextConflict,
Description: gui.Tr.SLocalize("NextConflict"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.prevItem"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectTop,
Description: gui.Tr.SLocalize("SelectTop"),
},
{
ViewName: "main",
Contexts: []string{"merging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.nextItem"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectBottom,
Description: gui.Tr.SLocalize("SelectBottom"),
},
{
ViewName: "main",
Contexts: []string{"mergin"},
Key: gocui.MouseWheelUp,
Modifier: gocui.ModNone,
Handler: gui.handleSelectTop,
},
{
ViewName: "main",
Contexts: []string{"mergin"},
Key: gocui.MouseWheelDown,
Modifier: gocui.ModNone,
Handler: gui.handleSelectBottom,
},
{
ViewName: "main",
Contexts: []string{"mergin"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.prevBlock-alt"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectPrevConflict,
},
{
ViewName: "main",
Contexts: []string{"mergin"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.nextBlock-alt"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectNextConflict,
},
{
ViewName: "main",
Contexts: []string{"mergin"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.prevItem-alt"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectTop,
},
{
ViewName: "main",
Contexts: []string{"mergin"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.nextItem-alt"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSelectBottom,
},
{
ViewName: "main",
Contexts: []string{"merging"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("main.undo"),
2019-11-16 03:41:04 +02:00
Modifier: gocui.ModNone,
Handler: gui.handlePopFileSnapshot,
Description: gui.Tr.SLocalize("Undo"),
},
2019-11-16 08:35:59 +02:00
{
ViewName: "branches",
Contexts: []string{"remotes"},
Key: gocui.KeyEnter,
Modifier: gocui.ModNone,
Handler: gui.handleRemoteEnter,
},
2019-11-17 03:02:39 +02:00
{
ViewName: "branches",
Contexts: []string{"remotes"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.new"),
2019-11-17 03:02:39 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleAddRemote,
Description: gui.Tr.SLocalize("addNewRemote"),
},
{
ViewName: "branches",
Contexts: []string{"remotes"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.remove"),
2019-11-17 03:02:39 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleRemoveRemote,
Description: gui.Tr.SLocalize("removeRemote"),
},
2019-11-17 09:15:32 +02:00
{
ViewName: "branches",
Contexts: []string{"remotes"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.edit"),
2019-11-17 09:15:32 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleEditRemote,
Description: gui.Tr.SLocalize("editRemote"),
},
{
ViewName: "branches",
Contexts: []string{"remote-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.select"),
Modifier: gocui.ModNone,
Handler: gui.handleCheckoutRemoteBranch,
Description: gui.Tr.SLocalize("checkout"),
},
{
ViewName: "branches",
Contexts: []string{"remote-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.mergeIntoCurrentBranch"),
Modifier: gocui.ModNone,
Handler: gui.handleMergeRemoteBranch,
Description: gui.Tr.SLocalize("mergeIntoCurrentBranch"),
},
2019-11-17 04:47:47 +02:00
{
ViewName: "branches",
Contexts: []string{"remote-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("universal.remove"),
2019-11-17 04:47:47 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleDeleteRemoteBranch,
Description: gui.Tr.SLocalize("deleteBranch"),
},
2019-11-17 05:04:57 +02:00
{
ViewName: "branches",
Contexts: []string{"remote-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.rebaseBranch"),
2019-11-17 05:04:57 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleRebaseOntoRemoteBranch,
Description: gui.Tr.SLocalize("rebaseBranch"),
},
2019-11-17 05:50:12 +02:00
{
ViewName: "branches",
Contexts: []string{"remote-branches"},
2019-12-05 04:01:01 +02:00
Key: gui.getKey("branches.setUpstream"),
2019-11-17 05:50:12 +02:00
Modifier: gocui.ModNone,
Handler: gui.handleSetBranchUpstream,
Description: gui.Tr.SLocalize("setUpstream"),
},
2019-11-16 05:00:27 +02:00
{
ViewName: "stash",
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleStashEntrySelect,
},
{
ViewName: "status",
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleStatusClick,
},
{
ViewName: "commitFiles",
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,
Handler: gui.handleCommitFilesClick,
},
2018-08-08 11:18:41 +02:00
}
for _, viewName := range []string{"status", "branches", "files", "commits", "commitFiles", "stash", "menu"} {
bindings = append(bindings, []*Binding{
2019-12-05 04:01:01 +02:00
{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},
}...)
}
// Appends keybindings to jump to a particular sideView using numbers
for i, viewName := range []string{"status", "files", "branches", "commits", "stash"} {
bindings = append(bindings, &Binding{ViewName: "", Key: rune(i+1) + '0', Modifier: gocui.ModNone, Handler: gui.goToSideView(viewName)})
}
2019-11-16 05:00:27 +02:00
for _, listView := range gui.getListViews() {
2018-12-07 09:52:31 +02:00
bindings = append(bindings, []*Binding{
2019-12-05 04:01:01 +02:00
{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},
2019-11-16 05:00:27 +02:00
{ViewName: listView.viewName, Contexts: []string{listView.context}, Key: gocui.MouseWheelUp, Modifier: gocui.ModNone, Handler: listView.handlePrevLine},
2019-12-05 04:01:01 +02:00
{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},
2019-11-16 05:00:27 +02:00
{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},
2018-12-07 09:52:31 +02:00
}...)
}
2018-08-28 20:07:13 +02:00
return bindings
}
func (gui *Gui) keybindings(g *gocui.Gui) error {
bindings := gui.GetInitialKeybindings()
2018-08-28 20:07:13 +02:00
2018-08-08 11:18:41 +02:00
for _, binding := range bindings {
2019-11-16 03:41:04 +02:00
if err := g.SetKeybinding(binding.ViewName, binding.Contexts, binding.Key, binding.Modifier, binding.Handler); err != nil {
2018-08-08 11:18:41 +02:00
return err
}
}
2019-11-13 14:18:31 +02:00
if err := g.SetTabClickBinding("branches", gui.onBranchesTabClick); err != nil {
return err
}
return nil
}