aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-21 16:35:35 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-21 16:35:35 -0400
commit79b459ecb0da7759de617d164cb1cafc4a6be1c8 (patch)
tree23f85b74a9b4d8d3447550ac5c9b227504859abd
parent10dd23f05d271a27ad40a6fafffb5fe2c3e5fe57 (diff)
Add additional context to key binding set
-rw-r--r--config/bindings.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/config/bindings.go b/config/bindings.go
index 39b50ce..1882f74 100644
--- a/config/bindings.go
+++ b/config/bindings.go
@@ -20,7 +20,14 @@ type Binding struct {
Input []KeyStroke
}
-type KeyBindings []*Binding
+type KeyBindings struct {
+ bindings []*Binding
+
+ // If false, disable global keybindings in this context
+ Globals bool
+ // Which key opens the ex line (default is :)
+ ExKey KeyStroke
+}
const (
BINDING_FOUND = iota
@@ -31,12 +38,15 @@ const (
type BindingSearchResult int
func NewKeyBindings() *KeyBindings {
- return &KeyBindings{}
+ return &KeyBindings{
+ ExKey: KeyStroke{tcell.KeyRune, ':'},
+ Globals: true,
+ }
}
func (bindings *KeyBindings) Add(binding *Binding) {
// TODO: Search for conflicts?
- *bindings = append(*bindings, binding)
+ bindings.bindings = append(bindings.bindings, binding)
}
func (bindings *KeyBindings) GetBinding(
@@ -45,7 +55,7 @@ func (bindings *KeyBindings) GetBinding(
incomplete := false
// TODO: This could probably be a sorted list to speed things up
// TODO: Deal with bindings that share a prefix
- for _, binding := range *bindings {
+ for _, binding := range bindings.bindings {
if len(binding.Input) < len(input) {
continue
}