From b40ebdcb33e5d7dad7c9018b632ab73b9e06ca65 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Fri, 4 Sep 2020 21:25:19 +0300 Subject: [PATCH] fix regular keys in push commands Related #445 --- eval.go | 4 ++-- ui.go | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/eval.go b/eval.go index 9d6ba96..e27eb75 100644 --- a/eval.go +++ b/eval.go @@ -1012,8 +1012,8 @@ func (e *callExpr) eval(app *app, args []string) { return } log.Println("pushing keys", e.args[0]) - for _, key := range splitKeys(e.args[0]) { - app.ui.keyChan <- key + for _, val := range splitKeys(e.args[0]) { + app.ui.keyChan <- val } case "cmd-insert": if len(e.args) == 0 { diff --git a/ui.go b/ui.go index 50fc313..9065cb4 100644 --- a/ui.go +++ b/ui.go @@ -808,34 +808,35 @@ func listMarks(marks map[string]string) *bytes.Buffer { func (ui *ui) pollEvent() tcell.Event { select { - case key := <-ui.keyChan: + case val := <-ui.keyChan: var ch rune var mod tcell.ModMask - var Key tcell.Key - if utf8.RuneCountInString(key) == 1 { - ch, _ = utf8.DecodeRuneInString(key) + k := tcell.KeyRune + + if utf8.RuneCountInString(val) == 1 { + ch, _ = utf8.DecodeRuneInString(val) } else { switch { - case key == "": + case val == "": ch = '<' - case key == "": + case val == "": ch = '>' - case reAltKey.MatchString(key): - match := reAltKey.FindStringSubmatch(key)[1] + case reAltKey.MatchString(val): + match := reAltKey.FindStringSubmatch(val)[1] ch, _ = utf8.DecodeRuneInString(match) mod = tcell.ModMask(tcell.ModAlt) default: - if val, ok := gValKey[key]; ok { - Key = val + if key, ok := gValKey[val]; ok { + k = key } else { - Key = tcell.KeyESC - ui.echoerrf("unknown key: %s", key) + k = tcell.KeyESC + ui.echoerrf("unknown key: %s", val) } } } - return tcell.NewEventKey(Key, ch, mod) + return tcell.NewEventKey(k, ch, mod) case ev := <-ui.evChan: return ev }