vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 24a9d34d01c90ea30ff24c2c806d8810929645a7 parent 8314cac31713670ca55351304dec9380f013888f Author: Marc André Tanner <mat@brain-dump.org> Date: Sun, 6 Sep 2015 23:21:15 +0200 ui: differentiate between Ctrl-J and enter Thus enter no longer creates new cursors, use CTRL-j instead. Closes #69 Diffstat:
| M | config.def.h | | | 6 | ++++-- |
| M | ui-curses.c | | | 1 | + |
| M | ui-curses.h | | | 1 | - |
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h @@ -104,7 +104,8 @@ static KeyBinding vis_movements[] = { { { NONE('j') }, movement, { .i = MOVE_LINE_DOWN } }, { { CONTROL('J') }, movement, { .i = MOVE_LINE_DOWN } }, { { CONTROL('N') }, movement, { .i = MOVE_LINE_DOWN } }, - { { KEY(ENTER) }, movement, { .i = MOVE_LINE_DOWN } }, + { { NONE('\n') }, movement, { .i = MOVE_LINE_DOWN } }, + { { NONE('\r') }, movement, { .i = MOVE_LINE_DOWN } }, { { NONE('g'), NONE('j') }, movement, { .i = MOVE_SCREEN_LINE_DOWN } }, { { NONE('g'), KEY(DOWN) }, movement, { .i = MOVE_SCREEN_LINE_DOWN } }, { { NONE('^') }, movement, { .i = MOVE_LINE_START } }, @@ -513,7 +514,8 @@ static KeyBinding vis_mode_readline[] = { static KeyBinding vis_mode_prompt[] = { { { KEY(BACKSPACE) }, prompt_backspace,{ .s = NULL } }, - { { KEY(ENTER) }, prompt_enter, { NULL } }, + { { NONE('\n') }, prompt_enter, { NULL } }, + { { NONE('\r') }, prompt_enter, { NULL } }, { { CONTROL('J') }, prompt_enter, { NULL } }, { { KEY(UP) }, prompt_up, { NULL } }, { { KEY(DOWN) }, prompt_down, { NULL } }, diff --git a/ui-curses.c b/ui-curses.c @@ -597,6 +597,7 @@ Ui *ui_curses_new(Color *colors) { use_default_colors(); raw(); noecho(); + nonl(); keypad(stdscr, TRUE); meta(stdscr, TRUE); curs_set(0); diff --git a/ui-curses.h b/ui-curses.h @@ -15,7 +15,6 @@ enum { UI_KEY_DELETE = KEY_DC, UI_KEY_PAGE_DOWN = KEY_NPAGE, UI_KEY_PAGE_UP = KEY_PPAGE, - UI_KEY_ENTER = KEY_ENTER, UI_KEY_END = KEY_END, UI_KEY_SHIFT_LEFT = KEY_SLEFT, UI_KEY_SHIFT_RIGHT = KEY_SRIGHT,