summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2019-05-09 13:12:59 +0000
committernicm <nicm>2019-05-09 13:12:59 +0000
commit21d97504505f2310c5d065e06d3c550d7b5d9f89 (patch)
tree066bce6c32d07a9470dea9949a5a6d2a0e1cc882
parent3c68e51609d35189e46d9b14c2a489a5ca3de67e (diff)
send-keys also needs to insert key commands in the right order.
-rw-r--r--cmd-send-keys.c32
-rw-r--r--key-bindings.c3
-rw-r--r--tmux.h5
3 files changed, 22 insertions, 18 deletions
diff --git a/cmd-send-keys.c b/cmd-send-keys.c
index d9c39f63..814755f3 100644
--- a/cmd-send-keys.c
+++ b/cmd-send-keys.c
@@ -55,31 +55,30 @@ 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)
+static struct cmdq_item *
+cmd_send_keys_inject(struct client *c, struct cmd_find_state *fs,
+ struct cmdq_item *item, key_code key)
{
- struct window_pane *wp = item->target.wp;
- struct session *s = item->target.s;
- struct winlink *wl = item->target.wl;
struct window_mode_entry *wme;
struct key_table *table;
struct key_binding *bd;
- wme = TAILQ_FIRST(&wp->modes);
+ wme = TAILQ_FIRST(&fs->wp->modes);
if (wme == NULL || wme->mode->key_table == NULL) {
- if (options_get_number(wp->window->options, "xterm-keys"))
+ if (options_get_number(fs->wp->window->options, "xterm-keys"))
key |= KEYC_XTERM;
- window_pane_key(wp, NULL, s, wl, key, NULL);
- return;
+ window_pane_key(fs->wp, NULL, fs->s, fs->wl, key, NULL);
+ return (item);
}
table = key_bindings_get_table(wme->mode->key_table(wme), 1);
bd = key_bindings_get(table, key & ~KEYC_XTERM);
if (bd != NULL) {
table->references++;
- key_bindings_dispatch(bd, item, c, NULL, &item->target);
+ item = key_bindings_dispatch(bd, item, c, NULL, &item->target);
key_bindings_unref_table(table);
}
+ return (item);
}
static enum cmd_retval
@@ -91,6 +90,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
struct session *s = item->target.s;
struct winlink *wl = item->target.wl;
struct mouse_event *m = &item->shared->mouse;
+ struct cmd_find_state *fs = &item->target;
struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes);
struct utf8_data *ud, *uc;
wchar_t wc;
@@ -141,7 +141,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");
- cmd_send_keys_inject(c, item, key);
+ cmd_send_keys_inject(c, fs, item, key);
return (CMD_RETURN_NORMAL);
}
@@ -155,9 +155,10 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
literal = args_has(args, 'l');
if (!literal) {
key = key_string_lookup_string(args->argv[i]);
- if (key != KEYC_NONE && key != KEYC_UNKNOWN)
- cmd_send_keys_inject(c, item, key);
- else
+ if (key != KEYC_NONE && key != KEYC_UNKNOWN) {
+ item = cmd_send_keys_inject(c, fs, item,
+ key);
+ } else
literal = 1;
}
if (literal) {
@@ -165,7 +166,8 @@ 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;
- cmd_send_keys_inject(c, item, wc);
+ item = cmd_send_keys_inject(c, fs, item,
+ wc);
}
free(ud);
}
diff --git a/key-bindings.c b/key-bindings.c
index 5af8f3ed..4d5f7278 100644
--- a/key-bindings.c
+++ b/key-bindings.c
@@ -448,7 +448,7 @@ key_bindings_read_only(struct cmdq_item *item, __unused void *data)
return (CMD_RETURN_ERROR);
}
-void
+struct cmdq_item *
key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item,
struct client *c, struct mouse_event *m, struct cmd_find_state *fs)
{
@@ -472,4 +472,5 @@ key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item,
cmdq_insert_after(item, new_item);
else
cmdq_append(c, new_item);
+ return (new_item);
}
diff --git a/tmux.h b/tmux.h
index 39b77341..955643d8 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2000,8 +2000,9 @@ void key_bindings_add(const char *, key_code, int, struct cmd_list *);
void key_bindings_remove(const char *, key_code);
void key_bindings_remove_table(const char *);
void key_bindings_init(void);
-void key_bindings_dispatch(struct key_binding *, struct cmdq_item *,
- struct client *, struct mouse_event *, struct cmd_find_state *);
+struct cmdq_item *key_bindings_dispatch(struct key_binding *,
+ struct cmdq_item *, struct client *, struct mouse_event *,
+ struct cmd_find_state *);
/* key-string.c */
key_code key_string_lookup_string(const char *);