diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-02-05 14:42:56 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-17 19:13:40 +1100 |
commit | 482bdc4f1ea5448c5e98697ae66221e544ea40dd (patch) | |
tree | 7df478f9870e3dddc85f77d7b77439bed16e3c7b /pkg/gui/context/base_context.go | |
parent | 8e3484d8e98faf12f8395eaf5f9e8381f77a8e52 (diff) |
more refactoring
Diffstat (limited to 'pkg/gui/context/base_context.go')
-rw-r--r-- | pkg/gui/context/base_context.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/pkg/gui/context/base_context.go b/pkg/gui/context/base_context.go index c61f57cf4..5dbc3cbf4 100644 --- a/pkg/gui/context/base_context.go +++ b/pkg/gui/context/base_context.go @@ -1,6 +1,7 @@ package context import ( + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" ) @@ -11,8 +12,8 @@ type BaseContext struct { windowName string onGetOptionsMap func() map[string]string - keybindingsFns []types.KeybindingsFn - keybindings []*types.Binding + keybindingsFns []types.KeybindingsFn + mouseKeybindingsFns []types.MouseKeybindingsFn *ParentContextMgr } @@ -80,3 +81,18 @@ func (self *BaseContext) GetKeybindings(opts types.KeybindingsOpts) []*types.Bin func (self *BaseContext) AddKeybindingsFn(fn types.KeybindingsFn) { self.keybindingsFns = append(self.keybindingsFns, fn) } + +func (self *BaseContext) AddMouseKeybindingsFn(fn types.MouseKeybindingsFn) { + self.mouseKeybindingsFns = append(self.mouseKeybindingsFns, fn) +} + +func (self *BaseContext) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding { + bindings := []*gocui.ViewMouseBinding{} + for i := range self.mouseKeybindingsFns { + // the first binding in the bindings array takes precedence but we want the + // last keybindingsFn to take precedence to we add them in reverse + bindings = append(bindings, self.mouseKeybindingsFns[len(self.mouseKeybindingsFns)-1-i](opts)...) + } + + return bindings +} |