summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-05-09 17:56:56 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-05-09 17:56:56 +0000
commit116e2c1675d1e17a91272533e109ab59165f48f9 (patch)
treeb88c8d435619f7b3a17d5727eb1d65dc8ed5cb1b /usr.bin/tmux
parenta17f94779358721f91a024cc3d9c834cd8f0dee4 (diff)
If the target pane for send-keys in in a mode with a key table (that is,
copy mode), then look the key up in the table and fire any command instead of delivering the key to the pane directly where it will be ignored. This makes C-b C-b (send-prefix) work in copy mode again.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/cmd-send-keys.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/usr.bin/tmux/cmd-send-keys.c b/usr.bin/tmux/cmd-send-keys.c
index 4b46c45e10c..ed67e678155 100644
--- a/usr.bin/tmux/cmd-send-keys.c
+++ b/usr.bin/tmux/cmd-send-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-send-keys.c,v 1.39 2017/04/22 10:22:39 nicm Exp $ */
+/* $OpenBSD: cmd-send-keys.c,v 1.40 2017/05/09 17:56:55 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -55,6 +55,29 @@ const struct cmd_entry cmd_send_prefix_entry = {
.exec = cmd_send_keys_exec
};
+static void
+cmd_send_keys_inject(struct client *c, struct cmdq_item *item, key_code key)
+{
+ struct window_pane *wp = item->target.wp;
+ struct session *s = item->target.s;
+ struct key_table *table;
+ struct key_binding *bd, bd_find;
+
+ if (wp->mode == NULL || wp->mode->key_table == NULL) {
+ window_pane_key(wp, NULL, s, key, NULL);
+ return;
+ }
+ table = key_bindings_get_table(wp->mode->key_table(wp), 1);
+
+ bd_find.key = (key & ~KEYC_XTERM);
+ bd = RB_FIND(key_bindings, &table->key_bindings, &bd_find);
+ if (bd != NULL) {
+ table->references++;
+ key_bindings_dispatch(bd, c, NULL, &item->target);
+ key_bindings_unref_table(table);
+ }
+}
+
static enum cmd_retval
cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
{
@@ -108,7 +131,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
key = options_get_number(s->options, "prefix2");
else
key = options_get_number(s->options, "prefix");
- window_pane_key(wp, NULL, s, key, NULL);
+ cmd_send_keys_inject(c, item, key);
return (CMD_RETURN_NORMAL);
}
@@ -123,7 +146,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
if (!literal) {
key = key_string_lookup_string(args->argv[i]);
if (key != KEYC_NONE && key != KEYC_UNKNOWN)
- window_pane_key(wp, NULL, s, key, NULL);
+ cmd_send_keys_inject(c, item, key);
else
literal = 1;
}
@@ -132,7 +155,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
for (uc = ud; uc->size != 0; uc++) {
if (utf8_combine(uc, &wc) != UTF8_DONE)
continue;
- window_pane_key(wp, NULL, s, wc, NULL);
+ cmd_send_keys_inject(c, item, wc);
}
free(ud);
}