mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 01:48:47 +00:00
send-keys also needs to insert key commands in the right order.
This commit is contained in:
parent
3c68e51609
commit
21d9750450
@ -55,31 +55,30 @@ const struct cmd_entry cmd_send_prefix_entry = {
|
|||||||
.exec = cmd_send_keys_exec
|
.exec = cmd_send_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static struct cmdq_item *
|
||||||
cmd_send_keys_inject(struct client *c, struct cmdq_item *item, key_code key)
|
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 window_mode_entry *wme;
|
||||||
struct key_table *table;
|
struct key_table *table;
|
||||||
struct key_binding *bd;
|
struct key_binding *bd;
|
||||||
|
|
||||||
wme = TAILQ_FIRST(&wp->modes);
|
wme = TAILQ_FIRST(&fs->wp->modes);
|
||||||
if (wme == NULL || wme->mode->key_table == NULL) {
|
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;
|
key |= KEYC_XTERM;
|
||||||
window_pane_key(wp, NULL, s, wl, key, NULL);
|
window_pane_key(fs->wp, NULL, fs->s, fs->wl, key, NULL);
|
||||||
return;
|
return (item);
|
||||||
}
|
}
|
||||||
table = key_bindings_get_table(wme->mode->key_table(wme), 1);
|
table = key_bindings_get_table(wme->mode->key_table(wme), 1);
|
||||||
|
|
||||||
bd = key_bindings_get(table, key & ~KEYC_XTERM);
|
bd = key_bindings_get(table, key & ~KEYC_XTERM);
|
||||||
if (bd != NULL) {
|
if (bd != NULL) {
|
||||||
table->references++;
|
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);
|
key_bindings_unref_table(table);
|
||||||
}
|
}
|
||||||
|
return (item);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
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 session *s = item->target.s;
|
||||||
struct winlink *wl = item->target.wl;
|
struct winlink *wl = item->target.wl;
|
||||||
struct mouse_event *m = &item->shared->mouse;
|
struct mouse_event *m = &item->shared->mouse;
|
||||||
|
struct cmd_find_state *fs = &item->target;
|
||||||
struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes);
|
struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes);
|
||||||
struct utf8_data *ud, *uc;
|
struct utf8_data *ud, *uc;
|
||||||
wchar_t wc;
|
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");
|
key = options_get_number(s->options, "prefix2");
|
||||||
else
|
else
|
||||||
key = options_get_number(s->options, "prefix");
|
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);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,9 +155,10 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
literal = args_has(args, 'l');
|
literal = args_has(args, 'l');
|
||||||
if (!literal) {
|
if (!literal) {
|
||||||
key = key_string_lookup_string(args->argv[i]);
|
key = key_string_lookup_string(args->argv[i]);
|
||||||
if (key != KEYC_NONE && key != KEYC_UNKNOWN)
|
if (key != KEYC_NONE && key != KEYC_UNKNOWN) {
|
||||||
cmd_send_keys_inject(c, item, key);
|
item = cmd_send_keys_inject(c, fs, item,
|
||||||
else
|
key);
|
||||||
|
} else
|
||||||
literal = 1;
|
literal = 1;
|
||||||
}
|
}
|
||||||
if (literal) {
|
if (literal) {
|
||||||
@ -165,7 +166,8 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
for (uc = ud; uc->size != 0; uc++) {
|
for (uc = ud; uc->size != 0; uc++) {
|
||||||
if (utf8_combine(uc, &wc) != UTF8_DONE)
|
if (utf8_combine(uc, &wc) != UTF8_DONE)
|
||||||
continue;
|
continue;
|
||||||
cmd_send_keys_inject(c, item, wc);
|
item = cmd_send_keys_inject(c, fs, item,
|
||||||
|
wc);
|
||||||
}
|
}
|
||||||
free(ud);
|
free(ud);
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ key_bindings_read_only(struct cmdq_item *item, __unused void *data)
|
|||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
struct cmdq_item *
|
||||||
key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item,
|
key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item,
|
||||||
struct client *c, struct mouse_event *m, struct cmd_find_state *fs)
|
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);
|
cmdq_insert_after(item, new_item);
|
||||||
else
|
else
|
||||||
cmdq_append(c, new_item);
|
cmdq_append(c, new_item);
|
||||||
|
return (new_item);
|
||||||
}
|
}
|
||||||
|
5
tmux.h
5
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(const char *, key_code);
|
||||||
void key_bindings_remove_table(const char *);
|
void key_bindings_remove_table(const char *);
|
||||||
void key_bindings_init(void);
|
void key_bindings_init(void);
|
||||||
void key_bindings_dispatch(struct key_binding *, struct cmdq_item *,
|
struct cmdq_item *key_bindings_dispatch(struct key_binding *,
|
||||||
struct client *, struct mouse_event *, struct cmd_find_state *);
|
struct cmdq_item *, struct client *, struct mouse_event *,
|
||||||
|
struct cmd_find_state *);
|
||||||
|
|
||||||
/* key-string.c */
|
/* key-string.c */
|
||||||
key_code key_string_lookup_string(const char *);
|
key_code key_string_lookup_string(const char *);
|
||||||
|
Loading…
Reference in New Issue
Block a user