diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-07-28 17:05:10 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-07-28 17:05:10 +0000 |
commit | f596be99505a0191cac9f314fb1b71528c5080b4 (patch) | |
tree | 1e765f4841da1107e11322d7ba62445f61ec67af /mode-key.c | |
parent | 9e5d585ba4b0af6badf559cc7b275a23be8947c2 (diff) | |
download | rtmux-f596be99505a0191cac9f314fb1b71528c5080b4.tar.gz rtmux-f596be99505a0191cac9f314fb1b71528c5080b4.tar.bz2 rtmux-f596be99505a0191cac9f314fb1b71528c5080b4.zip |
Final pieces of mode key rebinding: bind-key and unbind-key now accept a -t
argument to modify a table.
Diffstat (limited to 'mode-key.c')
-rw-r--r-- | mode-key.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -18,6 +18,8 @@ #include <sys/types.h> +#include <string.h> + #include "tmux.h" /* @@ -54,6 +56,8 @@ struct mode_key_cmdstr mode_key_cmdstr_edit[] = { { MODEKEYEDIT_STARTOFLINE, "start-of-line" }, { MODEKEYEDIT_SWITCHMODE, "switch-mode" }, { MODEKEYEDIT_SWITCHMODEAPPEND, "switch-mode-append" }, + + { 0, NULL } }; /* Choice keys command strings. */ @@ -64,6 +68,8 @@ struct mode_key_cmdstr mode_key_cmdstr_choice[] = { { MODEKEYCHOICE_PAGEDOWN, "page-down" }, { MODEKEYCHOICE_PAGEUP, "page-up" }, { MODEKEYCHOICE_UP, "up" }, + + { 0, NULL } }; /* Copy keys command strings. */ @@ -83,6 +89,8 @@ struct mode_key_cmdstr mode_key_cmdstr_copy[] = { { MODEKEYCOPY_STARTOFLINE, "start-of-line" }, { MODEKEYCOPY_STARTSELECTION, "begin-selection" }, { MODEKEYCOPY_UP, "cursor-up" }, + + { 0, NULL } }; /* vi editing keys. */ @@ -278,6 +286,28 @@ mode_key_tostring(struct mode_key_cmdstr *cmdstr, enum mode_key_cmd cmd) return (NULL); } +enum mode_key_cmd +mode_key_fromstring(struct mode_key_cmdstr *cmdstr, const char *name) +{ + for (; cmdstr->name != NULL; cmdstr++) { + if (strcasecmp(cmdstr->name, name) == 0) + return (cmdstr->cmd); + } + return (MODEKEY_NONE); +} + +const struct mode_key_table * +mode_key_findtable(const char *name) +{ + const struct mode_key_table *mtab; + + for (mtab = mode_key_tables; mtab->name != NULL; mtab++) { + if (strcasecmp(name, mtab->name) == 0) + return (mtab); + } + return (NULL); +} + void mode_key_init_trees(void) { |