version 1.23, 2015/04/19 21:34:21 |
version 1.24, 2015/06/17 17:02:15 |
|
|
|
|
#include "tmux.h" |
#include "tmux.h" |
|
|
|
enum cmd_retval cmdq_continue_one(struct cmd_q *); |
|
|
/* Create new command queue. */ |
/* Create new command queue. */ |
struct cmd_q * |
struct cmd_q * |
cmdq_new(struct client *c) |
cmdq_new(struct client *c) |
|
|
item->mouse.valid = 0; |
item->mouse.valid = 0; |
} |
} |
|
|
|
/* Process one command. */ |
|
enum cmd_retval |
|
cmdq_continue_one(struct cmd_q *cmdq) |
|
{ |
|
struct cmd *cmd = cmdq->cmd; |
|
enum cmd_retval retval; |
|
char tmp[1024]; |
|
int flags = !!(cmd->flags & CMD_CONTROL); |
|
|
|
cmd_print(cmd, tmp, sizeof tmp); |
|
log_debug("cmdq %p: %s", cmdq, tmp); |
|
|
|
cmdq->time = time(NULL); |
|
cmdq->number++; |
|
|
|
cmdq_guard(cmdq, "begin", flags); |
|
|
|
retval = cmd->entry->exec(cmd, cmdq); |
|
|
|
if (retval == CMD_RETURN_ERROR) |
|
cmdq_guard(cmdq, "error", flags); |
|
else |
|
cmdq_guard(cmdq, "end", flags); |
|
return (retval); |
|
} |
|
|
/* Continue processing command queue. Returns 1 if finishes empty. */ |
/* Continue processing command queue. Returns 1 if finishes empty. */ |
int |
int |
cmdq_continue(struct cmd_q *cmdq) |
cmdq_continue(struct cmd_q *cmdq) |
{ |
{ |
struct cmd_q_item *next; |
struct cmd_q_item *next; |
enum cmd_retval retval; |
enum cmd_retval retval; |
int empty, flags; |
int empty; |
char s[1024]; |
|
|
|
cmdq->references++; |
cmdq->references++; |
notify_disable(); |
notify_disable(); |
|
|
|
|
do { |
do { |
while (cmdq->cmd != NULL) { |
while (cmdq->cmd != NULL) { |
cmd_print(cmdq->cmd, s, sizeof s); |
retval = cmdq_continue_one(cmdq); |
log_debug("cmdq %p: %s (client %d)", cmdq, s, |
|
cmdq->client != NULL ? cmdq->client->ibuf.fd : -1); |
|
|
|
cmdq->time = time(NULL); |
|
cmdq->number++; |
|
|
|
flags = !!(cmdq->cmd->flags & CMD_CONTROL); |
|
cmdq_guard(cmdq, "begin", flags); |
|
|
|
retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq); |
|
|
|
if (retval == CMD_RETURN_ERROR) |
if (retval == CMD_RETURN_ERROR) |
cmdq_guard(cmdq, "error", flags); |
|
else |
|
cmdq_guard(cmdq, "end", flags); |
|
|
|
if (retval == CMD_RETURN_ERROR) |
|
break; |
break; |
if (retval == CMD_RETURN_WAIT) |
if (retval == CMD_RETURN_WAIT) |
goto out; |
goto out; |
|
|
cmdq_flush(cmdq); |
cmdq_flush(cmdq); |
goto empty; |
goto empty; |
} |
} |
|
|
cmdq->cmd = TAILQ_NEXT(cmdq->cmd, qentry); |
cmdq->cmd = TAILQ_NEXT(cmdq->cmd, qentry); |
} |
} |
next = TAILQ_NEXT(cmdq->item, qentry); |
next = TAILQ_NEXT(cmdq->item, qentry); |