diff options
Diffstat (limited to 'config/bindings.go')
-rw-r--r-- | config/bindings.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/config/bindings.go b/config/bindings.go index eff48a61..62956d7b 100644 --- a/config/bindings.go +++ b/config/bindings.go @@ -55,6 +55,28 @@ func MergeBindings(bindings ...*KeyBindings) *KeyBindings { return merged } +func (config AercConfig) MergeContextualBinds(baseBinds *KeyBindings, + contextType ContextType, reg string, bindCtx string) *KeyBindings { + + bindings := baseBinds + for _, contextualBind := range config.ContextualBinds { + if contextualBind.ContextType != contextType { + continue + } + + if !contextualBind.Regex.Match([]byte(reg)) { + continue + } + + if contextualBind.BindContext != bindCtx { + continue + } + + bindings = MergeBindings(contextualBind.Bindings, bindings) + } + return bindings +} + func (bindings *KeyBindings) Add(binding *Binding) { // TODO: Search for conflicts? bindings.bindings = append(bindings.bindings, binding) |