some additions to the plugin API

Those changes were originally used for the snippet plugin which
may not be part of the core.
This commit is contained in:
Florian Sundermann
2016-09-19 13:23:47 +02:00
parent d41f0bb324
commit 6fe20fb305
4 changed files with 32 additions and 2 deletions

View File

@@ -1,9 +1,11 @@
package main
import (
"strings"
"time"
dmp "github.com/sergi/go-diff/diffmatchpatch"
"github.com/yuin/gopher-lua"
)
const (
@@ -114,6 +116,17 @@ func (eh *EventHandler) Execute(t *TextEvent) {
eh.RedoStack = new(Stack)
}
eh.UndoStack.Push(t)
for _, pl := range loadedPlugins {
ret, err := Call(pl+".onBeforeTextEvent", t)
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
TermMessage(err)
}
if val, ok := ret.(lua.LBool); ok && val == lua.LFalse {
return
}
}
ExecuteTextEvent(t, eh.buf)
}