summaryrefslogtreecommitdiffstats
path: root/pkg/gui/keybindings.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-08-06 18:50:52 +1000
committerJesse Duffield <jessedduffield@gmail.com>2022-08-07 11:16:03 +1000
commit7410acd1aaa97f678295a328264360802346b33a (patch)
tree51dc6b5dfc8c0b67711ff644a6bc32480e6eaea8 /pkg/gui/keybindings.go
parent445a625b56a79be6cee7ec1ee35fe9f4fcc2daad (diff)
move merge conflicts code into controller
Diffstat (limited to 'pkg/gui/keybindings.go')
-rw-r--r--pkg/gui/keybindings.go130
1 files changed, 1 insertions, 129 deletions
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go
index 9d02d636e..8982a3056 100644
--- a/pkg/gui/keybindings.go
+++ b/pkg/gui/keybindings.go
@@ -2,37 +2,13 @@ package gui
import (
"log"
- "strings"
- "unicode/utf8"
"github.com/jesseduffield/gocui"
- "github.com/jesseduffield/lazygit/pkg/constants"
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
"github.com/jesseduffield/lazygit/pkg/gui/types"
)
-func (gui *Gui) getKeyDisplay(name string) string {
- key := gui.getKey(name)
- return keybindings.GetKeyDisplay(key)
-}
-
-func (gui *Gui) getKey(key string) types.Key {
- runeCount := utf8.RuneCountInString(key)
- if runeCount > 1 {
- binding := keybindings.Keymap[strings.ToLower(key)]
- if binding == nil {
- log.Fatalf("Unrecognized key %s for keybinding. For permitted values see %s", strings.ToLower(key), constants.Links.Docs.CustomKeybindings)
- } else {
- return binding
- }
- } else if runeCount == 1 {
- return []rune(key)[0]
- }
- log.Fatal("Key empty for keybinding: " + strings.ToLower(key))
- return nil
-}
-
func (gui *Gui) noPopupPanel(f func() error) func() error {
return func() error {
if gui.popupPanelFocused() {
@@ -68,7 +44,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
}
opts := types.KeybindingsOpts{
- GetKey: self.getKey,
+ GetKey: keybindings.GetKey,
Config: config,
Guards: guards,
}
@@ -326,110 +302,6 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
Handler: self.scrollUpSecondary,
},
{
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.ScrollLeft),
- Handler: self.scrollLeftMain,
- Description: self.c.Tr.LcScrollLeft,
- Tag: "navigation",
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.ScrollRight),
- Handler: self.scrollRightMain,
- Description: self.c.Tr.LcScrollRight,
- Tag: "navigation",
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.Return),
- Handler: self.handleEscapeMerge,
- Description: self.c.Tr.ReturnToFilesPanel,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Files.OpenMergeTool),
- Handler: self.helpers.WorkingTree.OpenMergeTool,
- Description: self.c.Tr.LcOpenMergeTool,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.Select),
- Handler: self.handlePickHunk,
- Description: self.c.Tr.PickHunk,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Main.PickBothHunks),
- Handler: self.handlePickAllHunks,
- Description: self.c.Tr.PickAllHunks,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.PrevBlock),
- Handler: self.handleSelectPrevConflict,
- Description: self.c.Tr.PrevConflict,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.NextBlock),
- Handler: self.handleSelectNextConflict,
- Description: self.c.Tr.NextConflict,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.PrevItem),
- Handler: self.handleSelectPrevConflictHunk,
- Description: self.c.Tr.SelectPrevHunk,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.NextItem),
- Handler: self.handleSelectNextConflictHunk,
- Description: self.c.Tr.SelectNextHunk,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.PrevBlockAlt),
- Modifier: gocui.ModNone,
- Handler: self.handleSelectPrevConflict,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.NextBlockAlt),
- Modifier: gocui.ModNone,
- Handler: self.handleSelectNextConflict,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.PrevItemAlt),
- Modifier: gocui.ModNone,
- Handler: self.handleSelectPrevConflictHunk,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.NextItemAlt),
- Modifier: gocui.ModNone,
- Handler: self.handleSelectNextConflictHunk,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.Edit),
- Handler: self.handleMergeConflictEditFileAtLine,
- Description: self.c.Tr.LcEditFile,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.OpenFile),
- Handler: self.handleMergeConflictOpenFileAtLine,
- Description: self.c.Tr.LcOpenFile,
- },
- {
- ViewName: "mergeConflicts",
- Key: opts.GetKey(opts.Config.Universal.Undo),
- Handler: self.handleMergeConflictUndo,
- Description: self.c.Tr.LcUndo,
- },
- {
ViewName: "status",
Key: gocui.MouseLeft,
Modifier: gocui.ModNone,