mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 06:37:14 +09:00
Change plugin callbacks to not only happen when a keybinding triggers the action
This commit is contained in:
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
|
||||
|
||||
Reference in New Issue
Block a user