mirror of
https://github.com/Hopiu/micro.git
synced 2026-05-18 11:31:08 +00:00
bindings: Allow raw escape sequence to be bound with bind
This commit is contained in:
parent
68d88b571d
commit
dcc7205699
1 changed files with 8 additions and 3 deletions
|
|
@ -634,6 +634,11 @@ func (h *BufPane) ShowCmd(args []string) {
|
||||||
InfoBar.Message(option)
|
InfoBar.Message(option)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseKeyArg(arg string) string {
|
||||||
|
// If this is a raw escape sequence, convert it to its raw byte form
|
||||||
|
return strings.ReplaceAll(arg, "\\x1b", "\x1b")
|
||||||
|
}
|
||||||
|
|
||||||
// ShowKeyCmd displays the action that a key is bound to
|
// ShowKeyCmd displays the action that a key is bound to
|
||||||
func (h *BufPane) ShowKeyCmd(args []string) {
|
func (h *BufPane) ShowKeyCmd(args []string) {
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
|
|
@ -641,7 +646,7 @@ func (h *BufPane) ShowKeyCmd(args []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
event, err := findEvent(args[0])
|
event, err := findEvent(parseKeyArg(args[0]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
InfoBar.Error(err)
|
InfoBar.Error(err)
|
||||||
return
|
return
|
||||||
|
|
@ -660,7 +665,7 @@ func (h *BufPane) BindCmd(args []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := TryBindKey(args[0], args[1], true)
|
_, err := TryBindKey(parseKeyArg(args[0]), args[1], true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
InfoBar.Error(err)
|
InfoBar.Error(err)
|
||||||
}
|
}
|
||||||
|
|
@ -673,7 +678,7 @@ func (h *BufPane) UnbindCmd(args []string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := UnbindKey(args[0])
|
err := UnbindKey(parseKeyArg(args[0]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
InfoBar.Error(err)
|
InfoBar.Error(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue