Add onRune(r string) callback for plugins

Define this function in a plugin (which takes one argument) to be
notified whenever a character is typed, and the character will be passed
as the argument.
This commit is contained in:
Zachary Yedidia
2016-06-21 17:57:25 -04:00
parent d32d373bff
commit 47efea6501

View File

@@ -298,6 +298,13 @@ func (v *View) HandleEvent(event tcell.Event) {
}
v.Buf.Insert(v.Cursor.Loc, string(e.Rune()))
v.Cursor.Right()
for _, pl := range loadedPlugins {
err := Call(pl+".onRune", []string{string(e.Rune())})
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
TermMessage(err)
}
}
} else {
for key, actions := range bindings {
if e.Key() == key.keyCode {