summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Burville <Sam.Burville@GlobalProcessing.com>2021-10-15 21:00:24 +0100
committerJesse Duffield <jessedduffield@gmail.com>2021-10-22 22:38:26 +1100
commit91e8765d9ca04aa88377f07d8abe665fb8fc66fe (patch)
tree35a9eb97cd0e50ecc23e3057c80072899100bb97
parent80a8e9b04d6fe5214136f92c644e5a412a94c59e (diff)
Add JumpToBlock keybinding
This should allow users to decide their own keybinding for jumping between blocks/panels. E.g. A user could choose 5-9 instead of 1-5.
-rw-r--r--docs/Config.md1
-rw-r--r--pkg/config/user_config.go120
-rw-r--r--pkg/gui/keybindings.go6
-rw-r--r--pkg/gui/view_helpers.go2
4 files changed, 68 insertions, 61 deletions
diff --git a/docs/Config.md b/docs/Config.md
index 8f61d1b62..b1cf78307 100644
--- a/docs/Config.md
+++ b/docs/Config.md
@@ -101,6 +101,7 @@ keybinding:
nextBlock: '<right>' # goto the next block / panel
prevBlock-alt: 'h' # goto the previous block / panel
nextBlock-alt: 'l' # goto the next block / panel
+ jumpToBlock: "1", "2", "3", "4", "5" # goto the Nth block / panel
nextMatch: 'n'
prevMatch: 'N'
optionMenu: 'x' # show help menu
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go
index 06c293d71..8e98eb592 100644
--- a/pkg/config/user_config.go
+++ b/pkg/config/user_config.go
@@ -106,65 +106,66 @@ type KeybindingConfig struct {
// damn looks like we have some inconsistencies here with -alt and -alt1
type KeybindingUniversalConfig struct {
- Quit string `yaml:"quit"`
- QuitAlt1 string `yaml:"quit-alt1"`
- Return string `yaml:"return"`
- QuitWithoutChangingDirectory string `yaml:"quitWithoutChangingDirectory"`
- TogglePanel string `yaml:"togglePanel"`
- PrevItem string `yaml:"prevItem"`
- NextItem string `yaml:"nextItem"`
- PrevItemAlt string `yaml:"prevItem-alt"`
- NextItemAlt string `yaml:"nextItem-alt"`
- PrevPage string `yaml:"prevPage"`
- NextPage string `yaml:"nextPage"`
- GotoTop string `yaml:"gotoTop"`
- GotoBottom string `yaml:"gotoBottom"`
- PrevBlock string `yaml:"prevBlock"`
- NextBlock string `yaml:"nextBlock"`
- PrevBlockAlt string `yaml:"prevBlock-alt"`
- NextBlockAlt string `yaml:"nextBlock-alt"`
- NextBlockAlt2 string `yaml:"nextBlock-alt2"`
- PrevBlockAlt2 string `yaml:"prevBlock-alt2"`
- NextMatch string `yaml:"nextMatch"`
- PrevMatch string `yaml:"prevMatch"`
- StartSearch string `yaml:"startSearch"`
- OptionMenu string `yaml:"optionMenu"`
- OptionMenuAlt1 string `yaml:"optionMenu-alt1"`
- Select string `yaml:"select"`
- GoInto string `yaml:"goInto"`
- Confirm string `yaml:"confirm"`
- ConfirmAlt1 string `yaml:"confirm-alt1"`
- Remove string `yaml:"remove"`
- New string `yaml:"new"`
- Edit string `yaml:"edit"`
- OpenFile string `yaml:"openFile"`
- ScrollUpMain string `yaml:"scrollUpMain"`
- ScrollDownMain string `yaml:"scrollDownMain"`
- ScrollUpMainAlt1 string `yaml:"scrollUpMain-alt1"`
- ScrollDownMainAlt1 string `yaml:"scrollDownMain-alt1"`
- ScrollUpMainAlt2 string `yaml:"scrollUpMain-alt2"`
- ScrollDownMainAlt2 string `yaml:"scrollDownMain-alt2"`
- ExecuteCustomCommand string `yaml:"executeCustomCommand"`
- CreateRebaseOptionsMenu string `yaml:"createRebaseOptionsMenu"`
- PushFiles string `yaml:"pushFiles"`
- PullFiles string `yaml:"pullFiles"`
- Refresh string `yaml:"refresh"`
- CreatePatchOptionsMenu string `yaml:"createPatchOptionsMenu"`
- NextTab string `yaml:"nextTab"`
- PrevTab string `yaml:"prevTab"`
- NextScreenMode string `yaml:"nextScreenMode"`
- PrevScreenMode string `yaml:"prevScreenMode"`
- Undo string `yaml:"undo"`
- Redo string `yaml:"redo"`
- FilteringMenu string `yaml:"filteringMenu"`
- DiffingMenu string `yaml:"diffingMenu"`
- DiffingMenuAlt string `yaml:"diffingMenu-alt"`
- CopyToClipboard string `yaml:"copyToClipboard"`
- OpenRecentRepos string `yaml:"openRecentRepos"`
- SubmitEditorText string `yaml:"submitEditorText"`
- AppendNewline string `yaml:"appendNewline"`
- ExtrasMenu string `yaml:"extrasMenu"`
- ToggleWhitespaceInDiffView string `yaml:"toggleWhitespaceInDiffView"`
+ Quit string `yaml:"quit"`
+ QuitAlt1 string `yaml:"quit-alt1"`
+ Return string `yaml:"return"`
+ QuitWithoutChangingDirectory string `yaml:"quitWithoutChangingDirectory"`
+ TogglePanel string `yaml:"togglePanel"`
+ PrevItem string `yaml:"prevItem"`
+ NextItem string `yaml:"nextItem"`
+ PrevItemAlt string `yaml:"prevItem-alt"`
+ NextItemAlt string `yaml:"nextItem-alt"`
+ PrevPage string `yaml:"prevPage"`
+ NextPage string `yaml:"nextPage"`
+ GotoTop string `yaml:"gotoTop"`
+ GotoBottom string `yaml:"gotoBottom"`
+ PrevBlock string `yaml:"prevBlock"`
+ NextBlock string `yaml:"nextBlock"`
+ PrevBlockAlt string `yaml:"prevBlock-alt"`
+ NextBlockAlt string `yaml:"nextBlock-alt"`
+ NextBlockAlt2 string `yaml:"nextBlock-alt2"`
+ PrevBlockAlt2 string `yaml:"prevBlock-alt2"`
+ JumpToBlock [5]string `yaml:"JumpToBlock"`
+ NextMatch string `yaml:"nextMatch"`
+ PrevMatch string `yaml:"prevMatch"`
+ StartSearch string `yaml:"startSearch"`
+ OptionMenu string `yaml:"optionMenu"`
+ OptionMenuAlt1 string `yaml:"optionMenu-alt1"`
+ Select string `yaml:"select"`
+ GoInto string `yaml:"goInto"`
+ Confirm string `yaml:"confirm"`
+ ConfirmAlt1 string `yaml:"confirm-alt1"`
+ Remove string `yaml:"remove"`
+ New string `yaml:"new"`
+ Edit string `yaml:"edit"`
+ OpenFile string `yaml:"openFile"`
+ ScrollUpMain string `yaml:"scrollUpMain"`
+ ScrollDownMain string `yaml:"scrollDownMain"`
+ ScrollUpMainAlt1 string `yaml:"scrollUpMain-alt1"`
+ ScrollDownMainAlt1 string `yaml:"scrollDownMain-alt1"`
+ ScrollUpMainAlt2 string `yaml:"scrollUpMain-alt2"`
+ ScrollDownMainAlt2 string `yaml:"scrollDownMain-alt2"`
+ ExecuteCustomCommand string `yaml:"executeCustomCommand"`
+ CreateRebaseOptionsMenu string `yaml:"createRebaseOptionsMenu"`
+ PushFiles string `yaml:"pushFiles"`
+ PullFiles string `yaml:"pullFiles"`
+ Refresh string `yaml:"refresh"`
+ CreatePatchOptionsMenu string `yaml:"createPatchOptionsMenu"`
+ NextTab string `yaml:"nextTab"`
+ PrevTab string `yaml:"prevTab"`
+ NextScreenMode string `yaml:"nextScreenMode"`
+ PrevScreenMode string `yaml:"prevScreenMode"`
+ Undo string `yaml:"undo"`
+ Redo string `yaml:"redo"`
+ FilteringMenu string `yaml:"filteringMenu"`
+ DiffingMenu string `yaml:"diffingMenu"`
+ DiffingMenuAlt string `yaml:"diffingMenu-alt"`
+ CopyToClipboard string `yaml:"copyToClipboard"`
+ OpenRecentRepos string `yaml:"openRecentRepos"`
+ SubmitEditorText string `yaml:"submitEditorText"`
+ AppendNewline string `yaml:"appendNewline"`
+ ExtrasMenu string `yaml:"extrasMenu"`
+ ToggleWhitespaceInDiffView string `yaml:"toggleWhitespaceInDiffView"`
}
type KeybindingStatusConfig struct {
@@ -377,6 +378,7 @@ func GetDefaultConfig() *UserConfig {
NextBlockAlt: "l",
PrevBlockAlt2: "<backtab>",
NextBlockAlt2: "<tab>",
+ JumpToBlock: [5]string{"1", "2", "3", "4", "5"},
NextMatch: "n",
PrevMatch: "N",
StartSearch: "/",
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 844a1dc8a..1678ee03c 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -1819,7 +1819,11 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
// Appends keybindings to jump to a particular sideView using numbers
for i, window := range []string{"status", "files", "branches", "commits", "stash"} {
- bindings = append(bindings, &Binding{ViewName: "", Key: rune(i+1) + '0', Modifier: gocui.ModNone, Handler: gui.goToSideWindow(window)})
+ bindings = append(bindings, &Binding{
+ ViewName: "",
+ Key: gui.getKey(config.Universal.JumpToBlock[i]),
+ Modifier: gocui.ModNone,
+ Handler: gui.goToSideWindow(window)})
}
for viewName := range gui.State.Contexts.initialViewTabContextMap() {
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index abfb65d93..ce836c59b 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -322,7 +322,7 @@ func (gui *Gui) globalOptionsMap() map[string]string {
gui.getKeyDisplay(keybindingConfig.Universal.Return): gui.Tr.LcCancel,
gui.getKeyDisplay(keybindingConfig.Universal.Quit): gui.Tr.LcQuit,
gui.getKeyDisplay(keybindingConfig.Universal.OptionMenu): gui.Tr.LcMenu,
- "1-5": gui.Tr.LcJump,
+ fmt.Sprintf("%s-%s", gui.getKeyDisplay(keybindingConfig.Universal.JumpToBlock[0]), gui.getKeyDisplay(keybindingConfig.Universal.JumpToBlock[4])): gui.Tr.LcJump,
}
}