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
down (default "j")
up (default "k")
updir (default "h")
open (default "l")
up (default "k" and "<up>")
down (default "j" and "<down>")
updir (default "h" and "<left>")
open (default "l" and "<right>")
quit (default "q")
bot (default "G")
top (default "gg")

View File

@ -29,10 +29,14 @@ func init() {
gOpts.keys = make(map[string]Expr)
gOpts.keys["j"] = &CallExpr{"down", 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["<left>"] = &CallExpr{"updir", nil}
gOpts.keys["l"] = &CallExpr{"open", nil}
gOpts.keys["<right>"] = &CallExpr{"open", nil}
gOpts.keys["q"] = &CallExpr{"quit", nil}
gOpts.keys["G"] = &CallExpr{"bot", 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', '>')
case termbox.KeyTab:
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:
acc = append(acc, '<', 'c', '-', 'l', '>')
case termbox.KeyEsc: