]> git.lizzy.rs Git - micro.git/blob - cmd/micro/bindings.go
f70e58230d81bf63836afff12fd8f3e517cef701
[micro.git] / cmd / micro / bindings.go
1 package main
2
3 import (
4         "fmt"
5         "io/ioutil"
6         "os"
7         "strings"
8         "unicode"
9
10         "github.com/flynn/json5"
11         "github.com/zyedidia/tcell"
12 )
13
14 var bindingsStr map[string]string
15 var bindings map[Key][]func(*View, bool) bool
16 var mouseBindings map[Key][]func(*View, bool, *tcell.EventMouse) bool
17 var helpBinding string
18 var kmenuBinding string
19
20 var mouseBindingActions = map[string]func(*View, bool, *tcell.EventMouse) bool{
21         "MousePress":       (*View).MousePress,
22         "MouseMultiCursor": (*View).MouseMultiCursor,
23 }
24
25 var bindingActions = map[string]func(*View, bool) bool{
26         "CursorUp":              (*View).CursorUp,
27         "CursorDown":            (*View).CursorDown,
28         "CursorPageUp":          (*View).CursorPageUp,
29         "CursorPageDown":        (*View).CursorPageDown,
30         "CursorLeft":            (*View).CursorLeft,
31         "CursorRight":           (*View).CursorRight,
32         "CursorStart":           (*View).CursorStart,
33         "CursorEnd":             (*View).CursorEnd,
34         "SelectToStart":         (*View).SelectToStart,
35         "SelectToEnd":           (*View).SelectToEnd,
36         "SelectUp":              (*View).SelectUp,
37         "SelectDown":            (*View).SelectDown,
38         "SelectLeft":            (*View).SelectLeft,
39         "SelectRight":           (*View).SelectRight,
40         "WordRight":             (*View).WordRight,
41         "WordLeft":              (*View).WordLeft,
42         "SelectWordRight":       (*View).SelectWordRight,
43         "SelectWordLeft":        (*View).SelectWordLeft,
44         "DeleteWordRight":       (*View).DeleteWordRight,
45         "DeleteWordLeft":        (*View).DeleteWordLeft,
46         "SelectLine":            (*View).SelectLine,
47         "SelectToStartOfLine":   (*View).SelectToStartOfLine,
48         "SelectToEndOfLine":     (*View).SelectToEndOfLine,
49         "ParagraphPrevious":     (*View).ParagraphPrevious,
50         "ParagraphNext":         (*View).ParagraphNext,
51         "InsertNewline":         (*View).InsertNewline,
52         "InsertSpace":           (*View).InsertSpace,
53         "Backspace":             (*View).Backspace,
54         "Delete":                (*View).Delete,
55         "InsertTab":             (*View).InsertTab,
56         "Save":                  (*View).Save,
57         "SaveAll":               (*View).SaveAll,
58         "SaveAs":                (*View).SaveAs,
59         "Find":                  (*View).Find,
60         "FindNext":              (*View).FindNext,
61         "FindPrevious":          (*View).FindPrevious,
62         "Center":                (*View).Center,
63         "Undo":                  (*View).Undo,
64         "Redo":                  (*View).Redo,
65         "Copy":                  (*View).Copy,
66         "Cut":                   (*View).Cut,
67         "CutLine":               (*View).CutLine,
68         "DuplicateLine":         (*View).DuplicateLine,
69         "DeleteLine":            (*View).DeleteLine,
70         "MoveLinesUp":           (*View).MoveLinesUp,
71         "MoveLinesDown":         (*View).MoveLinesDown,
72         "IndentSelection":       (*View).IndentSelection,
73         "OutdentSelection":      (*View).OutdentSelection,
74         "OutdentLine":           (*View).OutdentLine,
75         "Paste":                 (*View).Paste,
76         "PastePrimary":          (*View).PastePrimary,
77         "SelectAll":             (*View).SelectAll,
78         "OpenFile":              (*View).OpenFile,
79         "Start":                 (*View).Start,
80         "End":                   (*View).End,
81         "PageUp":                (*View).PageUp,
82         "PageDown":              (*View).PageDown,
83         "HalfPageUp":            (*View).HalfPageUp,
84         "HalfPageDown":          (*View).HalfPageDown,
85         "StartOfLine":           (*View).StartOfLine,
86         "EndOfLine":             (*View).EndOfLine,
87         "ToggleHelp":            (*View).ToggleHelp,
88         "ToggleKeyMenu":         (*View).ToggleKeyMenu,
89         "ToggleRuler":           (*View).ToggleRuler,
90         "JumpLine":              (*View).JumpLine,
91         "ClearStatus":           (*View).ClearStatus,
92         "ShellMode":             (*View).ShellMode,
93         "CommandMode":           (*View).CommandMode,
94         "ToggleOverwriteMode":   (*View).ToggleOverwriteMode,
95         "Escape":                (*View).Escape,
96         "Quit":                  (*View).Quit,
97         "QuitAll":               (*View).QuitAll,
98         "AddTab":                (*View).AddTab,
99         "PreviousTab":           (*View).PreviousTab,
100         "NextTab":               (*View).NextTab,
101         "NextSplit":             (*View).NextSplit,
102         "PreviousSplit":         (*View).PreviousSplit,
103         "Unsplit":               (*View).Unsplit,
104         "VSplit":                (*View).VSplitBinding,
105         "HSplit":                (*View).HSplitBinding,
106         "ToggleMacro":           (*View).ToggleMacro,
107         "PlayMacro":             (*View).PlayMacro,
108         "Suspend":               (*View).Suspend,
109         "ScrollUp":              (*View).ScrollUpAction,
110         "ScrollDown":            (*View).ScrollDownAction,
111         "SpawnMultiCursor":      (*View).SpawnMultiCursor,
112         "RemoveMultiCursor":     (*View).RemoveMultiCursor,
113         "RemoveAllMultiCursors": (*View).RemoveAllMultiCursors,
114         "SkipMultiCursor":       (*View).SkipMultiCursor,
115         "JumpToMatchingBrace":   (*View).JumpToMatchingBrace,
116
117         // This was changed to InsertNewline but I don't want to break backwards compatibility
118         "InsertEnter": (*View).InsertNewline,
119 }
120
121 var bindingMouse = map[string]tcell.ButtonMask{
122         "MouseLeft":       tcell.Button1,
123         "MouseMiddle":     tcell.Button2,
124         "MouseRight":      tcell.Button3,
125         "MouseWheelUp":    tcell.WheelUp,
126         "MouseWheelDown":  tcell.WheelDown,
127         "MouseWheelLeft":  tcell.WheelLeft,
128         "MouseWheelRight": tcell.WheelRight,
129 }
130
131 var bindingKeys = map[string]tcell.Key{
132         "Up":             tcell.KeyUp,
133         "Down":           tcell.KeyDown,
134         "Right":          tcell.KeyRight,
135         "Left":           tcell.KeyLeft,
136         "UpLeft":         tcell.KeyUpLeft,
137         "UpRight":        tcell.KeyUpRight,
138         "DownLeft":       tcell.KeyDownLeft,
139         "DownRight":      tcell.KeyDownRight,
140         "Center":         tcell.KeyCenter,
141         "PageUp":         tcell.KeyPgUp,
142         "PageDown":       tcell.KeyPgDn,
143         "Home":           tcell.KeyHome,
144         "End":            tcell.KeyEnd,
145         "Insert":         tcell.KeyInsert,
146         "Delete":         tcell.KeyDelete,
147         "Help":           tcell.KeyHelp,
148         "Exit":           tcell.KeyExit,
149         "Clear":          tcell.KeyClear,
150         "Cancel":         tcell.KeyCancel,
151         "Print":          tcell.KeyPrint,
152         "Pause":          tcell.KeyPause,
153         "Backtab":        tcell.KeyBacktab,
154         "F1":             tcell.KeyF1,
155         "F2":             tcell.KeyF2,
156         "F3":             tcell.KeyF3,
157         "F4":             tcell.KeyF4,
158         "F5":             tcell.KeyF5,
159         "F6":             tcell.KeyF6,
160         "F7":             tcell.KeyF7,
161         "F8":             tcell.KeyF8,
162         "F9":             tcell.KeyF9,
163         "F10":            tcell.KeyF10,
164         "F11":            tcell.KeyF11,
165         "F12":            tcell.KeyF12,
166         "F13":            tcell.KeyF13,
167         "F14":            tcell.KeyF14,
168         "F15":            tcell.KeyF15,
169         "F16":            tcell.KeyF16,
170         "F17":            tcell.KeyF17,
171         "F18":            tcell.KeyF18,
172         "F19":            tcell.KeyF19,
173         "F20":            tcell.KeyF20,
174         "F21":            tcell.KeyF21,
175         "F22":            tcell.KeyF22,
176         "F23":            tcell.KeyF23,
177         "F24":            tcell.KeyF24,
178         "F25":            tcell.KeyF25,
179         "F26":            tcell.KeyF26,
180         "F27":            tcell.KeyF27,
181         "F28":            tcell.KeyF28,
182         "F29":            tcell.KeyF29,
183         "F30":            tcell.KeyF30,
184         "F31":            tcell.KeyF31,
185         "F32":            tcell.KeyF32,
186         "F33":            tcell.KeyF33,
187         "F34":            tcell.KeyF34,
188         "F35":            tcell.KeyF35,
189         "F36":            tcell.KeyF36,
190         "F37":            tcell.KeyF37,
191         "F38":            tcell.KeyF38,
192         "F39":            tcell.KeyF39,
193         "F40":            tcell.KeyF40,
194         "F41":            tcell.KeyF41,
195         "F42":            tcell.KeyF42,
196         "F43":            tcell.KeyF43,
197         "F44":            tcell.KeyF44,
198         "F45":            tcell.KeyF45,
199         "F46":            tcell.KeyF46,
200         "F47":            tcell.KeyF47,
201         "F48":            tcell.KeyF48,
202         "F49":            tcell.KeyF49,
203         "F50":            tcell.KeyF50,
204         "F51":            tcell.KeyF51,
205         "F52":            tcell.KeyF52,
206         "F53":            tcell.KeyF53,
207         "F54":            tcell.KeyF54,
208         "F55":            tcell.KeyF55,
209         "F56":            tcell.KeyF56,
210         "F57":            tcell.KeyF57,
211         "F58":            tcell.KeyF58,
212         "F59":            tcell.KeyF59,
213         "F60":            tcell.KeyF60,
214         "F61":            tcell.KeyF61,
215         "F62":            tcell.KeyF62,
216         "F63":            tcell.KeyF63,
217         "F64":            tcell.KeyF64,
218         "CtrlSpace":      tcell.KeyCtrlSpace,
219         "CtrlA":          tcell.KeyCtrlA,
220         "CtrlB":          tcell.KeyCtrlB,
221         "CtrlC":          tcell.KeyCtrlC,
222         "CtrlD":          tcell.KeyCtrlD,
223         "CtrlE":          tcell.KeyCtrlE,
224         "CtrlF":          tcell.KeyCtrlF,
225         "CtrlG":          tcell.KeyCtrlG,
226         "CtrlH":          tcell.KeyCtrlH,
227         "CtrlI":          tcell.KeyCtrlI,
228         "CtrlJ":          tcell.KeyCtrlJ,
229         "CtrlK":          tcell.KeyCtrlK,
230         "CtrlL":          tcell.KeyCtrlL,
231         "CtrlM":          tcell.KeyCtrlM,
232         "CtrlN":          tcell.KeyCtrlN,
233         "CtrlO":          tcell.KeyCtrlO,
234         "CtrlP":          tcell.KeyCtrlP,
235         "CtrlQ":          tcell.KeyCtrlQ,
236         "CtrlR":          tcell.KeyCtrlR,
237         "CtrlS":          tcell.KeyCtrlS,
238         "CtrlT":          tcell.KeyCtrlT,
239         "CtrlU":          tcell.KeyCtrlU,
240         "CtrlV":          tcell.KeyCtrlV,
241         "CtrlW":          tcell.KeyCtrlW,
242         "CtrlX":          tcell.KeyCtrlX,
243         "CtrlY":          tcell.KeyCtrlY,
244         "CtrlZ":          tcell.KeyCtrlZ,
245         "CtrlLeftSq":     tcell.KeyCtrlLeftSq,
246         "CtrlBackslash":  tcell.KeyCtrlBackslash,
247         "CtrlRightSq":    tcell.KeyCtrlRightSq,
248         "CtrlCarat":      tcell.KeyCtrlCarat,
249         "CtrlUnderscore": tcell.KeyCtrlUnderscore,
250         "CtrlPageUp":     tcell.KeyCtrlPgUp,
251         "CtrlPageDown":   tcell.KeyCtrlPgDn,
252         "Tab":            tcell.KeyTab,
253         "Esc":            tcell.KeyEsc,
254         "Escape":         tcell.KeyEscape,
255         "Enter":          tcell.KeyEnter,
256         "Backspace":      tcell.KeyBackspace2,
257
258         // I renamed these keys to PageUp and PageDown but I don't want to break someone's keybindings
259         "PgUp":   tcell.KeyPgUp,
260         "PgDown": tcell.KeyPgDn,
261 }
262
263 // The Key struct holds the data for a keypress (keycode + modifiers)
264 type Key struct {
265         keyCode   tcell.Key
266         modifiers tcell.ModMask
267         buttons   tcell.ButtonMask
268         r         rune
269         escape    string
270 }
271
272 // InitBindings initializes the keybindings for micro
273 func InitBindings() {
274         bindings = make(map[Key][]func(*View, bool) bool)
275         bindingsStr = make(map[string]string)
276         mouseBindings = make(map[Key][]func(*View, bool, *tcell.EventMouse) bool)
277
278         var parsed map[string]string
279         defaults := DefaultBindings()
280
281         filename := configDir + "/bindings.json"
282         if _, e := os.Stat(filename); e == nil {
283                 input, err := ioutil.ReadFile(filename)
284                 if err != nil {
285                         TermMessage("Error reading bindings.json file: " + err.Error())
286                         return
287                 }
288
289                 err = json5.Unmarshal(input, &parsed)
290                 if err != nil {
291                         TermMessage("Error reading bindings.json:", err.Error())
292                 }
293         }
294
295         parseBindings(defaults)
296         parseBindings(parsed)
297 }
298
299 func parseBindings(userBindings map[string]string) {
300         for k, v := range userBindings {
301                 BindKey(k, v)
302         }
303 }
304
305 // findKey will find binding Key 'b' using string 'k'
306 func findKey(k string) (b Key, ok bool) {
307         modifiers := tcell.ModNone
308
309         // First, we'll strip off all the modifiers in the name and add them to the
310         // ModMask
311 modSearch:
312         for {
313                 switch {
314                 case strings.HasPrefix(k, "-"):
315                         // We optionally support dashes between modifiers
316                         k = k[1:]
317                 case strings.HasPrefix(k, "Ctrl") && k != "CtrlH":
318                         // CtrlH technically does not have a 'Ctrl' modifier because it is really backspace
319                         k = k[4:]
320                         modifiers |= tcell.ModCtrl
321                 case strings.HasPrefix(k, "Alt"):
322                         k = k[3:]
323                         modifiers |= tcell.ModAlt
324                 case strings.HasPrefix(k, "Shift"):
325                         k = k[5:]
326                         modifiers |= tcell.ModShift
327                 case strings.HasPrefix(k, "\x1b"):
328                         return Key{
329                                 keyCode:   -1,
330                                 modifiers: modifiers,
331                                 buttons:   -1,
332                                 r:         0,
333                                 escape:    k,
334                         }, true
335                 default:
336                         break modSearch
337                 }
338         }
339
340         // Control is handled specially, since some character codes in bindingKeys
341         // are different when Control is depressed. We should check for Control keys
342         // first.
343         if modifiers&tcell.ModCtrl != 0 {
344                 // see if the key is in bindingKeys with the Ctrl prefix.
345                 k = string(unicode.ToUpper(rune(k[0]))) + k[1:]
346                 if code, ok := bindingKeys["Ctrl"+k]; ok {
347                         // It is, we're done.
348                         return Key{
349                                 keyCode:   code,
350                                 modifiers: modifiers,
351                                 buttons:   -1,
352                                 r:         0,
353                         }, true
354                 }
355         }
356
357         // See if we can find the key in bindingKeys
358         if code, ok := bindingKeys[k]; ok {
359                 return Key{
360                         keyCode:   code,
361                         modifiers: modifiers,
362                         buttons:   -1,
363                         r:         0,
364                 }, true
365         }
366
367         // See if we can find the key in bindingMouse
368         if code, ok := bindingMouse[k]; ok {
369                 return Key{
370                         modifiers: modifiers,
371                         buttons:   code,
372                         r:         0,
373                 }, true
374         }
375
376         // If we were given one character, then we've got a rune.
377         if len(k) == 1 {
378                 return Key{
379                         keyCode:   tcell.KeyRune,
380                         modifiers: modifiers,
381                         buttons:   -1,
382                         r:         rune(k[0]),
383                 }, true
384         }
385
386         // We don't know what happened.
387         return Key{buttons: -1}, false
388 }
389
390 // findAction will find 'action' using string 'v'
391 func findAction(v string) (action func(*View, bool) bool) {
392         action, ok := bindingActions[v]
393         if !ok {
394                 // If the user seems to be binding a function that doesn't exist
395                 // We hope that it's a lua function that exists and bind it to that
396                 action = LuaFunctionBinding(v)
397         }
398         return action
399 }
400
401 func findMouseAction(v string) func(*View, bool, *tcell.EventMouse) bool {
402         action, ok := mouseBindingActions[v]
403         if !ok {
404                 // If the user seems to be binding a function that doesn't exist
405                 // We hope that it's a lua function that exists and bind it to that
406                 action = LuaFunctionMouseBinding(v)
407         }
408         return action
409 }
410
411 // TryBindKey tries to bind a key by writing to configDir/bindings.json
412 // This function is unused for now
413 func TryBindKey(k, v string) {
414         filename := configDir + "/bindings.json"
415         if _, e := os.Stat(filename); e == nil {
416                 input, err := ioutil.ReadFile(filename)
417                 if err != nil {
418                         TermMessage("Error reading bindings.json file: " + err.Error())
419                         return
420                 }
421
422                 conflict := -1
423                 lines := strings.Split(string(input), "\n")
424                 for i, l := range lines {
425                         parts := strings.Split(l, ":")
426                         if len(parts) >= 2 {
427                                 if strings.Contains(parts[0], k) {
428                                         conflict = i
429                                         TermMessage("Warning: Keybinding conflict:", k, " has been overwritten")
430                                 }
431                         }
432                 }
433
434                 binding := fmt.Sprintf("    \"%s\": \"%s\",", k, v)
435                 if conflict == -1 {
436                         lines = append([]string{lines[0], binding}, lines[conflict:]...)
437                 } else {
438                         lines = append(append(lines[:conflict], binding), lines[conflict+1:]...)
439                 }
440                 txt := strings.Join(lines, "\n")
441                 err = ioutil.WriteFile(filename, []byte(txt), 0644)
442                 if err != nil {
443                         TermMessage("Error")
444                 }
445         }
446 }
447
448 // BindKey takes a key and an action and binds the two together
449 func BindKey(k, v string) {
450         key, ok := findKey(k)
451         if !ok {
452                 TermMessage("Unknown keybinding: " + k)
453                 return
454         }
455         if v == "ToggleHelp" {
456                 helpBinding = k
457         }
458         if v == "ToggleKeyMenu" {
459                 kmenuBinding = k
460         }
461         if helpBinding == k && v != "ToggleHelp" {
462                 helpBinding = ""
463         }
464         if kmenuBinding == k && v != "ToggleKeyMenu" {
465                 kmenuBinding = ""
466         }
467
468         actionNames := strings.Split(v, ",")
469         if actionNames[0] == "UnbindKey" {
470                 delete(bindings, key)
471                 delete(mouseBindings, key)
472                 delete(bindingsStr, k)
473                 if len(actionNames) == 1 {
474                         return
475                 }
476                 actionNames = append(actionNames[:0], actionNames[1:]...)
477         }
478         actions := make([]func(*View, bool) bool, 0, len(actionNames))
479         mouseActions := make([]func(*View, bool, *tcell.EventMouse) bool, 0, len(actionNames))
480         for _, actionName := range actionNames {
481                 if strings.HasPrefix(actionName, "Mouse") {
482                         mouseActions = append(mouseActions, findMouseAction(actionName))
483                 } else if strings.HasPrefix(actionName, "command:") {
484                         cmd := strings.SplitN(actionName, ":", 2)[1]
485                         actions = append(actions, CommandAction(cmd))
486                 } else if strings.HasPrefix(actionName, "command-edit:") {
487                         cmd := strings.SplitN(actionName, ":", 2)[1]
488                         actions = append(actions, CommandEditAction(cmd))
489                 } else {
490                         actions = append(actions, findAction(actionName))
491                 }
492         }
493
494         if len(actions) > 0 {
495                 // Can't have a binding be both mouse and normal
496                 delete(mouseBindings, key)
497                 bindings[key] = actions
498                 bindingsStr[k] = v
499         } else if len(mouseActions) > 0 {
500                 // Can't have a binding be both mouse and normal
501                 delete(bindings, key)
502                 mouseBindings[key] = mouseActions
503         }
504 }
505
506 // DefaultBindings returns a map containing micro's default keybindings
507 func DefaultBindings() map[string]string {
508         return map[string]string{
509                 "Up":             "CursorUp",
510                 "Down":           "CursorDown",
511                 "Right":          "CursorRight",
512                 "Left":           "CursorLeft",
513                 "ShiftUp":        "SelectUp",
514                 "ShiftDown":      "SelectDown",
515                 "ShiftLeft":      "SelectLeft",
516                 "ShiftRight":     "SelectRight",
517                 "AltLeft":        "WordLeft",
518                 "AltRight":       "WordRight",
519                 "AltUp":          "MoveLinesUp",
520                 "AltDown":        "MoveLinesDown",
521                 "AltShiftRight":  "SelectWordRight",
522                 "AltShiftLeft":   "SelectWordLeft",
523                 "CtrlLeft":       "StartOfLine",
524                 "CtrlRight":      "EndOfLine",
525                 "CtrlShiftLeft":  "SelectToStartOfLine",
526                 "ShiftHome":      "SelectToStartOfLine",
527                 "CtrlShiftRight": "SelectToEndOfLine",
528                 "ShiftEnd":       "SelectToEndOfLine",
529                 "CtrlUp":         "CursorStart",
530                 "CtrlDown":       "CursorEnd",
531                 "CtrlShiftUp":    "SelectToStart",
532                 "CtrlShiftDown":  "SelectToEnd",
533                 "Alt-{":          "ParagraphPrevious",
534                 "Alt-}":          "ParagraphNext",
535                 "Enter":          "InsertNewline",
536                 "CtrlH":          "Backspace",
537                 "Backspace":      "Backspace",
538                 "Alt-CtrlH":      "DeleteWordLeft",
539                 "Alt-Backspace":  "DeleteWordLeft",
540                 "Tab":            "IndentSelection,InsertTab",
541                 "Backtab":        "OutdentSelection,OutdentLine",
542                 "CtrlO":          "OpenFile",
543                 "CtrlS":          "Save",
544                 "CtrlF":          "Find",
545                 "CtrlN":          "FindNext",
546                 "CtrlP":          "FindPrevious",
547                 "CtrlZ":          "Undo",
548                 "CtrlY":          "Redo",
549                 "CtrlC":          "Copy",
550                 "CtrlX":          "Cut",
551                 "CtrlK":          "CutLine",
552                 "CtrlD":          "DuplicateLine",
553                 "CtrlV":          "Paste",
554                 "CtrlA":          "SelectAll",
555                 "CtrlT":          "AddTab",
556                 "Alt,":           "PreviousTab",
557                 "Alt.":           "NextTab",
558                 "Home":           "StartOfLine",
559                 "End":            "EndOfLine",
560                 "CtrlHome":       "CursorStart",
561                 "CtrlEnd":        "CursorEnd",
562                 "PageUp":         "CursorPageUp",
563                 "PageDown":       "CursorPageDown",
564                 "CtrlPageUp":     "PreviousTab",
565                 "CtrlPageDown":   "NextTab",
566                 "CtrlG":          "ToggleHelp",
567                 "Alt-g":          "ToggleKeyMenu",
568                 "CtrlR":          "ToggleRuler",
569                 "CtrlL":          "JumpLine",
570                 "Delete":         "Delete",
571                 "CtrlB":          "ShellMode",
572                 "CtrlQ":          "Quit",
573                 "CtrlE":          "CommandMode",
574                 "CtrlW":          "NextSplit",
575                 "CtrlU":          "ToggleMacro",
576                 "CtrlJ":          "PlayMacro",
577                 "Insert":         "ToggleOverwriteMode",
578
579                 // Emacs-style keybindings
580                 "Alt-f": "WordRight",
581                 "Alt-b": "WordLeft",
582                 "Alt-a": "StartOfLine",
583                 "Alt-e": "EndOfLine",
584                 // "Alt-p": "CursorUp",
585                 // "Alt-n": "CursorDown",
586
587                 // Integration with file managers
588                 "F2":  "Save",
589                 "F3":  "Find",
590                 "F4":  "Quit",
591                 "F7":  "Find",
592                 "F10": "Quit",
593                 "Esc": "Escape",
594
595                 // Mouse bindings
596                 "MouseWheelUp":   "ScrollUp",
597                 "MouseWheelDown": "ScrollDown",
598                 "MouseLeft":      "MousePress",
599                 "MouseMiddle":    "PastePrimary",
600                 "Ctrl-MouseLeft": "MouseMultiCursor",
601
602                 "Alt-n": "SpawnMultiCursor",
603                 "Alt-p": "RemoveMultiCursor",
604                 "Alt-c": "RemoveAllMultiCursors",
605                 "Alt-x": "SkipMultiCursor",
606         }
607 }