=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-queue.c,v retrieving revision 1.86 retrieving revision 1.87 diff -u -r1.86 -r1.87 --- src/usr.bin/tmux/cmd-queue.c 2020/04/13 14:04:25 1.86 +++ src/usr.bin/tmux/cmd-queue.c 2020/04/13 14:46:04 1.87 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-queue.c,v 1.86 2020/04/13 14:04:25 nicm Exp $ */ +/* $OpenBSD: cmd-queue.c,v 1.87 2020/04/13 14:46:04 nicm Exp $ */ /* * Copyright (c) 2013 Nicholas Marriott @@ -65,6 +65,23 @@ }; 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,13 +159,27 @@ 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. */ void cmdq_merge_formats(struct cmdq_item *item, struct format_tree *ft) @@ -317,7 +348,7 @@ /* 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 @@ 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;