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:
		@@ -67,8 +67,8 @@ struct options_entry *cmd_set_option_style(struct cmd *, struct cmd_q *,
 | 
			
		||||
const struct cmd_entry cmd_set_option_entry = {
 | 
			
		||||
	"set-option", "set",
 | 
			
		||||
	"agoqst:uw", 1, 2,
 | 
			
		||||
	"[-agosquw] [-t target-session|target-window] option [value]",
 | 
			
		||||
	0,
 | 
			
		||||
	"[-agosquw] [-t target-window] option [value]",
 | 
			
		||||
	CMD_WINDOW_T|CMD_CANFAIL,
 | 
			
		||||
	cmd_set_option_exec
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -76,7 +76,7 @@ const struct cmd_entry cmd_set_window_option_entry = {
 | 
			
		||||
	"set-window-option", "setw",
 | 
			
		||||
	"agoqt:u", 1, 2,
 | 
			
		||||
	"[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
 | 
			
		||||
	0,
 | 
			
		||||
	CMD_WINDOW_T|CMD_CANFAIL,
 | 
			
		||||
	cmd_set_option_exec
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -84,12 +84,12 @@ enum cmd_retval
 | 
			
		||||
cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
			
		||||
{
 | 
			
		||||
	struct args				*args = self->args;
 | 
			
		||||
	const struct options_table_entry	*oe;
 | 
			
		||||
	struct session				*s;
 | 
			
		||||
	struct winlink				*wl;
 | 
			
		||||
	struct client				*c;
 | 
			
		||||
	struct options				*oo;
 | 
			
		||||
	struct session				*s = cmdq->state.tflag.s;
 | 
			
		||||
	struct winlink				*wl = cmdq->state.tflag.wl;
 | 
			
		||||
	struct window				*w;
 | 
			
		||||
	struct client				*c;
 | 
			
		||||
	const struct options_table_entry	*oe;
 | 
			
		||||
	struct options				*oo;
 | 
			
		||||
	const char				*optstr, *valstr;
 | 
			
		||||
 | 
			
		||||
	/* Get the option name and value. */
 | 
			
		||||
@@ -131,7 +131,6 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
			
		||||
		if (args_has(self->args, 'g'))
 | 
			
		||||
			oo = global_w_options;
 | 
			
		||||
		else {
 | 
			
		||||
			wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
 | 
			
		||||
			if (wl == NULL) {
 | 
			
		||||
				cmdq_error(cmdq,
 | 
			
		||||
				    "couldn't set '%s'%s", optstr,
 | 
			
		||||
@@ -145,7 +144,6 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
 | 
			
		||||
		if (args_has(self->args, 'g'))
 | 
			
		||||
			oo = global_s_options;
 | 
			
		||||
		else {
 | 
			
		||||
			s = cmd_find_session(cmdq, args_get(args, 't'), 0);
 | 
			
		||||
			if (s == NULL) {
 | 
			
		||||
				cmdq_error(cmdq,
 | 
			
		||||
				    "couldn't set '%s'%s", optstr,
 | 
			
		||||
@@ -209,8 +207,8 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr,
 | 
			
		||||
    const char *valstr)
 | 
			
		||||
{
 | 
			
		||||
	struct args	*args = self->args;
 | 
			
		||||
	struct session	*s;
 | 
			
		||||
	struct winlink	*wl;
 | 
			
		||||
	struct session	*s = cmdq->state.tflag.s;
 | 
			
		||||
	struct winlink	*wl = cmdq->state.tflag.wl;
 | 
			
		||||
	struct options	*oo;
 | 
			
		||||
 | 
			
		||||
	if (args_has(args, 's'))
 | 
			
		||||
@@ -219,21 +217,13 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, const char *optstr,
 | 
			
		||||
	    self->entry == &cmd_set_window_option_entry) {
 | 
			
		||||
		if (args_has(self->args, 'g'))
 | 
			
		||||
			oo = global_w_options;
 | 
			
		||||
		else {
 | 
			
		||||
			wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
 | 
			
		||||
			if (wl == NULL)
 | 
			
		||||
				return (CMD_RETURN_ERROR);
 | 
			
		||||
		else
 | 
			
		||||
			oo = wl->window->options;
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if (args_has(self->args, 'g'))
 | 
			
		||||
			oo = global_s_options;
 | 
			
		||||
		else {
 | 
			
		||||
			s = cmd_find_session(cmdq, args_get(args, 't'), 0);
 | 
			
		||||
			if (s == NULL)
 | 
			
		||||
				return (CMD_RETURN_ERROR);
 | 
			
		||||
		else
 | 
			
		||||
			oo = s->options;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (args_has(args, 'u')) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user