mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	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.
This commit is contained in:
		
							
								
								
									
										25
									
								
								cmd-queue.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user