mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 06:37:14 +09:00
chainable actions and flexible modifiers
Doesn't work quite right yet, but the idea is to support arbitrary modifiers without having to hardcode in all the permutations of alt/shift/ctrl for every key, along with chainable actions, so this can be configured: "AltBackspace": "SelectWordLeft,Backspace",
This commit is contained in:
@@ -280,7 +280,7 @@ func (v *View) HandleEvent(event tcell.Event) {
|
||||
v.Buf.Insert(v.Cursor.Loc(), string(e.Rune()))
|
||||
v.Cursor.Right()
|
||||
} else {
|
||||
for key, action := range bindings {
|
||||
for key, actions := range bindings {
|
||||
if e.Key() == key.keyCode {
|
||||
if e.Key() == tcell.KeyRune {
|
||||
if e.Rune() != key.r {
|
||||
@@ -288,12 +288,15 @@ func (v *View) HandleEvent(event tcell.Event) {
|
||||
}
|
||||
}
|
||||
if e.Modifiers() == key.modifiers {
|
||||
relocate = action(v)
|
||||
for _, pl := range loadedPlugins {
|
||||
funcName := strings.Split(runtime.FuncForPC(reflect.ValueOf(action).Pointer()).Name(), ".")
|
||||
err := Call(pl+"_on"+funcName[len(funcName)-1], nil)
|
||||
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
|
||||
TermMessage(err)
|
||||
relocate = false
|
||||
for _, action := range actions {
|
||||
relocate = action(v) || relocate
|
||||
for _, pl := range loadedPlugins {
|
||||
funcName := strings.Split(runtime.FuncForPC(reflect.ValueOf(action).Pointer()).Name(), ".")
|
||||
err := Call(pl+"_on"+funcName[len(funcName)-1], nil)
|
||||
if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
|
||||
TermMessage(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user