]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/bindings.go
Move cursor with search selection
[micro.git] / cmd / micro / bindings.go
index 1053a9626c5665ad84ab1c03e5b8766480c40fec..93bd6f21cd39c20231838ef2643cc1afb6ba6514 100644 (file)
@@ -9,10 +9,10 @@ import (
        "github.com/zyedidia/tcell"
 )
 
-var bindings map[Key][]func(*View) bool
+var bindings map[Key][]func(*View, bool) bool
 var helpBinding string
 
-var bindingActions = map[string]func(*View) bool{
+var bindingActions = map[string]func(*View, bool) bool{
        "CursorUp":            (*View).CursorUp,
        "CursorDown":          (*View).CursorDown,
        "CursorPageUp":        (*View).CursorPageUp,
@@ -35,7 +35,7 @@ var bindingActions = map[string]func(*View) bool{
        "DeleteWordLeft":      (*View).DeleteWordLeft,
        "SelectToStartOfLine": (*View).SelectToStartOfLine,
        "SelectToEndOfLine":   (*View).SelectToEndOfLine,
-       "InsertEnter":         (*View).InsertEnter,
+       "InsertNewline":       (*View).InsertNewline,
        "InsertSpace":         (*View).InsertSpace,
        "Backspace":           (*View).Backspace,
        "Delete":              (*View).Delete,
@@ -76,6 +76,9 @@ var bindingActions = map[string]func(*View) bool{
        "NextTab":             (*View).NextTab,
        "NextSplit":           (*View).NextSplit,
        "PreviousSplit":       (*View).PreviousSplit,
+
+       // This was changed to InsertNewline but I don't want to break backwards compatibility
+       "InsertEnter": (*View).InsertNewline,
 }
 
 var bindingKeys = map[string]tcell.Key{
@@ -218,7 +221,7 @@ type Key struct {
 
 // InitBindings initializes the keybindings for micro
 func InitBindings() {
-       bindings = make(map[Key][]func(*View) bool)
+       bindings = make(map[Key][]func(*View, bool) bool)
 
        var parsed map[string]string
        defaults := DefaultBindings()
@@ -311,7 +314,7 @@ modSearch:
 }
 
 // findAction will find 'action' using string 'v'
-func findAction(v string) (action func(*View) bool) {
+func findAction(v string) (action func(*View, bool) bool) {
        action, ok := bindingActions[v]
        if !ok {
                // If the user seems to be binding a function that doesn't exist
@@ -332,7 +335,7 @@ func BindKey(k, v string) {
        }
 
        actionNames := strings.Split(v, ",")
-       actions := make([]func(*View) bool, 0, len(actionNames))
+       actions := make([]func(*View, bool) bool, 0, len(actionNames))
        for _, actionName := range actionNames {
                actions = append(actions, findAction(actionName))
        }
@@ -363,7 +366,7 @@ func DefaultBindings() map[string]string {
                "CtrlDown":       "CursorEnd",
                "CtrlShiftUp":    "SelectToStart",
                "CtrlShiftDown":  "SelectToEnd",
-               "Enter":          "InsertEnter",
+               "Enter":          "InsertNewline",
                "Space":          "InsertSpace",
                "Backspace":      "Backspace",
                "Backspace2":     "Backspace",
@@ -387,8 +390,8 @@ func DefaultBindings() map[string]string {
                "CtrlT":          "AddTab",
                "CtrlRightSq":    "PreviousTab",
                "CtrlBackslash":  "NextTab",
-               "Home":           "Start",
-               "End":            "End",
+               "Home":           "StartOfLine",
+               "End":            "EndOfLine",
                "PageUp":         "CursorPageUp",
                "PageDown":       "CursorPageDown",
                "CtrlG":          "ToggleHelp",