From 226985bf7602763f7578ef236bdc4cec3a1494e9 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 5 Feb 2022 10:31:07 +1100 Subject: refactor keybindings --- pkg/gui/types/context.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'pkg/gui/types/context.go') diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go index fcbadfd22..e4a11779e 100644 --- a/pkg/gui/types/context.go +++ b/pkg/gui/types/context.go @@ -28,6 +28,9 @@ type IBaseContext interface { GetKey() ContextKey GetOptionsMap() map[string]string + + GetKeybindings(opts KeybindingsOpts) []*Binding + AddKeybindingsFn(KeybindingsFn) } type Context interface { @@ -46,12 +49,16 @@ type OnFocusOpts struct { type ContextKey string +type KeybindingsOpts struct { + GetKey func(key string) interface{} + Config config.KeybindingConfig + Guards KeybindingGuards +} + +type KeybindingsFn func(opts KeybindingsOpts) []*Binding + type HasKeybindings interface { - Keybindings( - getKey func(key string) interface{}, - config config.KeybindingConfig, - guards KeybindingGuards, - ) []*Binding + GetKeybindings(opts KeybindingsOpts) []*Binding } type IController interface { -- cgit v1.2.3