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