mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-20 07:50:25 +00:00
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:
parent
d32d373bff
commit
47efea6501
1 changed files with 7 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue