]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/action/bindings.go
Gutter message support
[micro.git] / cmd / micro / action / bindings.go
index b1e2685b212f0488e113def2662f7bcc0dd06bd1..105f8ca2df0799707580a9897042ce210f48509c 100644 (file)
@@ -14,9 +14,9 @@ import (
        "github.com/zyedidia/tcell"
 )
 
-var Bindings = DefaultBindings()
-
 func InitBindings() {
+       config.Bindings = DefaultBindings()
+
        var parsed map[string]string
        defaults := DefaultBindings()
 
@@ -57,7 +57,7 @@ func BindKey(k, v string) {
                util.TermMessage("Raw events not supported yet")
        }
 
-       Bindings[k] = v
+       config.Bindings[k] = v
 }
 
 // findKeyEvent will find binding Key 'b' using string 'k'
@@ -103,7 +103,8 @@ modSearch:
                k = string(unicode.ToUpper(rune(k[0]))) + k[1:]
                if code, ok := keyEvents["Ctrl"+k]; ok {
                        var r tcell.Key
-                       if code < 256 {
+                       // Special case for escape, for some reason tcell doesn't send it with the esc character
+                       if code < 256 && code != 27 {
                                r = code
                        }
                        // It is, we're done.
@@ -118,7 +119,8 @@ modSearch:
        // See if we can find the key in bindingKeys
        if code, ok := keyEvents[k]; ok {
                var r tcell.Key
-               if code < 256 {
+               // Special case for escape, for some reason tcell doesn't send it with the esc character
+               if code < 256 && code != 27 {
                        r = code
                }
                return KeyEvent{
@@ -376,8 +378,8 @@ func DefaultBindings() map[string]string {
                "Backspace":      "Backspace",
                "Alt-CtrlH":      "DeleteWordLeft",
                "Alt-Backspace":  "DeleteWordLeft",
-               "Tab":            "IndentSelection,InsertTab",
-               "Backtab":        "OutdentSelection,OutdentLine",
+               "Tab":            "InsertTab",
+               "Backtab":        "OutdentLine",
                "CtrlO":          "OpenFile",
                "CtrlS":          "Save",
                "CtrlF":          "Find",