@@ -321,18 +321,16 @@ func (h *BufPane) ResizePane(size int) {
321321}
322322
323323// PluginCB calls all plugin callbacks with a certain name and displays an
324- // error if there is one and returns the aggregate boolean response
325- func (h * BufPane ) PluginCB (cb string ) bool {
326- b , err := config .RunPluginFnBool (h .Buf .Settings , cb , luar .New (ulua .L , h ))
327- if err != nil {
328- screen .TermMessage (err )
324+ // error if there is one and returns the aggregate boolean response.
325+ // The bufpane is passed as the first argument to the callbacks,
326+ // optional args are passed as the next arguments.
327+ func (h * BufPane ) PluginCB (cb string , args ... interface {}) bool {
328+ largs := []lua.LValue {luar .New (ulua .L , h )}
329+ for _ , a := range args {
330+ largs = append (largs , luar .New (ulua .L , a ))
329331 }
330- return b
331- }
332332
333- // PluginCBRune is the same as PluginCB but also passes a rune to the plugins
334- func (h * BufPane ) PluginCBRune (cb string , r rune ) bool {
335- b , err := config .RunPluginFnBool (h .Buf .Settings , cb , luar .New (ulua .L , h ), luar .New (ulua .L , string (r )))
333+ b , err := config .RunPluginFnBool (h .Buf .Settings , cb , largs ... )
336334 if err != nil {
337335 screen .TermMessage (err )
338336 }
@@ -559,7 +557,7 @@ func (h *BufPane) execAction(action BufAction, name string, te *tcell.EventMouse
559557 h .Buf .HasSuggestions = false
560558 }
561559
562- if ! h .PluginCB ("pre" + name ) {
560+ if ! h .PluginCB ("pre" + name , te ) {
563561 return false
564562 }
565563
@@ -570,7 +568,7 @@ func (h *BufPane) execAction(action BufAction, name string, te *tcell.EventMouse
570568 case BufMouseAction :
571569 success = a (h , te )
572570 }
573- success = success && h .PluginCB ("on" + name )
571+ success = success && h .PluginCB ("on" + name , te )
574572
575573 if _ , ok := MultiActions [name ]; ok {
576574 if recordingMacro {
@@ -626,7 +624,7 @@ func (h *BufPane) DoRuneInsert(r rune) {
626624 // Insert a character
627625 h .Buf .SetCurCursor (c .Num )
628626 h .Cursor = c
629- if ! h .PluginCBRune ("preRune" , r ) {
627+ if ! h .PluginCB ("preRune" , string ( r ) ) {
630628 continue
631629 }
632630 if c .HasSelection () {
@@ -645,7 +643,7 @@ func (h *BufPane) DoRuneInsert(r rune) {
645643 curmacro = append (curmacro , r )
646644 }
647645 h .Relocate ()
648- h .PluginCBRune ("onRune" , r )
646+ h .PluginCB ("onRune" , string ( r ) )
649647 }
650648}
651649
0 commit comments