X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=cmd%2Fmicro%2Fbindings.go;h=b537a9e12e9241082c1005e2baf533b0c7e63d2e;hb=128dc9fea1587f19ab8fcb176c265c6e4f13c536;hp=07cd9dcc2537ab5c64008e1b503b38e13e2b6078;hpb=b45fcf5bd7018594d0d53ab2d3f541fed2fc6548;p=micro.git diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index 07cd9dcc..b537a9e1 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -5,7 +5,7 @@ import ( "os" "strings" - "github.com/yosuke-furukawa/json5/encoding/json5" + "github.com/zyedidia/json5/encoding/json5" "github.com/zyedidia/tcell" ) @@ -52,9 +52,13 @@ var bindingActions = map[string]func(*View, bool) bool{ "CutLine": (*View).CutLine, "DuplicateLine": (*View).DuplicateLine, "DeleteLine": (*View).DeleteLine, + "MoveLinesUp": (*View).MoveLinesUp, + "MoveLinesDown": (*View).MoveLinesDown, "IndentSelection": (*View).IndentSelection, "OutdentSelection": (*View).OutdentSelection, + "OutdentLine": (*View).OutdentLine, "Paste": (*View).Paste, + "PastePrimary": (*View).PastePrimary, "SelectAll": (*View).SelectAll, "OpenFile": (*View).OpenFile, "Start": (*View).Start, @@ -71,6 +75,7 @@ var bindingActions = map[string]func(*View, bool) bool{ "ClearStatus": (*View).ClearStatus, "ShellMode": (*View).ShellMode, "CommandMode": (*View).CommandMode, + "Escape": (*View).Escape, "Quit": (*View).Quit, "QuitAll": (*View).QuitAll, "AddTab": (*View).AddTab, @@ -78,6 +83,11 @@ var bindingActions = map[string]func(*View, bool) bool{ "NextTab": (*View).NextTab, "NextSplit": (*View).NextSplit, "PreviousSplit": (*View).PreviousSplit, + "Unsplit": (*View).Unsplit, + "VSplit": (*View).VSplitBinding, + "HSplit": (*View).HSplitBinding, + "ToggleMacro": (*View).ToggleMacro, + "PlayMacro": (*View).PlayMacro, // This was changed to InsertNewline but I don't want to break backwards compatibility "InsertEnter": (*View).InsertNewline, @@ -202,12 +212,11 @@ var bindingKeys = map[string]tcell.Key{ "CtrlRightSq": tcell.KeyCtrlRightSq, "CtrlCarat": tcell.KeyCtrlCarat, "CtrlUnderscore": tcell.KeyCtrlUnderscore, - "Backspace": tcell.KeyBackspace, "Tab": tcell.KeyTab, "Esc": tcell.KeyEsc, "Escape": tcell.KeyEscape, "Enter": tcell.KeyEnter, - "Backspace2": tcell.KeyBackspace2, + "Backspace": tcell.KeyBackspace2, // I renamed these keys to PageUp and PageDown but I don't want to break someone's keybindings "PgUp": tcell.KeyPgUp, @@ -264,7 +273,8 @@ modSearch: case strings.HasPrefix(k, "-"): // We optionally support dashes between modifiers k = k[1:] - case strings.HasPrefix(k, "Ctrl"): + case strings.HasPrefix(k, "Ctrl") && k != "CtrlH": + // CtrlH technically does not have a 'Ctrl' modifier because it is really backspace k = k[4:] modifiers |= tcell.ModCtrl case strings.HasPrefix(k, "Alt"): @@ -330,6 +340,7 @@ func findAction(v string) (action func(*View, bool) bool) { func BindKey(k, v string) { key, ok := findKey(k) if !ok { + TermMessage("Unknown keybinding: " + k) return } if v == "ToggleHelp" { @@ -358,6 +369,8 @@ func DefaultBindings() map[string]string { "ShiftRight": "SelectRight", "AltLeft": "WordLeft", "AltRight": "WordRight", + "AltUp": "MoveLinesUp", + "AltDown": "MoveLinesDown", "AltShiftRight": "SelectWordRight", "AltShiftLeft": "SelectWordLeft", "CtrlLeft": "StartOfLine", @@ -369,13 +382,12 @@ func DefaultBindings() map[string]string { "CtrlShiftUp": "SelectToStart", "CtrlShiftDown": "SelectToEnd", "Enter": "InsertNewline", - "Space": "InsertSpace", + "CtrlH": "Backspace", "Backspace": "Backspace", - "Backspace2": "Backspace", + "Alt-CtrlH": "DeleteWordLeft", "Alt-Backspace": "DeleteWordLeft", - "Alt-Backspace2": "DeleteWordLeft", "Tab": "IndentSelection,InsertTab", - "Backtab": "OutdentSelection", + "Backtab": "OutdentSelection,OutdentLine", "CtrlO": "OpenFile", "CtrlS": "Save", "CtrlF": "Find", @@ -394,17 +406,20 @@ func DefaultBindings() map[string]string { "CtrlBackslash": "NextTab", "Home": "StartOfLine", "End": "EndOfLine", + "CtrlHome": "CursorStart", + "CtrlEnd": "CursorEnd", "PageUp": "CursorPageUp", "PageDown": "CursorPageDown", "CtrlG": "ToggleHelp", "CtrlR": "ToggleRuler", "CtrlL": "JumpLine", "Delete": "Delete", - "Esc": "ClearStatus", "CtrlB": "ShellMode", "CtrlQ": "Quit", "CtrlE": "CommandMode", "CtrlW": "NextSplit", + "CtrlU": "ToggleMacro", + "CtrlJ": "PlayMacro", // Emacs-style keybindings "Alt-f": "WordRight", @@ -413,5 +428,13 @@ func DefaultBindings() map[string]string { "Alt-e": "EndOfLine", "Alt-p": "CursorUp", "Alt-n": "CursorDown", + + // Integration with file managers + "F1": "ToggleHelp", + "F2": "Save", + "F4": "Quit", + "F7": "Find", + "F10": "Quit", + "Esc": "Escape", } }