From 670ee761775bcca14214aa2e7b8aa8c01fe99e47 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 23 May 2019 04:44:48 -0700 Subject: Added key binding tool (ctrl-h) to figure out what a binding is --- keys.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'keys.h') diff --git a/keys.h b/keys.h index 702d367..25da8b5 100644 --- a/keys.h +++ b/keys.h @@ -204,4 +204,32 @@ int term_getkey(int fd, int *mouse_x, int *mouse_y, int timeout) return -1; } +const char *keyname(key) +{ + // TODO: currently only the keys I'm using are named + switch (key) { + case ' ': return "Space"; + case '\r': return "Enter"; + case KEY_ARROW_UP: return "Up"; + case KEY_ARROW_DOWN: return "Down"; + case KEY_ARROW_LEFT: return "Left"; + case KEY_ARROW_RIGHT: return "Right"; + case KEY_HOME: return "Home"; + case KEY_END: return "End"; + case KEY_DELETE: return "Delete"; + case KEY_ESC: return "Escape"; + case KEY_F5: return "F5"; + case KEY_CTRL_A: return "Ctrl-a"; + case KEY_CTRL_D: return "Ctrl-d"; + case KEY_CTRL_H: return "Ctrl-h"; + case KEY_CTRL_R: return "Ctrl-r"; + case KEY_CTRL_U: return "Ctrl-u"; + case KEY_PGDN: return "PgDn"; + case KEY_PGUP: return "PgUp"; + case KEY_MOUSE_WHEEL_DOWN: return "Scroll down"; + case KEY_MOUSE_WHEEL_UP: return "Scroll up"; + } + return NULL; +} + #endif -- cgit v1.2.3