Skip to content

Commit

Permalink
Enable C-n C-p for autocompletion menu as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
nsf committed Oct 8, 2012
1 parent 81a93e6 commit a88bc0d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Global keys:
M-/ - Local autocompletion mode

Extended mode:
C-c - Quit from godit
C-c - Quit from godit (cancel autocompletion)
C-a - Invoke autocompletion
C-x - Swap cursor and mark locations
C-s - Save file
S - Save file (raw)
Expand Down
5 changes: 4 additions & 1 deletion godit.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ func (g *godit) cursor_position() (int, int) {
func (g *godit) on_sys_key(ev *termbox.Event) {
switch ev.Key {
case termbox.KeyCtrlG:
v := g.active.leaf
v.ac = nil
g.set_overlay_mode(nil)
g.set_status("Quit")
case termbox.KeyF1:
Expand All @@ -434,6 +436,7 @@ func (g *godit) on_alt_key(ev *termbox.Event) bool {
}

func (g *godit) on_key(ev *termbox.Event) {
v := g.active.leaf
switch ev.Key {
case termbox.KeyCtrlX:
g.set_overlay_mode(init_extended_mode(g))
Expand All @@ -445,7 +448,7 @@ func (g *godit) on_key(ev *termbox.Event) {
if ev.Mod&termbox.ModAlt != 0 && g.on_alt_key(ev) {
break
}
g.active.leaf.on_key(ev)
v.on_key(ev)
}
}

Expand Down
8 changes: 2 additions & 6 deletions view.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,21 +1142,17 @@ func (v *view) on_key(ev *termbox.Event) {
v.on_vcommand(vcommand_move_cursor_forward, 0)
case termbox.KeyCtrlB, termbox.KeyArrowLeft:
v.on_vcommand(vcommand_move_cursor_backward, 0)
case termbox.KeyArrowDown:
case termbox.KeyCtrlN, termbox.KeyArrowDown:
if v.ac != nil {
v.on_vcommand(vcommand_autocompl_move_cursor_down, 0)
break
}
fallthrough
case termbox.KeyCtrlN:
v.on_vcommand(vcommand_move_cursor_next_line, 0)
case termbox.KeyArrowUp:
case termbox.KeyCtrlP, termbox.KeyArrowUp:
if v.ac != nil {
v.on_vcommand(vcommand_autocompl_move_cursor_up, 0)
break
}
fallthrough
case termbox.KeyCtrlP:
v.on_vcommand(vcommand_move_cursor_prev_line, 0)
case termbox.KeyCtrlE, termbox.KeyEnd:
v.on_vcommand(vcommand_move_cursor_end_of_line, 0)
Expand Down

0 comments on commit a88bc0d

Please sign in to comment.