From adb76fd1ce8753a958d4ffe14db724f9f4d674ea Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 13 Apr 2020 14:46:04 +0000 Subject: [PATCH] Move cmdq_state into cmd-queue.c. --- cmd-attach-session.c | 5 ++--- cmd-break-pane.c | 3 +-- cmd-copy-mode.c | 6 +++--- cmd-display-menu.c | 14 ++++++------- cmd-find.c | 6 +++--- cmd-if-shell.c | 14 ++++++------- cmd-join-pane.c | 3 +-- cmd-new-session.c | 5 ++--- cmd-new-window.c | 3 +-- cmd-queue.c | 48 +++++++++++++++++++++++++++++++++++--------- cmd-resize-pane.c | 6 +++--- cmd-rotate-window.c | 3 +-- cmd-select-pane.c | 3 +-- cmd-select-window.c | 3 +-- cmd-send-keys.c | 4 ++-- cmd-split-window.c | 3 +-- cmd-switch-client.c | 5 ++--- control.c | 4 ++-- format.c | 7 ++----- key-bindings.c | 8 ++++---- menu.c | 6 +++--- popup.c | 6 +++--- server-client.c | 2 +- tmux.h | 21 +++++++------------ 24 files changed, 99 insertions(+), 89 deletions(-) diff --git a/cmd-attach-session.c b/cmd-attach-session.c index 00a852fc..8c30c767 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -50,8 +50,7 @@ enum cmd_retval cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag, int xflag, int rflag, const char *cflag, int Eflag) { - struct cmdq_state *state = cmdq_get_state(item); - struct cmd_find_state *current = &state->current; + struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state target; enum cmd_find_type type; int flags; @@ -120,7 +119,7 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag, environ_update(s->options, c->environ, s->environ); c->session = s; - if (~state->flags & CMDQ_STATE_REPEAT) + if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT) server_client_set_key_table(c, NULL); tty_update_client_offset(c); status_timer_start(c); diff --git a/cmd-break-pane.c b/cmd-break-pane.c index 1d0ad2ce..e12b09b6 100644 --- a/cmd-break-pane.c +++ b/cmd-break-pane.c @@ -49,8 +49,7 @@ static enum cmd_retval cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); - struct cmd_find_state *current = &state->current; + struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *source = cmdq_get_source(item); struct client *c = cmd_find_client(item, NULL, 1); diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c index 01006e5b..d8b4fd3e 100644 --- a/cmd-copy-mode.c +++ b/cmd-copy-mode.c @@ -57,7 +57,7 @@ static enum cmd_retval cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); + struct key_event *event = cmdq_get_event(item); struct cmd_find_state *source = cmdq_get_source(item); struct cmd_find_state *target = cmdq_get_target(item); struct client *c = cmdq_get_client(item); @@ -70,7 +70,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item) } if (args_has(args, 'M')) { - if ((wp = cmd_mouse_pane(&state->event.m, &s, NULL)) == NULL) + if ((wp = cmd_mouse_pane(&event->m, &s, NULL)) == NULL) return (CMD_RETURN_NORMAL); if (c == NULL || c->session != s) return (CMD_RETURN_NORMAL); @@ -87,7 +87,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item) swp = wp; if (!window_pane_set_mode(wp, swp, &window_copy_mode, NULL, args)) { if (args_has(args, 'M')) - window_copy_start_drag(c, &state->event.m); + window_copy_start_drag(c, &event->m); } if (args_has(args, 'u')) window_copy_pageup(wp, 0); diff --git a/cmd-display-menu.c b/cmd-display-menu.c index df8e0329..830491dc 100644 --- a/cmd-display-menu.c +++ b/cmd-display-menu.c @@ -65,8 +65,8 @@ static void cmd_display_menu_get_position(struct client *c, struct cmdq_item *item, struct args *args, u_int *px, u_int *py, u_int w, u_int h) { - struct cmdq_state *state = cmdq_get_state(item); struct cmd_find_state *target = cmdq_get_target(item); + struct key_event *event = cmdq_get_event(item); struct session *s = c->session; struct winlink *wl = target->wl; struct window_pane *wp = target->wp; @@ -100,8 +100,8 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item, else *px = 0; } else if (strcmp(xp, "M") == 0) { - if (state->event.m.valid && state->event.m.x > w / 2) - *px = state->event.m.x - w / 2; + if (event->m.valid && event->m.x > w / 2) + *px = event->m.x - w / 2; else *px = 0; } else if (strcmp(xp, "W") == 0) { @@ -134,8 +134,8 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item, else *py = 0; } else if (strcmp(yp, "M") == 0) { - if (state->event.m.valid) - *py = state->event.m.y + h; + if (event->m.valid) + *py = event->m.y + h; else *py = 0; } else if (strcmp(yp, "S") == 0) { @@ -176,8 +176,8 @@ static enum cmd_retval cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); struct cmd_find_state *target = cmdq_get_target(item); + struct key_event *event = cmdq_get_event(item); struct client *c; struct menu *menu = NULL; struct menu_item menu_item; @@ -230,7 +230,7 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item) cmd_display_menu_get_position(c, item, args, &px, &py, menu->width + 4, menu->count + 2); - if (!state->event.m.valid) + if (!event->m.valid) flags |= MENU_NOMOUSE; if (menu_display(menu, flags, item, px, py, c, target, NULL, NULL) != 0) return (CMD_RETURN_NORMAL); diff --git a/cmd-find.c b/cmd-find.c index a063f115..9c8bcbc1 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -961,8 +961,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item, if (server_check_marked() && (flags & CMD_FIND_DEFAULT_MARKED)) { fs->current = &marked_pane; log_debug("%s: current is marked pane", __func__); - } else if (cmd_find_valid_state(&cmdq_get_state(item)->current)) { - fs->current = &cmdq_get_state(item)->current; + } else if (cmd_find_valid_state(cmdq_get_current(item))) { + fs->current = cmdq_get_current(item); log_debug("%s: current is from queue", __func__); } else if (cmd_find_from_client(¤t, cmdq_get_client(item), flags) == 0) { @@ -982,7 +982,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item, /* Mouse target is a plain = or {mouse}. */ if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) { - m = &cmdq_get_state(item)->event.m; + m = &cmdq_get_event(item)->m; switch (type) { case CMD_FIND_PANE: fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl); diff --git a/cmd-if-shell.c b/cmd-if-shell.c index 4210392e..3657c730 100644 --- a/cmd-if-shell.c +++ b/cmd-if-shell.c @@ -56,16 +56,15 @@ struct cmd_if_shell_data { struct client *client; struct cmdq_item *item; - struct mouse_event mouse; + struct key_event event; }; static enum cmd_retval cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); struct cmd_find_state *target = cmdq_get_target(item); - struct mouse_event *m = &state->event.m; + struct key_event *event = cmdq_get_event(item); struct cmd_if_shell_data *cdata; char *shellcmd, *cmd; const char *file; @@ -102,7 +101,8 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item) free(pr->error); return (CMD_RETURN_ERROR); case CMD_PARSE_SUCCESS: - new_item = cmdq_get_command(pr->cmdlist, target, m, 0); + new_item = cmdq_get_command(pr->cmdlist, target, event, + 0); cmdq_insert_after(item, new_item); cmd_list_free(pr->cmdlist); break; @@ -117,7 +117,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item) cdata->cmd_else = xstrdup(args->argv[2]); else cdata->cmd_else = NULL; - memcpy(&cdata->mouse, m, sizeof cdata->mouse); + memcpy(&cdata->event, event, sizeof cdata->event); if (!args_has(args, 'b')) cdata->client = cmdq_get_client(item); @@ -161,7 +161,7 @@ cmd_if_shell_callback(struct job *job) { struct cmd_if_shell_data *cdata = job_get_data(job); struct client *c = cdata->client; - struct mouse_event *m = &cdata->mouse; + struct key_event *event = &cdata->event; struct cmdq_item *new_item = NULL; char *cmd; int status; @@ -185,7 +185,7 @@ cmd_if_shell_callback(struct job *job) free(pr->error); break; case CMD_PARSE_SUCCESS: - new_item = cmdq_get_command(pr->cmdlist, NULL, m, 0); + new_item = cmdq_get_command(pr->cmdlist, NULL, event, 0); cmd_list_free(pr->cmdlist); break; } diff --git a/cmd-join-pane.c b/cmd-join-pane.c index 99d7f366..45a56fc4 100644 --- a/cmd-join-pane.c +++ b/cmd-join-pane.c @@ -64,8 +64,7 @@ static enum cmd_retval cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); - struct cmd_find_state *current = &state->current; + struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *target = cmdq_get_target(item); struct cmd_find_state *source = cmdq_get_source(item); struct session *dst_s; diff --git a/cmd-new-session.c b/cmd-new-session.c index 551cd74c..5286d320 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -67,8 +67,7 @@ static enum cmd_retval cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); - struct cmd_find_state *current = &state->current; + struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *target = cmdq_get_target(item); struct client *c = cmdq_get_client(item); struct session *s, *as, *groupwith; @@ -317,7 +316,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) } else if (c->session != NULL) c->last_session = c->session; c->session = s; - if (~state->flags & CMDQ_STATE_REPEAT) + if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT) server_client_set_key_table(c, NULL); tty_update_client_offset(c); status_timer_start(c); diff --git a/cmd-new-window.c b/cmd-new-window.c index f2a7fbc2..87aae659 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -52,8 +52,7 @@ static enum cmd_retval cmd_new_window_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); - struct cmd_find_state *current = &state->current; + struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *target = cmdq_get_target(item); struct spawn_context sc; struct client *c = cmd_find_client(item, NULL, 1); diff --git a/cmd-queue.c b/cmd-queue.c index 12ad8c2d..40db3fef 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -65,6 +65,23 @@ struct cmdq_item { }; TAILQ_HEAD(cmdq_list, cmdq_item); +/* + * Command queue state. This is the context for commands on the command queue. + * It holds information about how the commands were fired (the key and flags), + * any additional formats for the commands, and the current default target. + * Multiple commands can share the same state and a command may update the + * default target. + */ +struct cmdq_state { + int references; + int flags; + + struct format_tree *formats; + + struct key_event event; + struct cmd_find_state current; +}; + /* Get command queue name. */ static const char * cmdq_name(struct client *c) @@ -142,11 +159,25 @@ cmdq_get_source(struct cmdq_item *item) return (&item->source); } -/* Get item state. */ -struct cmdq_state * -cmdq_get_state(struct cmdq_item *item) +/* Get state event. */ +struct key_event * +cmdq_get_event(struct cmdq_item *item) { - return (item->state); + return (&item->state->event); +} + +/* Get state current target. */ +struct cmd_find_state * +cmdq_get_current(struct cmdq_item *item) +{ + return (&item->state->current); +} + +/* Get state flags. */ +int +cmdq_get_flags(struct cmdq_item *item) +{ + return (item->state->flags); } /* Merge formats from item. */ @@ -317,7 +348,7 @@ cmdq_remove_group(struct cmdq_item *item) /* Get a command for the command queue. */ struct cmdq_item * cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current, - struct mouse_event *m, int flags) + struct key_event *event, int flags) { struct cmdq_item *item, *first = NULL, *last = NULL; struct cmd *cmd; @@ -333,10 +364,9 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current, cmd_find_copy_state(&state->current, current); else cmd_find_clear_state(&state->current, 0); - if (m != NULL) { - state->event.key = KEYC_NONE; - memcpy(&state->event.m, m, - sizeof state->event.m); + if (event != NULL) { + memcpy(&state->event, event, + sizeof state->event); } state->flags = flags; last_group = group; diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c index e8c2a5bc..105f48e0 100644 --- a/cmd-resize-pane.c +++ b/cmd-resize-pane.c @@ -50,8 +50,8 @@ static enum cmd_retval cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); struct cmd_find_state *target = cmdq_get_target(item); + struct key_event *event = cmdq_get_event(item); struct window_pane *wp = target->wp; struct winlink *wl = target->wl; struct window *w = wl->window; @@ -76,12 +76,12 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item) } if (args_has(args, 'M')) { - if (cmd_mouse_window(&state->event.m, &s) == NULL) + if (!event->m.valid || cmd_mouse_window(&event->m, &s) == NULL) return (CMD_RETURN_NORMAL); if (c == NULL || c->session != s) return (CMD_RETURN_NORMAL); c->tty.mouse_drag_update = cmd_resize_pane_mouse_update; - cmd_resize_pane_mouse_update(c, &state->event.m); + cmd_resize_pane_mouse_update(c, &event->m); return (CMD_RETURN_NORMAL); } diff --git a/cmd-rotate-window.c b/cmd-rotate-window.c index 6ba2056e..55c1dde2 100644 --- a/cmd-rotate-window.c +++ b/cmd-rotate-window.c @@ -44,8 +44,7 @@ static enum cmd_retval cmd_rotate_window_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); - struct cmd_find_state *current = &state->current; + struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *target = cmdq_get_target(item); struct winlink *wl = target->wl; struct window *w = wl->window; diff --git a/cmd-select-pane.c b/cmd-select-pane.c index e0907812..5f4a2e63 100644 --- a/cmd-select-pane.c +++ b/cmd-select-pane.c @@ -85,8 +85,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); const struct cmd_entry *entry = cmd_get_entry(self); - struct cmdq_state *state = cmdq_get_state(item); - struct cmd_find_state *current = &state->current; + struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *target = cmdq_get_target(item); struct client *c = cmd_find_client(item, NULL, 1); struct winlink *wl = target->wl; diff --git a/cmd-select-window.c b/cmd-select-window.c index 0a84bf0e..377e3633 100644 --- a/cmd-select-window.c +++ b/cmd-select-window.c @@ -85,8 +85,7 @@ static enum cmd_retval cmd_select_window_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); - struct cmd_find_state *current = &state->current; + struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *target = cmdq_get_target(item); struct winlink *wl = target->wl; struct session *s = target->s; diff --git a/cmd-send-keys.c b/cmd-send-keys.c index 1f70db16..de910904 100644 --- a/cmd-send-keys.c +++ b/cmd-send-keys.c @@ -134,13 +134,13 @@ static enum cmd_retval cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); struct cmd_find_state *target = cmdq_get_target(item); struct client *c = cmd_find_client(item, NULL, 1); struct window_pane *wp = target->wp; struct session *s = target->s; struct winlink *wl = target->wl; - struct mouse_event *m = &state->event.m; + struct key_event *event = cmdq_get_event(item); + struct mouse_event *m = &event->m; struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes); int i; key_code key; diff --git a/cmd-split-window.c b/cmd-split-window.c index 01d7cbc8..84419a1e 100644 --- a/cmd-split-window.c +++ b/cmd-split-window.c @@ -54,8 +54,7 @@ static enum cmd_retval cmd_split_window_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); - struct cmd_find_state *current = &state->current; + struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state *target = cmdq_get_target(item); struct spawn_context sc; struct client *c = cmd_find_client(item, NULL, 1); diff --git a/cmd-switch-client.c b/cmd-switch-client.c index de85122f..bc6a8174 100644 --- a/cmd-switch-client.c +++ b/cmd-switch-client.c @@ -48,8 +48,7 @@ static enum cmd_retval cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item) { struct args *args = cmd_get_args(self); - struct cmdq_state *state = cmdq_get_state(item); - struct cmd_find_state *current = &state->current; + struct cmd_find_state *current = cmdq_get_current(item); struct cmd_find_state target; const char *tflag = args_get(args, 't'); enum cmd_find_type type; @@ -137,7 +136,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmdq_item *item) if (c->session != NULL && c->session != s) c->last_session = c->session; c->session = s; - if (~state->flags & CMDQ_STATE_REPEAT) + if (~cmdq_get_flags(item) & CMDQ_STATE_REPEAT) server_client_set_key_table(c, NULL); tty_update_client_offset(c); status_timer_start(c); diff --git a/control.c b/control.c index 088371f5..d3515005 100644 --- a/control.c +++ b/control.c @@ -85,8 +85,8 @@ control_callback(__unused struct client *c, __unused const char *path, cmdq_append(c, item); break; case CMD_PARSE_SUCCESS: - item = cmdq_get_command(pr->cmdlist, NULL, NULL, 0); - cmdq_get_state(item)->flags |= CMDQ_STATE_CONTROL; + item = cmdq_get_command(pr->cmdlist, NULL, NULL, + CMDQ_STATE_CONTROL); cmdq_append(c, item); cmd_list_free(pr->cmdlist); break; diff --git a/format.c b/format.c index 9274e353..08fa38df 100644 --- a/format.c +++ b/format.c @@ -1124,16 +1124,13 @@ format_merge(struct format_tree *ft, struct format_tree *from) static void format_create_add_item(struct format_tree *ft, struct cmdq_item *item) { - struct cmdq_state *state = cmdq_get_state(item); - struct mouse_event *m; + struct key_event *event = cmdq_get_event(item); + struct mouse_event *m = &event->m; struct window_pane *wp; u_int x, y; cmdq_merge_formats(item, ft); - if (state == NULL) - return; - m = &state->event.m; if (m->valid && ((wp = cmd_mouse_pane(m, NULL, NULL)) != NULL)) { format_add(ft, "mouse_pane", "%%%u", wp->id); if (cmd_mouse_at(wp, m, &x, &y, 0) == 0) { diff --git a/key-bindings.c b/key-bindings.c index 04a5cef7..13caa889 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -535,10 +535,10 @@ key_bindings_read_only(struct cmdq_item *item, __unused void *data) 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) + struct client *c, struct key_event *event, struct cmd_find_state *fs) { struct cmdq_item *new_item; - int readonly; + int readonly, flags = 0; if (c == NULL || (~c->flags & CLIENT_READONLY)) readonly = 1; @@ -547,9 +547,9 @@ key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item, if (!readonly) new_item = cmdq_get_callback(key_bindings_read_only, NULL); else { - new_item = cmdq_get_command(bd->cmdlist, fs, m, 0); if (bd->flags & KEY_BINDING_REPEAT) - cmdq_get_state(new_item)->flags |= CMDQ_STATE_REPEAT; + flags |= CMDQ_STATE_REPEAT; + new_item = cmdq_get_command(bd->cmdlist, fs, event, flags); } if (item != NULL) new_item = cmdq_insert_after(item, new_item); diff --git a/menu.c b/menu.c index 6c571473..c72be5ce 100644 --- a/menu.c +++ b/menu.c @@ -282,10 +282,10 @@ chosen: break; case CMD_PARSE_SUCCESS: if (md->item != NULL) - m = &cmdq_get_state(md->item)->event.m; + event = cmdq_get_event(md->item); else - m = NULL; - new_item = cmdq_get_command(pr->cmdlist, &md->fs, m, 0); + event = NULL; + new_item = cmdq_get_command(pr->cmdlist, &md->fs, event, 0); cmd_list_free(pr->cmdlist); cmdq_append(c, new_item); break; diff --git a/popup.c b/popup.c index 8359397c..c1530347 100644 --- a/popup.c +++ b/popup.c @@ -305,10 +305,10 @@ popup_key_cb(struct client *c, struct key_event *event) break; case CMD_PARSE_SUCCESS: if (pd->item != NULL) - m = &cmdq_get_state(pd->item)->event.m; + event = cmdq_get_event(pd->item); else - m = NULL; - new_item = cmdq_get_command(pr->cmdlist, fs, m, 0); + event = NULL; + new_item = cmdq_get_command(pr->cmdlist, fs, event, 0); cmd_list_free(pr->cmdlist); cmdq_append(c, new_item); break; diff --git a/server-client.c b/server-client.c index 12a65af2..9575fd4d 100644 --- a/server-client.c +++ b/server-client.c @@ -1223,7 +1223,7 @@ try_again: server_status_client(c); /* Execute the key binding. */ - key_bindings_dispatch(bd, item, c, m, &fs); + key_bindings_dispatch(bd, item, c, event, &fs); key_bindings_unref_table(table); goto out; } diff --git a/tmux.h b/tmux.h index dbd046c4..e5ecab9b 100644 --- a/tmux.h +++ b/tmux.h @@ -43,6 +43,7 @@ struct cmd; struct cmd_find_state; struct cmdq_item; struct cmdq_list; +struct cmdq_state; struct cmds; struct environ; struct format_job_tree; @@ -1378,21 +1379,11 @@ struct cmd_parse_input { struct cmd_find_state fs; }; -/* Command queue item state. */ -struct cmdq_state { - int references; - - int flags; +/* Command queue flags. */ #define CMDQ_STATE_REPEAT 0x1 #define CMDQ_STATE_CONTROL 0x2 #define CMDQ_STATE_NOHOOKS 0x4 - struct format_tree *formats; - - struct key_event event; - struct cmd_find_state current; -}; - /* Command queue callback. */ typedef enum cmd_retval (*cmdq_cb) (struct cmdq_item *, void *); @@ -2108,10 +2099,12 @@ const char *cmdq_get_name(struct cmdq_item *); struct client *cmdq_get_client(struct cmdq_item *); struct cmd_find_state *cmdq_get_target(struct cmdq_item *); struct cmd_find_state *cmdq_get_source(struct cmdq_item *); -struct cmdq_state *cmdq_get_state(struct cmdq_item *); +struct key_event *cmdq_get_event(struct cmdq_item *); +struct cmd_find_state *cmdq_get_current(struct cmdq_item *); +int cmdq_get_flags(struct cmdq_item *); void cmdq_merge_formats(struct cmdq_item *, struct format_tree *); struct cmdq_item *cmdq_get_command(struct cmd_list *, struct cmd_find_state *, - struct mouse_event *, int); + struct key_event *, int); #define cmdq_get_callback(cb, data) cmdq_get_callback1(#cb, cb, data) struct cmdq_item *cmdq_get_callback1(const char *, cmdq_cb, void *); struct cmdq_item *cmdq_get_error(const char *); @@ -2147,7 +2140,7 @@ void key_bindings_remove(const char *, key_code); void key_bindings_remove_table(const char *); void key_bindings_init(void); struct cmdq_item *key_bindings_dispatch(struct key_binding *, - struct cmdq_item *, struct client *, struct mouse_event *, + struct cmdq_item *, struct client *, struct key_event *, struct cmd_find_state *); /* key-string.c */