add cursor key bindings

This commit is contained in:
Gokcehan 2016-08-13 21:37:09 +03:00
parent bdee73bc54
commit 84cf8e12c3
3 changed files with 17 additions and 5 deletions

View File

@ -2,10 +2,10 @@
## Keys ## Keys
down (default "j") up (default "k" and "<up>")
up (default "k") down (default "j" and "<down>")
updir (default "h") updir (default "h" and "<left>")
open (default "l") open (default "l" and "<right>")
quit (default "q") quit (default "q")
bot (default "G") bot (default "G")
top (default "gg") top (default "gg")

View File

@ -29,10 +29,14 @@ func init() {
gOpts.keys = make(map[string]Expr) gOpts.keys = make(map[string]Expr)
gOpts.keys["j"] = &CallExpr{"down", nil}
gOpts.keys["k"] = &CallExpr{"up", nil} gOpts.keys["k"] = &CallExpr{"up", nil}
gOpts.keys["<up>"] = &CallExpr{"up", nil}
gOpts.keys["j"] = &CallExpr{"down", nil}
gOpts.keys["<down>"] = &CallExpr{"down", nil}
gOpts.keys["h"] = &CallExpr{"updir", nil} gOpts.keys["h"] = &CallExpr{"updir", nil}
gOpts.keys["<left>"] = &CallExpr{"updir", nil}
gOpts.keys["l"] = &CallExpr{"open", nil} gOpts.keys["l"] = &CallExpr{"open", nil}
gOpts.keys["<right>"] = &CallExpr{"open", nil}
gOpts.keys["q"] = &CallExpr{"quit", nil} gOpts.keys["q"] = &CallExpr{"quit", nil}
gOpts.keys["G"] = &CallExpr{"bot", nil} gOpts.keys["G"] = &CallExpr{"bot", nil}
gOpts.keys["gg"] = &CallExpr{"top", nil} gOpts.keys["gg"] = &CallExpr{"top", nil}

8
ui.go
View File

@ -360,6 +360,14 @@ func (ui *UI) getExpr() Expr {
acc = append(acc, '<', 'b', 's', '2', '>') acc = append(acc, '<', 'b', 's', '2', '>')
case termbox.KeyTab: case termbox.KeyTab:
acc = append(acc, '<', 't', 'a', 'b', '>') acc = append(acc, '<', 't', 'a', 'b', '>')
case termbox.KeyArrowUp:
acc = append(acc, '<', 'u', 'p', '>')
case termbox.KeyArrowDown:
acc = append(acc, '<', 'd', 'o', 'w', 'n', '>')
case termbox.KeyArrowLeft:
acc = append(acc, '<', 'l', 'e', 'f', 't', '>')
case termbox.KeyArrowRight:
acc = append(acc, '<', 'r', 'i', 'g', 'h', 't', '>')
case termbox.KeyCtrlL: case termbox.KeyCtrlL:
acc = append(acc, '<', 'c', '-', 'l', '>') acc = append(acc, '<', 'c', '-', 'l', '>')
case termbox.KeyEsc: case termbox.KeyEsc: