mirror of
https://github.com/Hopiu/micro.git
synced 2026-05-17 19:21:07 +00:00
Change plugin callbacks to not only happen when a keybinding triggers the action
This commit is contained in:
parent
de9567322b
commit
ed31d37e74
4 changed files with 517 additions and 127 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -1,14 +1,11 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mattn/go-runewidth"
|
||||
"github.com/yuin/gopher-lua"
|
||||
"github.com/zyedidia/tcell"
|
||||
)
|
||||
|
||||
|
|
@ -333,28 +330,7 @@ func (v *View) HandleEvent(event tcell.Event) {
|
|||
if e.Modifiers() == key.modifiers {
|
||||
relocate = false
|
||||
for _, action := range actions {
|
||||
executeAction := true
|
||||
funcName := strings.Split(runtime.FuncForPC(reflect.ValueOf(action).Pointer()).Name(), ".")
|
||||
for _, pl := range loadedPlugins {
|
||||
ret, err := Call(pl+".pre"+funcName[len(funcName)-1], nil)
|
||||
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
|
||||
TermMessage(err)
|
||||
continue
|
||||
}
|
||||
if ret == lua.LFalse {
|
||||
executeAction = false
|
||||
}
|
||||
}
|
||||
if executeAction {
|
||||
relocate = action(v) || relocate
|
||||
for _, pl := range loadedPlugins {
|
||||
_, err := Call(pl+".on"+funcName[len(funcName)-1], nil)
|
||||
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
|
||||
TermMessage(err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
relocate = action(v) || relocate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ function onRune(r)
|
|||
end
|
||||
end
|
||||
|
||||
function onInsertEnter()
|
||||
function onInsertNewline()
|
||||
if not GetOption("autoclose") then
|
||||
return
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue