diff options
author | 2015-12-13 14:32:38 +0000 | |
---|---|---|
committer | 2015-12-13 14:32:38 +0000 | |
commit | 3447b427c1ffcf379e7fc14b9e25cce4fa75a963 (patch) | |
tree | 4470a122c84b0cc4457651c553dc0f60b4b9a3b0 /usr.bin/tmux/cmd-queue.c | |
parent | less macro; (diff) | |
download | wireguard-openbsd-3447b427c1ffcf379e7fc14b9e25cce4fa75a963.tar.xz wireguard-openbsd-3447b427c1ffcf379e7fc14b9e25cce4fa75a963.zip |
Instead of every command resolving the target (-t or -s) itself, prepare
the state (client, session, winlink, pane) for it it before entering the
command. Each command provides some flags that tell the prepare step
what it is expecting.
This is a requirement for having hooks on commands (for example, if you
hook "select-window -t1:2", the hook command should to operate on window
1:2 not whatever it thinks is the current window), and should allow some
other target improvements.
The old cmd_find_* functions remain for the moment but that layer will
be dropped later.
Joint work with Thomas Adam.
Diffstat (limited to 'usr.bin/tmux/cmd-queue.c')
-rw-r--r-- | usr.bin/tmux/cmd-queue.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c index 60ed6d7bb5f..ef63770292b 100644 --- a/usr.bin/tmux/cmd-queue.c +++ b/usr.bin/tmux/cmd-queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-queue.c,v 1.30 2015/11/27 15:06:43 nicm Exp $ */ +/* $OpenBSD: cmd-queue.c,v 1.31 2015/12/13 14:32:38 nicm Exp $ */ /* * Copyright (c) 2013 Nicholas Marriott <nicm@users.sourceforge.net> @@ -25,7 +25,7 @@ #include "tmux.h" -enum cmd_retval cmdq_continue_one(struct cmd_q *); +static enum cmd_retval cmdq_continue_one(struct cmd_q *); /* Create new command queue. */ struct cmd_q * @@ -179,37 +179,40 @@ cmdq_append(struct cmd_q *cmdq, struct cmd_list *cmdlist, struct mouse_event *m) } /* Process one command. */ -enum cmd_retval +static enum cmd_retval cmdq_continue_one(struct cmd_q *cmdq) { struct cmd *cmd = cmdq->cmd; enum cmd_retval retval; - char *s; + char *tmp; int flags = !!(cmd->flags & CMD_CONTROL); - s = cmd_print(cmd); - log_debug("cmdq %p: %s", cmdq, s); - free(s); + tmp = cmd_print(cmd); + log_debug("cmdq %p: %s", cmdq, tmp); + free(tmp); cmdq->time = time(NULL); cmdq->number++; cmdq_guard(cmdq, "begin", flags); + if (cmd_prepare_state(cmd, cmdq) != 0) + goto error; retval = cmd->entry->exec(cmd, cmdq); - if (retval == CMD_RETURN_ERROR) - cmdq_guard(cmdq, "error", flags); - else - cmdq_guard(cmdq, "end", flags); + cmdq_guard(cmdq, "end", flags); return (retval); + +error: + cmdq_guard(cmdq, "error", flags); + return (CMD_RETURN_ERROR); } /* Continue processing command queue. Returns 1 if finishes empty. */ int cmdq_continue(struct cmd_q *cmdq) { - struct client *c = cmdq->client; + struct client *c = cmdq->client; struct cmd_q_item *next; enum cmd_retval retval; int empty; |