]> git.lizzy.rs Git - micro.git/blob - internal/action/bufpane.go
Update to tcell v2
[micro.git] / internal / action / bufpane.go
1 package action
2
3 import (
4         "strings"
5         "time"
6
7         luar "layeh.com/gopher-luar"
8
9         lua "github.com/yuin/gopher-lua"
10         "github.com/zyedidia/micro/v2/internal/buffer"
11         "github.com/zyedidia/micro/v2/internal/clipboard"
12         "github.com/zyedidia/micro/v2/internal/config"
13         "github.com/zyedidia/micro/v2/internal/display"
14         ulua "github.com/zyedidia/micro/v2/internal/lua"
15         "github.com/zyedidia/micro/v2/internal/screen"
16         "github.com/zyedidia/tcell/v2"
17 )
18
19 type BufKeyAction func(*BufPane) bool
20 type BufMouseAction func(*BufPane, *tcell.EventMouse) bool
21
22 var BufBindings *KeyTree
23
24 func BufKeyActionGeneral(a BufKeyAction) PaneKeyAction {
25         return func(p Pane) bool {
26                 return a(p.(*BufPane))
27         }
28 }
29
30 func BufMouseActionGeneral(a BufMouseAction) PaneMouseAction {
31         return func(p Pane, me *tcell.EventMouse) bool {
32                 return a(p.(*BufPane), me)
33         }
34 }
35
36 func init() {
37         BufBindings = NewKeyTree()
38 }
39
40 func LuaAction(fn string) func(*BufPane) bool {
41         luaFn := strings.Split(fn, ".")
42         if len(luaFn) <= 1 {
43                 return nil
44         }
45         plName, plFn := luaFn[0], luaFn[1]
46         pl := config.FindPlugin(plName)
47         if pl == nil {
48                 return nil
49         }
50         return func(h *BufPane) bool {
51                 val, err := pl.Call(plFn, luar.New(ulua.L, h))
52                 if err != nil {
53                         screen.TermMessage(err)
54                 }
55                 if v, ok := val.(lua.LBool); !ok {
56                         return false
57                 } else {
58                         return bool(v)
59                 }
60         }
61 }
62
63 // BufMapKey maps an event to an action
64 func BufMapEvent(k Event, action string) {
65         switch e := k.(type) {
66         case KeyEvent, KeySequenceEvent, RawEvent:
67                 bufMapKey(e, action)
68         case MouseEvent:
69                 bufMapMouse(e, action)
70         }
71 }
72
73 func bufMapKey(k Event, action string) {
74         var actionfns []func(*BufPane) bool
75         var names []string
76         var types []byte
77         for i := 0; ; i++ {
78                 if action == "" {
79                         break
80                 }
81
82                 // TODO: fix problem when complex bindings have these
83                 // characters (escape them?)
84                 idx := strings.IndexAny(action, "&|,")
85                 a := action
86                 if idx >= 0 {
87                         a = action[:idx]
88                         types = append(types, action[idx])
89                         action = action[idx+1:]
90                 } else {
91                         types = append(types, ' ')
92                         action = ""
93                 }
94
95                 var afn func(*BufPane) bool
96                 if strings.HasPrefix(a, "command:") {
97                         a = strings.SplitN(a, ":", 2)[1]
98                         afn = CommandAction(a)
99                         names = append(names, "")
100                 } else if strings.HasPrefix(a, "command-edit:") {
101                         a = strings.SplitN(a, ":", 2)[1]
102                         afn = CommandEditAction(a)
103                         names = append(names, "")
104                 } else if strings.HasPrefix(a, "lua:") {
105                         a = strings.SplitN(a, ":", 2)[1]
106                         afn = LuaAction(a)
107                         if afn == nil {
108                                 screen.TermMessage("Lua Error:", a, "does not exist")
109                                 continue
110                         }
111                         split := strings.SplitN(a, ".", 2)
112                         if len(split) > 1 {
113                                 a = strings.Title(split[0]) + strings.Title(split[1])
114                         } else {
115                                 a = strings.Title(a)
116                         }
117
118                         names = append(names, a)
119                 } else if f, ok := BufKeyActions[a]; ok {
120                         afn = f
121                         names = append(names, a)
122                 } else {
123                         screen.TermMessage("Error in bindings: action", a, "does not exist")
124                         continue
125                 }
126                 actionfns = append(actionfns, afn)
127         }
128         bufAction := func(h *BufPane) bool {
129                 cursors := h.Buf.GetCursors()
130                 success := true
131                 for i, a := range actionfns {
132                         innerSuccess := true
133                         for j, c := range cursors {
134                                 if c == nil {
135                                         continue
136                                 }
137                                 h.Buf.SetCurCursor(c.Num)
138                                 h.Cursor = c
139                                 if i == 0 || (success && types[i-1] == '&') || (!success && types[i-1] == '|') || (types[i-1] == ',') {
140                                         innerSuccess = innerSuccess && h.execAction(a, names[i], j)
141                                 } else {
142                                         break
143                                 }
144                         }
145                         // if the action changed the current pane, update the reference
146                         h = MainTab().CurPane()
147                         success = innerSuccess
148                 }
149                 return true
150         }
151
152         BufBindings.RegisterKeyBinding(k, BufKeyActionGeneral(bufAction))
153 }
154
155 // BufMapMouse maps a mouse event to an action
156 func bufMapMouse(k MouseEvent, action string) {
157         if f, ok := BufMouseActions[action]; ok {
158                 BufBindings.RegisterMouseBinding(k, BufMouseActionGeneral(f))
159         } else {
160                 // TODO
161                 // delete(BufMouseBindings, k)
162                 bufMapKey(k, action)
163         }
164 }
165
166 // BufUnmap unmaps a key or mouse event from any action
167 func BufUnmap(k Event) {
168         // TODO
169         // delete(BufKeyBindings, k)
170         //
171         // switch e := k.(type) {
172         // case MouseEvent:
173         //      delete(BufMouseBindings, e)
174         // }
175 }
176
177 // The BufPane connects the buffer and the window
178 // It provides a cursor (or multiple) and defines a set of actions
179 // that can be taken on the buffer
180 // The ActionHandler can access the window for necessary info about
181 // visual positions for mouse clicks and scrolling
182 type BufPane struct {
183         display.BWindow
184
185         // Buf is the buffer this BufPane views
186         Buf *buffer.Buffer
187         // Bindings stores the association of key events and actions
188         bindings *KeyTree
189
190         // Cursor is the currently active buffer cursor
191         Cursor *buffer.Cursor
192
193         // Since tcell doesn't differentiate between a mouse release event
194         // and a mouse move event with no keys pressed, we need to keep
195         // track of whether or not the mouse was pressed (or not released) last event to determine
196         // mouse release events
197         mouseReleased bool
198
199         // We need to keep track of insert key press toggle
200         isOverwriteMode bool
201         // This stores when the last click was
202         // This is useful for detecting double and triple clicks
203         lastClickTime time.Time
204         lastLoc       buffer.Loc
205
206         // lastCutTime stores when the last ctrl+k was issued.
207         // It is used for clearing the clipboard to replace it with fresh cut lines.
208         lastCutTime time.Time
209
210         // freshClip returns true if the clipboard has never been pasted.
211         freshClip bool
212
213         // Was the last mouse event actually a double click?
214         // Useful for detecting triple clicks -- if a double click is detected
215         // but the last mouse event was actually a double click, it's a triple click
216         doubleClick bool
217         // Same here, just to keep track for mouse move events
218         tripleClick bool
219
220         // Last search stores the last successful search for FindNext and FindPrev
221         lastSearch      string
222         lastSearchRegex bool
223         // Should the current multiple cursor selection search based on word or
224         // based on selection (false for selection, true for word)
225         multiWord bool
226
227         splitID uint64
228         tab     *Tab
229
230         // remember original location of a search in case the search is canceled
231         searchOrig buffer.Loc
232 }
233
234 func NewBufPane(buf *buffer.Buffer, win display.BWindow, tab *Tab) *BufPane {
235         h := new(BufPane)
236         h.Buf = buf
237         h.BWindow = win
238         h.tab = tab
239
240         h.Cursor = h.Buf.GetActiveCursor()
241         h.mouseReleased = true
242
243         config.RunPluginFn("onBufPaneOpen", luar.New(ulua.L, h))
244
245         return h
246 }
247
248 func NewBufPaneFromBuf(buf *buffer.Buffer, tab *Tab) *BufPane {
249         w := display.NewBufWindow(0, 0, 0, 0, buf)
250         return NewBufPane(buf, w, tab)
251 }
252
253 func (h *BufPane) SetTab(t *Tab) {
254         h.tab = t
255 }
256
257 func (h *BufPane) Tab() *Tab {
258         return h.tab
259 }
260
261 func (h *BufPane) ResizePane(size int) {
262         n := h.tab.GetNode(h.splitID)
263         n.ResizeSplit(size)
264         h.tab.Resize()
265 }
266
267 // PluginCB calls all plugin callbacks with a certain name and
268 // displays an error if there is one and returns the aggregrate
269 // boolean response
270 func (h *BufPane) PluginCB(cb string) bool {
271         b, err := config.RunPluginFnBool(cb, luar.New(ulua.L, h))
272         if err != nil {
273                 screen.TermMessage(err)
274         }
275         return b
276 }
277
278 // PluginCBRune is the same as PluginCB but also passes a rune to
279 // the plugins
280 func (h *BufPane) PluginCBRune(cb string, r rune) bool {
281         b, err := config.RunPluginFnBool(cb, luar.New(ulua.L, h), luar.New(ulua.L, string(r)))
282         if err != nil {
283                 screen.TermMessage(err)
284         }
285         return b
286 }
287
288 func (h *BufPane) OpenBuffer(b *buffer.Buffer) {
289         h.Buf.Close()
290         h.Buf = b
291         h.BWindow.SetBuffer(b)
292         h.Cursor = b.GetActiveCursor()
293         h.Resize(h.GetView().Width, h.GetView().Height)
294         h.Relocate()
295         // Set mouseReleased to true because we assume the mouse is not being pressed when
296         // the editor is opened
297         h.mouseReleased = true
298         // Set isOverwriteMode to false, because we assume we are in the default mode when editor
299         // is opened
300         h.isOverwriteMode = false
301         h.lastClickTime = time.Time{}
302 }
303
304 func (h *BufPane) ID() uint64 {
305         return h.splitID
306 }
307
308 func (h *BufPane) SetID(i uint64) {
309         h.splitID = i
310 }
311
312 func (h *BufPane) Name() string {
313         n := h.Buf.GetName()
314         if h.Buf.Modified() {
315                 n += " +"
316         }
317         return n
318 }
319
320 // HandleEvent executes the tcell event properly
321 func (h *BufPane) HandleEvent(event tcell.Event) {
322         if h.Buf.ExternallyModified() && !h.Buf.ReloadDisabled {
323                 InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool) {
324                         if canceled {
325                                 h.Buf.DisableReload()
326                         }
327                         if !yes || canceled {
328                                 h.Buf.UpdateModTime()
329                         } else {
330                                 h.Buf.ReOpen()
331                         }
332                 })
333
334         }
335
336         switch e := event.(type) {
337         case *tcell.EventRaw:
338                 re := RawEvent{
339                         esc: e.EscSeq(),
340                 }
341                 h.DoKeyEvent(re)
342         case *tcell.EventPaste:
343                 h.paste(e.Text())
344                 h.Relocate()
345         case *tcell.EventKey:
346                 ke := KeyEvent{
347                         code: e.Key(),
348                         mod:  e.Modifiers(),
349                         r:    e.Rune(),
350                 }
351
352                 done := h.DoKeyEvent(ke)
353                 if !done && e.Key() == tcell.KeyRune {
354                         h.DoRuneInsert(e.Rune())
355                 }
356         case *tcell.EventMouse:
357                 cancel := false
358                 switch e.Buttons() {
359                 case tcell.Button1:
360                         _, my := e.Position()
361                         if h.Buf.Type.Kind != buffer.BTInfo.Kind && h.Buf.Settings["statusline"].(bool) && my >= h.GetView().Y+h.GetView().Height-1 {
362                                 cancel = true
363                         }
364                 case tcell.ButtonNone:
365                         // Mouse event with no click
366                         if !h.mouseReleased {
367                                 // Mouse was just released
368
369                                 // mx, my := e.Position()
370                                 // mouseLoc := h.LocFromVisual(buffer.Loc{X: mx, Y: my})
371
372                                 // we could finish the selection based on the release location as described
373                                 // below but when the mouse click is within the scroll margin this will
374                                 // cause a scroll and selection even for a simple mouse click which is
375                                 // not good
376                                 // for terminals that don't support mouse motion events, selection via
377                                 // the mouse won't work but this is ok
378
379                                 // Relocating here isn't really necessary because the cursor will
380                                 // be in the right place from the last mouse event
381                                 // However, if we are running in a terminal that doesn't support mouse motion
382                                 // events, this still allows the user to make selections, except only after they
383                                 // release the mouse
384
385                                 // if !h.doubleClick && !h.tripleClick {
386                                 //      h.Cursor.SetSelectionEnd(h.Cursor.Loc)
387                                 // }
388                                 if h.Cursor.HasSelection() {
389                                         h.Cursor.CopySelection(clipboard.PrimaryReg)
390                                 }
391                                 h.mouseReleased = true
392                         }
393                 }
394
395                 if !cancel {
396                         me := MouseEvent{
397                                 btn: e.Buttons(),
398                                 mod: e.Modifiers(),
399                         }
400                         h.DoMouseEvent(me, e)
401                 }
402         }
403         h.Buf.MergeCursors()
404
405         if h.IsActive() {
406                 // Display any gutter messages for this line
407                 c := h.Buf.GetActiveCursor()
408                 none := true
409                 for _, m := range h.Buf.Messages {
410                         if c.Y == m.Start.Y || c.Y == m.End.Y {
411                                 InfoBar.GutterMessage(m.Msg)
412                                 none = false
413                                 break
414                         }
415                 }
416                 if none && InfoBar.HasGutter {
417                         InfoBar.ClearGutter()
418                 }
419         }
420 }
421
422 func (h *BufPane) Bindings() *KeyTree {
423         if h.bindings != nil {
424                 return h.bindings
425         }
426         return BufBindings
427 }
428
429 // DoKeyEvent executes a key event by finding the action it is bound
430 // to and executing it (possibly multiple times for multiple cursors)
431 func (h *BufPane) DoKeyEvent(e Event) bool {
432         binds := h.Bindings()
433         action, more := binds.NextEvent(e, nil)
434         if action != nil && !more {
435                 action(h)
436                 binds.ResetEvents()
437                 return true
438         } else if action == nil && !more {
439                 binds.ResetEvents()
440         }
441         return more
442 }
443
444 func (h *BufPane) execAction(action func(*BufPane) bool, name string, cursor int) bool {
445         if name != "Autocomplete" && name != "CycleAutocompleteBack" {
446                 h.Buf.HasSuggestions = false
447         }
448
449         _, isMulti := MultiActions[name]
450         if (!isMulti && cursor == 0) || isMulti {
451                 if h.PluginCB("pre" + name) {
452                         success := action(h)
453                         success = success && h.PluginCB("on"+name)
454
455                         if isMulti {
456                                 if recording_macro {
457                                         if name != "ToggleMacro" && name != "PlayMacro" {
458                                                 curmacro = append(curmacro, action)
459                                         }
460                                 }
461                         }
462
463                         return success
464                 }
465         }
466
467         return false
468 }
469
470 func (h *BufPane) completeAction(action string) {
471         h.PluginCB("on" + action)
472 }
473
474 func (h *BufPane) HasKeyEvent(e Event) bool {
475         // TODO
476         return true
477         // _, ok := BufKeyBindings[e]
478         // return ok
479 }
480
481 // DoMouseEvent executes a mouse event by finding the action it is bound
482 // to and executing it
483 func (h *BufPane) DoMouseEvent(e MouseEvent, te *tcell.EventMouse) bool {
484         binds := h.Bindings()
485         action, _ := binds.NextEvent(e, te)
486         if action != nil {
487                 action(h)
488                 binds.ResetEvents()
489                 return true
490         }
491         // TODO
492         return false
493
494         // if action, ok := BufMouseBindings[e]; ok {
495         //      if action(h, te) {
496         //              h.Relocate()
497         //      }
498         //      return true
499         // } else if h.HasKeyEvent(e) {
500         //      return h.DoKeyEvent(e)
501         // }
502         // return false
503 }
504
505 // DoRuneInsert inserts a given rune into the current buffer
506 // (possibly multiple times for multiple cursors)
507 func (h *BufPane) DoRuneInsert(r rune) {
508         cursors := h.Buf.GetCursors()
509         for _, c := range cursors {
510                 // Insert a character
511                 h.Buf.SetCurCursor(c.Num)
512                 h.Cursor = c
513                 if !h.PluginCBRune("preRune", r) {
514                         continue
515                 }
516                 if c.HasSelection() {
517                         c.DeleteSelection()
518                         c.ResetSelection()
519                 }
520
521                 if h.isOverwriteMode {
522                         next := c.Loc
523                         next.X++
524                         h.Buf.Replace(c.Loc, next, string(r))
525                 } else {
526                         h.Buf.Insert(c.Loc, string(r))
527                 }
528                 if recording_macro {
529                         curmacro = append(curmacro, r)
530                 }
531                 h.Relocate()
532                 h.PluginCBRune("onRune", r)
533         }
534 }
535
536 func (h *BufPane) VSplitIndex(buf *buffer.Buffer, right bool) *BufPane {
537         e := NewBufPaneFromBuf(buf, h.tab)
538         e.splitID = MainTab().GetNode(h.splitID).VSplit(right)
539         MainTab().Panes = append(MainTab().Panes, e)
540         MainTab().Resize()
541         MainTab().SetActive(len(MainTab().Panes) - 1)
542         return e
543 }
544 func (h *BufPane) HSplitIndex(buf *buffer.Buffer, bottom bool) *BufPane {
545         e := NewBufPaneFromBuf(buf, h.tab)
546         e.splitID = MainTab().GetNode(h.splitID).HSplit(bottom)
547         MainTab().Panes = append(MainTab().Panes, e)
548         MainTab().Resize()
549         MainTab().SetActive(len(MainTab().Panes) - 1)
550         return e
551 }
552
553 func (h *BufPane) VSplitBuf(buf *buffer.Buffer) *BufPane {
554         return h.VSplitIndex(buf, h.Buf.Settings["splitright"].(bool))
555 }
556 func (h *BufPane) HSplitBuf(buf *buffer.Buffer) *BufPane {
557         return h.HSplitIndex(buf, h.Buf.Settings["splitbottom"].(bool))
558 }
559 func (h *BufPane) Close() {
560         h.Buf.Close()
561 }
562
563 func (h *BufPane) SetActive(b bool) {
564         h.BWindow.SetActive(b)
565         if b {
566                 // Display any gutter messages for this line
567                 c := h.Buf.GetActiveCursor()
568                 none := true
569                 for _, m := range h.Buf.Messages {
570                         if c.Y == m.Start.Y || c.Y == m.End.Y {
571                                 InfoBar.GutterMessage(m.Msg)
572                                 none = false
573                                 break
574                         }
575                 }
576                 if none && InfoBar.HasGutter {
577                         InfoBar.ClearGutter()
578                 }
579         }
580
581 }
582
583 // BufKeyActions contains the list of all possible key actions the bufhandler could execute
584 var BufKeyActions = map[string]BufKeyAction{
585         "CursorUp":                  (*BufPane).CursorUp,
586         "CursorDown":                (*BufPane).CursorDown,
587         "CursorPageUp":              (*BufPane).CursorPageUp,
588         "CursorPageDown":            (*BufPane).CursorPageDown,
589         "CursorLeft":                (*BufPane).CursorLeft,
590         "CursorRight":               (*BufPane).CursorRight,
591         "CursorStart":               (*BufPane).CursorStart,
592         "CursorEnd":                 (*BufPane).CursorEnd,
593         "SelectToStart":             (*BufPane).SelectToStart,
594         "SelectToEnd":               (*BufPane).SelectToEnd,
595         "SelectUp":                  (*BufPane).SelectUp,
596         "SelectDown":                (*BufPane).SelectDown,
597         "SelectLeft":                (*BufPane).SelectLeft,
598         "SelectRight":               (*BufPane).SelectRight,
599         "WordRight":                 (*BufPane).WordRight,
600         "WordLeft":                  (*BufPane).WordLeft,
601         "SelectWordRight":           (*BufPane).SelectWordRight,
602         "SelectWordLeft":            (*BufPane).SelectWordLeft,
603         "DeleteWordRight":           (*BufPane).DeleteWordRight,
604         "DeleteWordLeft":            (*BufPane).DeleteWordLeft,
605         "SelectLine":                (*BufPane).SelectLine,
606         "SelectToStartOfLine":       (*BufPane).SelectToStartOfLine,
607         "SelectToStartOfText":       (*BufPane).SelectToStartOfText,
608         "SelectToStartOfTextToggle": (*BufPane).SelectToStartOfTextToggle,
609         "SelectToEndOfLine":         (*BufPane).SelectToEndOfLine,
610         "ParagraphPrevious":         (*BufPane).ParagraphPrevious,
611         "ParagraphNext":             (*BufPane).ParagraphNext,
612         "InsertNewline":             (*BufPane).InsertNewline,
613         "Backspace":                 (*BufPane).Backspace,
614         "Delete":                    (*BufPane).Delete,
615         "InsertTab":                 (*BufPane).InsertTab,
616         "Save":                      (*BufPane).Save,
617         "SaveAll":                   (*BufPane).SaveAll,
618         "SaveAs":                    (*BufPane).SaveAs,
619         "Find":                      (*BufPane).Find,
620         "FindLiteral":               (*BufPane).FindLiteral,
621         "FindNext":                  (*BufPane).FindNext,
622         "FindPrevious":              (*BufPane).FindPrevious,
623         "Center":                    (*BufPane).Center,
624         "Undo":                      (*BufPane).Undo,
625         "Redo":                      (*BufPane).Redo,
626         "Copy":                      (*BufPane).Copy,
627         "CopyLine":                  (*BufPane).CopyLine,
628         "Cut":                       (*BufPane).Cut,
629         "CutLine":                   (*BufPane).CutLine,
630         "DuplicateLine":             (*BufPane).DuplicateLine,
631         "DeleteLine":                (*BufPane).DeleteLine,
632         "MoveLinesUp":               (*BufPane).MoveLinesUp,
633         "MoveLinesDown":             (*BufPane).MoveLinesDown,
634         "IndentSelection":           (*BufPane).IndentSelection,
635         "OutdentSelection":          (*BufPane).OutdentSelection,
636         "Autocomplete":              (*BufPane).Autocomplete,
637         "CycleAutocompleteBack":     (*BufPane).CycleAutocompleteBack,
638         "OutdentLine":               (*BufPane).OutdentLine,
639         "IndentLine":                (*BufPane).IndentLine,
640         "Paste":                     (*BufPane).Paste,
641         "PastePrimary":              (*BufPane).PastePrimary,
642         "SelectAll":                 (*BufPane).SelectAll,
643         "OpenFile":                  (*BufPane).OpenFile,
644         "Start":                     (*BufPane).Start,
645         "End":                       (*BufPane).End,
646         "PageUp":                    (*BufPane).PageUp,
647         "PageDown":                  (*BufPane).PageDown,
648         "SelectPageUp":              (*BufPane).SelectPageUp,
649         "SelectPageDown":            (*BufPane).SelectPageDown,
650         "HalfPageUp":                (*BufPane).HalfPageUp,
651         "HalfPageDown":              (*BufPane).HalfPageDown,
652         "StartOfText":               (*BufPane).StartOfText,
653         "StartOfTextToggle":         (*BufPane).StartOfTextToggle,
654         "StartOfLine":               (*BufPane).StartOfLine,
655         "EndOfLine":                 (*BufPane).EndOfLine,
656         "ToggleHelp":                (*BufPane).ToggleHelp,
657         "ToggleKeyMenu":             (*BufPane).ToggleKeyMenu,
658         "ToggleDiffGutter":          (*BufPane).ToggleDiffGutter,
659         "ToggleRuler":               (*BufPane).ToggleRuler,
660         "ClearStatus":               (*BufPane).ClearStatus,
661         "ShellMode":                 (*BufPane).ShellMode,
662         "CommandMode":               (*BufPane).CommandMode,
663         "ToggleOverwriteMode":       (*BufPane).ToggleOverwriteMode,
664         "Escape":                    (*BufPane).Escape,
665         "Quit":                      (*BufPane).Quit,
666         "QuitAll":                   (*BufPane).QuitAll,
667         "AddTab":                    (*BufPane).AddTab,
668         "PreviousTab":               (*BufPane).PreviousTab,
669         "NextTab":                   (*BufPane).NextTab,
670         "NextSplit":                 (*BufPane).NextSplit,
671         "PreviousSplit":             (*BufPane).PreviousSplit,
672         "Unsplit":                   (*BufPane).Unsplit,
673         "VSplit":                    (*BufPane).VSplitAction,
674         "HSplit":                    (*BufPane).HSplitAction,
675         "ToggleMacro":               (*BufPane).ToggleMacro,
676         "PlayMacro":                 (*BufPane).PlayMacro,
677         "Suspend":                   (*BufPane).Suspend,
678         "ScrollUp":                  (*BufPane).ScrollUpAction,
679         "ScrollDown":                (*BufPane).ScrollDownAction,
680         "SpawnMultiCursor":          (*BufPane).SpawnMultiCursor,
681         "SpawnMultiCursorUp":        (*BufPane).SpawnMultiCursorUp,
682         "SpawnMultiCursorDown":      (*BufPane).SpawnMultiCursorDown,
683         "SpawnMultiCursorSelect":    (*BufPane).SpawnMultiCursorSelect,
684         "RemoveMultiCursor":         (*BufPane).RemoveMultiCursor,
685         "RemoveAllMultiCursors":     (*BufPane).RemoveAllMultiCursors,
686         "SkipMultiCursor":           (*BufPane).SkipMultiCursor,
687         "JumpToMatchingBrace":       (*BufPane).JumpToMatchingBrace,
688         "JumpLine":                  (*BufPane).JumpLine,
689         "Deselect":                  (*BufPane).Deselect,
690         "ClearInfo":                 (*BufPane).ClearInfo,
691         "None":                      (*BufPane).None,
692
693         // This was changed to InsertNewline but I don't want to break backwards compatibility
694         "InsertEnter": (*BufPane).InsertNewline,
695 }
696
697 // BufMouseActions contains the list of all possible mouse actions the bufhandler could execute
698 var BufMouseActions = map[string]BufMouseAction{
699         "MousePress":       (*BufPane).MousePress,
700         "MouseMultiCursor": (*BufPane).MouseMultiCursor,
701 }
702
703 // MultiActions is a list of actions that should be executed multiple
704 // times if there are multiple cursors (one per cursor)
705 // Generally actions that modify global editor state like quitting or
706 // saving should not be included in this list
707 var MultiActions = map[string]bool{
708         "CursorUp":                  true,
709         "CursorDown":                true,
710         "CursorPageUp":              true,
711         "CursorPageDown":            true,
712         "CursorLeft":                true,
713         "CursorRight":               true,
714         "CursorStart":               true,
715         "CursorEnd":                 true,
716         "SelectToStart":             true,
717         "SelectToEnd":               true,
718         "SelectUp":                  true,
719         "SelectDown":                true,
720         "SelectLeft":                true,
721         "SelectRight":               true,
722         "WordRight":                 true,
723         "WordLeft":                  true,
724         "SelectWordRight":           true,
725         "SelectWordLeft":            true,
726         "DeleteWordRight":           true,
727         "DeleteWordLeft":            true,
728         "SelectLine":                true,
729         "SelectToStartOfLine":       true,
730         "SelectToStartOfText":       true,
731         "SelectToStartOfTextToggle": true,
732         "SelectToEndOfLine":         true,
733         "ParagraphPrevious":         true,
734         "ParagraphNext":             true,
735         "InsertNewline":             true,
736         "Backspace":                 true,
737         "Delete":                    true,
738         "InsertTab":                 true,
739         "FindNext":                  true,
740         "FindPrevious":              true,
741         "CopyLine":                  true,
742         "Copy":                      true,
743         "Cut":                       true,
744         "CutLine":                   true,
745         "DuplicateLine":             true,
746         "DeleteLine":                true,
747         "MoveLinesUp":               true,
748         "MoveLinesDown":             true,
749         "IndentSelection":           true,
750         "OutdentSelection":          true,
751         "OutdentLine":               true,
752         "IndentLine":                true,
753         "Paste":                     true,
754         "PastePrimary":              true,
755         "SelectPageUp":              true,
756         "SelectPageDown":            true,
757         "StartOfLine":               true,
758         "StartOfText":               true,
759         "StartOfTextToggle":         true,
760         "EndOfLine":                 true,
761         "JumpToMatchingBrace":       true,
762 }