diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-04-21 13:49:05 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-04-21 13:49:05 +0200 |
| commit | 0480a61dbc68949cabb10ff40cb7d79df7c193b5 (patch) | |
| tree | d99f35e5b8f3d09625dea55e99e1b761894e5141 | |
| parent | d90f2af57e1a26e3655e34ad03c14b6942b2c034 (diff) | |
| download | vis-0480a61dbc68949cabb10ff40cb7d79df7c193b5.tar.gz vis-0480a61dbc68949cabb10ff40cb7d79df7c193b5.tar.xz | |
vis: list usable symbolic keys in :help output
| -rw-r--r-- | vis-cmds.c | 77 |
1 files changed, 76 insertions, 1 deletions
@@ -1,5 +1,7 @@ /* this file is included from sam.c */ +#include <termkey.h> + #ifndef VIS_OPEN #define VIS_OPEN "vis-open" #endif @@ -549,6 +551,76 @@ static bool print_action(const char *key, void *value, void *data) { return text_appendf(txt, " %-30s\t%s\n", key, action->help); } +static void print_symbolic_keys(Vis *vis, Text *txt) { + static const int keys[] = { + TERMKEY_SYM_BACKSPACE, + TERMKEY_SYM_TAB, + TERMKEY_SYM_ENTER, + TERMKEY_SYM_ESCAPE, + //TERMKEY_SYM_SPACE, + TERMKEY_SYM_DEL, + TERMKEY_SYM_UP, + TERMKEY_SYM_DOWN, + TERMKEY_SYM_LEFT, + TERMKEY_SYM_RIGHT, + TERMKEY_SYM_BEGIN, + TERMKEY_SYM_FIND, + TERMKEY_SYM_INSERT, + TERMKEY_SYM_DELETE, + TERMKEY_SYM_SELECT, + TERMKEY_SYM_PAGEUP, + TERMKEY_SYM_PAGEDOWN, + TERMKEY_SYM_HOME, + TERMKEY_SYM_END, + TERMKEY_SYM_CANCEL, + TERMKEY_SYM_CLEAR, + TERMKEY_SYM_CLOSE, + TERMKEY_SYM_COMMAND, + TERMKEY_SYM_COPY, + TERMKEY_SYM_EXIT, + TERMKEY_SYM_HELP, + TERMKEY_SYM_MARK, + TERMKEY_SYM_MESSAGE, + TERMKEY_SYM_MOVE, + TERMKEY_SYM_OPEN, + TERMKEY_SYM_OPTIONS, + TERMKEY_SYM_PRINT, + TERMKEY_SYM_REDO, + TERMKEY_SYM_REFERENCE, + TERMKEY_SYM_REFRESH, + TERMKEY_SYM_REPLACE, + TERMKEY_SYM_RESTART, + TERMKEY_SYM_RESUME, + TERMKEY_SYM_SAVE, + TERMKEY_SYM_SUSPEND, + TERMKEY_SYM_UNDO, + TERMKEY_SYM_KP0, + TERMKEY_SYM_KP1, + TERMKEY_SYM_KP2, + TERMKEY_SYM_KP3, + TERMKEY_SYM_KP4, + TERMKEY_SYM_KP5, + TERMKEY_SYM_KP6, + TERMKEY_SYM_KP7, + TERMKEY_SYM_KP8, + TERMKEY_SYM_KP9, + TERMKEY_SYM_KPENTER, + TERMKEY_SYM_KPPLUS, + TERMKEY_SYM_KPMINUS, + TERMKEY_SYM_KPMULT, + TERMKEY_SYM_KPDIV, + TERMKEY_SYM_KPCOMMA, + TERMKEY_SYM_KPPERIOD, + TERMKEY_SYM_KPEQUALS, + }; + + TermKey *termkey = vis->ui->termkey_get(vis->ui); + text_appendf(txt, " ␣ (a literal \" \" space symbol must be used to refer to <Space>)\n"); + for (size_t i = 0; i < LENGTH(keys); i++) { + text_appendf(txt, " <%s>\n", termkey_get_keyname(termkey, keys[i])); + } +} + static bool cmd_help(Vis *vis, Win *win, Command *cmd, const char *argv[], Cursor *cur, Filerange *range) { if (!vis_window_new(vis, NULL)) return false; @@ -564,7 +636,6 @@ static bool cmd_help(Vis *vis, Win *win, Command *cmd, const char *argv[], Curso text_appendf(txt, " %-18s\t%s\n", mode->name, mode->help); } - if (!map_empty(vis->keymap)) { text_appendf(txt, "\n Layout specific mappings (affects all modes except INSERT/REPLACE)\n\n"); map_iterate(vis->keymap, print_keylayout, txt); @@ -582,6 +653,10 @@ static bool cmd_help(Vis *vis, Win *win, Command *cmd, const char *argv[], Curso text_appendf(txt, "\n Key binding actions\n\n"); map_iterate(vis->actions, print_action, txt); + text_appendf(txt, "\n Symbolic keys usable for key bindings " + "(prefix with C-, S-, and M- for Ctrl, Shift and Alt respectively)\n\n"); + print_symbolic_keys(vis, txt); + text_save(txt, NULL); return true; } |
