diff options
author | nicm <nicm> | 2015-12-13 14:32:38 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-12-13 14:32:38 +0000 |
commit | 4a4daf13031673870341c68b990e20c314140118 (patch) | |
tree | 2457218fe3b49af2401cb78cde064b2a7ff62916 /cmd-queue.c | |
parent | 5ed17e84faed0a7655ec1eb3de291b60839dcb12 (diff) | |
download | rtmux-4a4daf13031673870341c68b990e20c314140118.tar.gz rtmux-4a4daf13031673870341c68b990e20c314140118.tar.bz2 rtmux-4a4daf13031673870341c68b990e20c314140118.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 'cmd-queue.c')
-rw-r--r-- | cmd-queue.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/cmd-queue.c b/cmd-queue.c index c85fb048..7b2675fa 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -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; |