From e1fb2830184a4ef244068e5f7020d2b14d927705 Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 13 Dec 2019 16:54:09 -0500 Subject: [PATCH] input: handle more sequences #134 --- include/notcurses.h | 14 ++++++++++++-- src/lib/input.c | 9 ++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/notcurses.h b/include/notcurses.h index 3f248b7ee..91efa9ea2 100644 --- a/include/notcurses.h +++ b/include/notcurses.h @@ -166,7 +166,7 @@ wchar_supppuab_p(wchar_t w){ #define NCKEY_LEFT suppuabize(5) #define NCKEY_INS suppuabize(6) #define NCKEY_DEL suppuabize(7) -#define NCKEY_BS suppuabize(8) // backspace (sometimes) +#define NCKEY_BACKSPACE suppuabize(8) // backspace (sometimes) #define NCKEY_PGDOWN suppuabize(9) #define NCKEY_PGUP suppuabize(10) #define NCKEY_HOME suppuabize(11) @@ -192,6 +192,14 @@ wchar_supppuab_p(wchar_t w){ #define NCKEY_F18 suppuabize(38) #define NCKEY_F19 suppuabize(39) #define NCKEY_F20 suppuabize(40) +// ... leave room for up to 100 function keys, egads +#define NCKEY_ENTER suppuabize(121) +#define NCKEY_CLS suppuabize(122) // "clear-screen or erase" +#define NCKEY_DLEFT suppuabize(123) // down + left on keypad +#define NCKEY_DRIGHT suppuabize(124) +#define NCKEY_ULEFT suppuabize(125) // up + left on keypad +#define NCKEY_URIGHT suppuabize(126) +#define NCKEY_CENTER suppuabize(127) // the most truly neutral of keypresses // See ppoll(2) for more detail. Provide a NULL 'ts' to block at lenghth, a 'ts' // of 0 for non-blocking operation, and otherwise a timespec to bound blocking. @@ -479,7 +487,9 @@ ncplane_putwstr_yx(struct ncplane* n, int y, int x, const wchar_t* gclustarr){ } // The ncplane equivalents of printf(3) and vprintf(3). -API int ncplane_printf(struct ncplane* n, const char* format, ...); +API int ncplane_printf(struct ncplane* n, const char* format, ...) + __attribute__ ((format (printf, 2, 3))); + API int ncplane_vprintf(struct ncplane* n, const char* format, va_list ap); static inline int diff --git a/src/lib/input.c b/src/lib/input.c index 9f8170d61..4ccf9e92a 100644 --- a/src/lib/input.c +++ b/src/lib/input.c @@ -224,7 +224,7 @@ int prep_special_keys(notcurses* nc){ { .tinfo = "kcuu1", .key = NCKEY_UP, }, { .tinfo = "kcud1", .key = NCKEY_DOWN, }, { .tinfo = "kdch1", .key = NCKEY_DEL, }, - { .tinfo = "kbs", .key = NCKEY_BS, }, + { .tinfo = "kbs", .key = NCKEY_BACKSPACE, }, { .tinfo = "kich1", .key = NCKEY_INS, }, { .tinfo = "kend", .key = NCKEY_END, }, { .tinfo = "khome", .key = NCKEY_HOME, }, @@ -251,6 +251,13 @@ int prep_special_keys(notcurses* nc){ { .tinfo = "kf18", .key = NCKEY_F18, }, { .tinfo = "kf19", .key = NCKEY_F19, }, { .tinfo = "kf20", .key = NCKEY_F20, }, + { .tinfo = "kent", .key = NCKEY_ENTER, }, + { .tinfo = "kclr", .key = NCKEY_CLS, }, + { .tinfo = "kc1", .key = NCKEY_DLEFT, }, + { .tinfo = "kc3", .key = NCKEY_DRIGHT, }, + { .tinfo = "ka1", .key = NCKEY_ULEFT, }, + { .tinfo = "ka3", .key = NCKEY_URIGHT, }, + { .tinfo = "kb2", .key = NCKEY_CENTER, }, { .tinfo = NULL, .key = NCKEY_INVALID, } }, *k; for(k = keys ; k->tinfo ; ++k){