summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2018-04-12 17:39:28 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2018-04-12 17:42:48 +0900
commit7dbbbef51afe071f9a725cf7dccf4fb2aafd8e3f (patch)
tree3db3e3e3ac13db39ae22700fcd6c6891cdc3edd2 /src
parent7add75126d222be45281eb0d273d3e41a8cd103d (diff)
Add support for alt-{up,down,left,right} keys
Close #1234
Diffstat (limited to 'src')
-rw-r--r--src/options.go8
-rw-r--r--src/tui/light.go18
-rw-r--r--src/tui/tcell.go12
-rw-r--r--src/tui/tui.go5
4 files changed, 43 insertions, 0 deletions
diff --git a/src/options.go b/src/options.go
index bec4d32e..45eca5ef 100644
--- a/src/options.go
+++ b/src/options.go
@@ -410,6 +410,14 @@ func parseKeyChords(str string, message string) map[int]string {
chord = tui.AltSlash
case "alt-bs", "alt-bspace":
chord = tui.AltBS
+ case "alt-up":
+ chord = tui.AltUp
+ case "alt-down":
+ chord = tui.AltDown
+ case "alt-left":
+ chord = tui.AltLeft
+ case "alt-right":
+ chord = tui.AltRight
case "tab":
chord = tui.Tab
case "btab", "shift-tab":
diff --git a/src/tui/light.go b/src/tui/light.go
index 9b1489fa..7b474181 100644
--- a/src/tui/light.go
+++ b/src/tui/light.go
@@ -360,6 +360,11 @@ func (r *LightRenderer) escSequence(sz *int) Event {
if r.buffer[1] >= 1 && r.buffer[1] <= 'z'-'a'+1 {
return Event{int(CtrlAltA + r.buffer[1] - 1), 0, nil}
}
+ alt := false
+ if len(r.buffer) > 2 && r.buffer[1] == ESC {
+ r.buffer = r.buffer[1:]
+ alt = true
+ }
switch r.buffer[1] {
case 32:
return Event{AltSpace, 0, nil}
@@ -380,12 +385,25 @@ func (r *LightRenderer) escSequence(sz *int) Event {
*sz = 3
switch r.buffer[2] {
case 68:
+ if alt {
+ return Event{AltLeft, 0, nil}
+ }
return Event{Left, 0, nil}
case 67:
+ if alt {
+ // Ugh..
+ return Event{AltRight, 0, nil}
+ }
return Event{Right, 0, nil}
case 66:
+ if alt {
+ return Event{AltDown, 0, nil}
+ }
return Event{Down, 0, nil}
case 65:
+ if alt {
+ return Event{AltUp, 0, nil}
+ }
return Event{Up, 0, nil}
case 90:
return Event{BTab, 0, nil}
diff --git a/src/tui/tcell.go b/src/tui/tcell.go
index 8e5524ae..5f2b87fe 100644
--- a/src/tui/tcell.go
+++ b/src/tui/tcell.go
@@ -295,12 +295,24 @@ func (r *FullscreenRenderer) GetChar() Event {
return Event{BSpace, 0, nil}
case tcell.KeyUp:
+ if alt {
+ return Event{AltUp, 0, nil}
+ }
return Event{Up, 0, nil}
case tcell.KeyDown:
+ if alt {
+ return Event{AltDown, 0, nil}
+ }
return Event{Down, 0, nil}
case tcell.KeyLeft:
+ if alt {
+ return Event{AltLeft, 0, nil}
+ }
return Event{Left, 0, nil}
case tcell.KeyRight:
+ if alt {
+ return Event{AltRight, 0, nil}
+ }
return Event{Right, 0, nil}
case tcell.KeyHome:
diff --git a/src/tui/tui.go b/src/tui/tui.go
index e2f5ea58..f1fac5e3 100644
--- a/src/tui/tui.go
+++ b/src/tui/tui.go
@@ -85,6 +85,11 @@ const (
AltSlash
AltBS
+ AltUp
+ AltDown
+ AltLeft
+ AltRight
+
Alt0
)