aboutsummaryrefslogtreecommitdiff
path: root/mode-key.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-07-28 23:19:06 +0000
committerTiago Cunha <tcunha@gmx.com>2009-07-28 23:19:06 +0000
commit522fc94d12753466dd5351918642114bbc475e35 (patch)
treeda2c829f9317cd22553241a5d5c7e54bb5ce761d /mode-key.c
parentdeaba448353857d6520e13246c4ea9445af9bbb3 (diff)
downloadrtmux-522fc94d12753466dd5351918642114bbc475e35.tar.gz
rtmux-522fc94d12753466dd5351918642114bbc475e35.tar.bz2
rtmux-522fc94d12753466dd5351918642114bbc475e35.zip
Sync OpenBSD patchset 194:
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.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/mode-key.c b/mode-key.c
index 33c60cff..4be32fbd 100644
--- a/mode-key.c
+++ b/mode-key.c
@@ -1,4 +1,4 @@
-/* $Id: mode-key.c,v 1.21 2009-07-28 23:11:18 tcunha Exp $ */
+/* $Id: mode-key.c,v 1.22 2009-07-28 23:19:06 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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)
{