mirror of
https://github.com/Hopiu/micro.git
synced 2026-05-04 04:44:43 +00:00
Support binding raw escapes codes
This commit is contained in:
parent
74589af1fc
commit
773c54a40d
3 changed files with 28 additions and 1 deletions
|
|
@ -260,6 +260,7 @@ type Key struct {
|
|||
modifiers tcell.ModMask
|
||||
buttons tcell.ButtonMask
|
||||
r rune
|
||||
escape string
|
||||
}
|
||||
|
||||
// InitBindings initializes the keybindings for micro
|
||||
|
|
@ -316,6 +317,14 @@ modSearch:
|
|||
case strings.HasPrefix(k, "Shift"):
|
||||
k = k[5:]
|
||||
modifiers |= tcell.ModShift
|
||||
case strings.HasPrefix(k, "\x1b"):
|
||||
return Key{
|
||||
keyCode: -1,
|
||||
modifiers: modifiers,
|
||||
buttons: -1,
|
||||
r: 0,
|
||||
escape: k,
|
||||
}, true
|
||||
default:
|
||||
break modSearch
|
||||
}
|
||||
|
|
|
|||
2
cmd/micro/vendor/github.com/zyedidia/tcell
generated
vendored
2
cmd/micro/vendor/github.com/zyedidia/tcell
generated
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit c47e75564a5c5e7fb5c7e5ec5b341c7902d551bc
|
||||
Subproject commit c92e80b717d7d911424a2c8394af863ceca4abf0
|
||||
|
|
@ -497,6 +497,24 @@ func (v *View) HandleEvent(event tcell.Event) {
|
|||
v.Buf.CheckModTime()
|
||||
|
||||
switch e := event.(type) {
|
||||
case *tcell.EventRaw:
|
||||
for key, actions := range bindings {
|
||||
if key.keyCode == -1 {
|
||||
if e.EscapeCode() == key.escape {
|
||||
for _, c := range v.Buf.cursors {
|
||||
ok := v.SetCursor(c)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
relocate = false
|
||||
relocate = v.ExecuteActions(actions) || relocate
|
||||
}
|
||||
v.SetCursor(&v.Buf.Cursor)
|
||||
v.Buf.MergeCursors()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
case *tcell.EventKey:
|
||||
// Check first if input is a key binding, if it is we 'eat' the input and don't insert a rune
|
||||
isBinding := false
|
||||
|
|
|
|||
Loading…
Reference in a new issue