diff options
author | nicm <nicm> | 2015-04-20 15:34:56 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-04-20 15:34:56 +0000 |
commit | bded7437064c76dd6cf4e76e558d826859adcc79 (patch) | |
tree | 708c5dee6ddf671161b5ffa7208cba05e52eb4c5 /cmd-switch-client.c | |
parent | 3497843f0272e573d0a63cb6e94948591ae07667 (diff) | |
download | rtmux-bded7437064c76dd6cf4e76e558d826859adcc79.tar.gz rtmux-bded7437064c76dd6cf4e76e558d826859adcc79.tar.bz2 rtmux-bded7437064c76dd6cf4e76e558d826859adcc79.zip |
Support for multiple key tables to commands to be bound to sequences of
keys. The default key bindings become the "prefix" table and -n the
"root" table. Keys may be bound in new tables with bind -T and
switch-client -T used to specify the table in which the next key should
be looked up. Based on a diff from Keith Amling.
Diffstat (limited to 'cmd-switch-client.c')
-rw-r--r-- | cmd-switch-client.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/cmd-switch-client.c b/cmd-switch-client.c index 439f593b..8c4daf97 100644 --- a/cmd-switch-client.c +++ b/cmd-switch-client.c @@ -31,8 +31,8 @@ enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_q *); const struct cmd_entry cmd_switch_client_entry = { "switch-client", "switchc", - "lc:npt:r", 0, 0, - "[-lnpr] [-c target-client] [-t target-session]", + "lc:npt:rT:", 0, 0, + "[-lnpr] [-c target-client] [-t target-session] [-T key-table]", CMD_READONLY, cmd_switch_client_exec }; @@ -46,7 +46,8 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) struct winlink *wl = NULL; struct window *w = NULL; struct window_pane *wp = NULL; - const char *tflag; + const char *tflag, *tablename; + struct key_table *table; if ((c = cmd_find_client(cmdq, args_get(args, 'c'), 0)) == NULL) return (CMD_RETURN_ERROR); @@ -58,6 +59,18 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) c->flags |= CLIENT_READONLY; } + tablename = args_get(args, 'T'); + if (tablename != NULL) { + table = key_bindings_get_table(tablename, 0); + if (table == NULL) { + cmdq_error(cmdq, "table %s doesn't exist", tablename); + return (CMD_RETURN_ERROR); + } + table->references++; + key_bindings_unref_table(c->keytable); + c->keytable = table; + } + tflag = args_get(args, 't'); if (args_has(args, 'n')) { if ((s = session_next_session(c->session)) == NULL) { |