From 142f58a35adc20b131a5b7280121d080d9c83b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 9 Jul 2015 16:21:17 +0200 Subject: ui: abstract curses related special keys away --- config.def.h | 12 ++++++------ ui-curses.c | 1 - ui-curses.h | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/config.def.h b/config.def.h index 658a156..916831e 100644 --- a/config.def.h +++ b/config.def.h @@ -2,7 +2,7 @@ /* macros used to specify keys for key bindings */ #define ESC 0x1B #define NONE(k) { .str = { k }, .code = 0 } -#define KEY(k) { .str = { '\0' }, .code = KEY_##k } +#define KEY(k) { .str = { '\0' }, .code = UI_KEY_##k } #define CONTROL(k) NONE((k)&0x1F) #define META(k) { .str = { ESC, (k) }, .code = 0 } @@ -80,13 +80,13 @@ static bool vis_keypress(Key *key) { static KeyBinding basic_movement[] = { { { CONTROL('Z') }, suspend, { NULL } }, { { KEY(LEFT) }, movement, { .i = MOVE_CHAR_PREV } }, - { { KEY(SLEFT) }, movement, { .i = MOVE_LONGWORD_START_PREV } }, + { { KEY(SHIFT_LEFT) }, movement, { .i = MOVE_LONGWORD_START_PREV } }, { { KEY(RIGHT) }, movement, { .i = MOVE_CHAR_NEXT } }, - { { KEY(SRIGHT) }, movement, { .i = MOVE_LONGWORD_START_NEXT } }, + { { KEY(SHIFT_RIGHT) }, movement, { .i = MOVE_LONGWORD_START_NEXT } }, { { KEY(UP) }, movement, { .i = MOVE_LINE_UP } }, { { KEY(DOWN) }, movement, { .i = MOVE_LINE_DOWN } }, - { { KEY(PPAGE) }, wscroll, { .i = -PAGE } }, - { { KEY(NPAGE) }, wscroll, { .i = +PAGE } }, + { { KEY(PAGE_UP) }, wscroll, { .i = -PAGE } }, + { { KEY(PAGE_DOWN) }, wscroll, { .i = +PAGE } }, { { KEY(HOME) }, movement, { .i = MOVE_LINE_START } }, { { KEY(END) }, movement, { .i = MOVE_LINE_FINISH } }, { /* empty last element, array terminator */ }, @@ -420,7 +420,7 @@ static KeyBinding vis_mode_normal[] = { static KeyBinding vis_mode_visual[] = { { { KEY(BACKSPACE) }, operator, { .i = OP_DELETE } }, - { { KEY(DC) }, operator, { .i = OP_DELETE } }, + { { KEY(DELETE) }, operator, { .i = OP_DELETE } }, { { NONE(ESC) }, switchmode, { .i = VIS_MODE_NORMAL } }, { { CONTROL('c') }, switchmode, { .i = VIS_MODE_NORMAL } }, { { NONE('v') }, switchmode, { .i = VIS_MODE_NORMAL } }, diff --git a/ui-curses.c b/ui-curses.c index a57ab8f..2473521 100644 --- a/ui-curses.c +++ b/ui-curses.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #include diff --git a/ui-curses.h b/ui-curses.h index 74cb920..0509f25 100644 --- a/ui-curses.h +++ b/ui-curses.h @@ -1,8 +1,25 @@ #ifndef UI_CURSES_H #define UI_CURSES_H +#include #include "ui.h" +enum { + UI_KEY_DOWN = KEY_DOWN, + UI_KEY_UP = KEY_UP, + UI_KEY_LEFT = KEY_LEFT, + UI_KEY_RIGHT = KEY_RIGHT, + UI_KEY_HOME = KEY_HOME, + UI_KEY_BACKSPACE = KEY_BACKSPACE, + 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, +}; + Ui *ui_curses_new(void); void ui_curses_free(Ui*); -- cgit v1.2.3