summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Czapliński <czapkofan@gmail.com>2018-12-04 21:04:19 +0100
committerMateusz Czapliński <czapkofan@gmail.com>2018-12-04 21:04:19 +0100
commit748ed0c619d2e74e39580965820a05acf4e538c1 (patch)
tree5dfe33f8dc24c87284ed2f6ad1d1b593b7324119
parent768439418ecc58dbf740893fbee754e6a19fa90b (diff)
keys: supplement ctrlKey() with key()
I'm not really sure why KeyCtrlB needs to be wrapped with ctrlKey() on my machine, if it already has Ctrl in name; I hoped key() would be enough here. But it seems to only work in ctrlKey() for me. However, given the confusion, I currently prefer to err on the "beter safe than sorry" side, and slap both variants everywhere. To be fixed some day in future maybe.
-rw-r--r--up.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/up.go b/up.go
index a3ae807..cc06d1a 100644
--- a/up.go
+++ b/up.go
@@ -328,22 +328,28 @@ func (e *Editor) HandleKey(ev *tcell.EventKey) bool {
case key(tcell.KeyDelete):
e.delete(0)
case key(tcell.KeyLeft),
+ key(tcell.KeyCtrlB),
ctrlKey(tcell.KeyCtrlB):
if e.cursor > 0 {
e.cursor--
}
case key(tcell.KeyRight),
+ key(tcell.KeyCtrlF),
ctrlKey(tcell.KeyCtrlF):
if e.cursor < len(e.value) {
e.cursor++
}
- case ctrlKey(tcell.KeyCtrlA):
+ case key(tcell.KeyCtrlA),
+ ctrlKey(tcell.KeyCtrlA):
e.cursor = 0
- case ctrlKey(tcell.KeyCtrlE):
+ case key(tcell.KeyCtrlE),
+ ctrlKey(tcell.KeyCtrlE):
e.cursor = len(e.value)
- case ctrlKey(tcell.KeyCtrlK):
+ case key(tcell.KeyCtrlK),
+ ctrlKey(tcell.KeyCtrlK):
e.kill()
- case ctrlKey(tcell.KeyCtrlY):
+ case key(tcell.KeyCtrlY),
+ ctrlKey(tcell.KeyCtrlY):
e.yank()
default:
// Unknown key/combination, not handled