diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-05-09 13:13:00 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2019-05-09 13:13:00 +0000 |
commit | 9074802f9742dd97c54225d58edfc9f5573835ad (patch) | |
tree | 0e6f5404f66806000cac036d882658e669233da5 | |
parent | a7780b3c5224a348927ab1380f8973ab01a09ef4 (diff) |
send-keys also needs to insert key commands in the right order.
-rw-r--r-- | usr.bin/tmux/cmd-send-keys.c | 34 | ||||
-rw-r--r-- | usr.bin/tmux/key-bindings.c | 5 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 7 |
3 files changed, 25 insertions, 21 deletions
diff --git a/usr.bin/tmux/cmd-send-keys.c b/usr.bin/tmux/cmd-send-keys.c index 5ebc9ceff8f..02a1d2ffa42 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.46 2019/03/12 11:16:50 nicm Exp $ */ +/* $OpenBSD: cmd-send-keys.c,v 1.47 2019/05/09 13:12:59 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c index 79db69a2e3f..c484f2301c2 100644 --- a/usr.bin/tmux/key-bindings.c +++ b/usr.bin/tmux/key-bindings.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key-bindings.c,v 1.89 2019/04/29 06:55:21 nicm Exp $ */ +/* $OpenBSD: key-bindings.c,v 1.90 2019/05/09 13:12:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 61f36fb7720..98d1e0e66c1 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.891 2019/05/08 18:07:12 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.892 2019/05/09 13:12:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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 *); |