mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Merge branch 'obsd-master'
This commit is contained in:
		@@ -92,16 +92,19 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
 | 
				
			|||||||
	struct options			*oo;
 | 
						struct options			*oo;
 | 
				
			||||||
	struct options_entry		*parent, *o;
 | 
						struct options_entry		*parent, *o;
 | 
				
			||||||
	char				*name, *argument, *value = NULL, *cause;
 | 
						char				*name, *argument, *value = NULL, *cause;
 | 
				
			||||||
	const char			*target;
 | 
					 | 
				
			||||||
	int				 window, idx, already, error, ambiguous;
 | 
						int				 window, idx, already, error, ambiguous;
 | 
				
			||||||
	struct style			*sy;
 | 
						struct style			*sy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						window = (self->entry == &cmd_set_window_option_entry);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Expand argument. */
 | 
						/* Expand argument. */
 | 
				
			||||||
	c = cmd_find_client(item, NULL, 1);
 | 
						c = cmd_find_client(item, NULL, 1);
 | 
				
			||||||
	argument = format_single(item, args->argv[0], c, s, wl, NULL);
 | 
						argument = format_single(item, args->argv[0], c, s, wl, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* If set-hook -R, fire the hook straight away. */
 | 
				
			||||||
	if (self->entry == &cmd_set_hook_entry && args_has(args, 'R')) {
 | 
						if (self->entry == &cmd_set_hook_entry && args_has(args, 'R')) {
 | 
				
			||||||
		notify_hook(item, argument);
 | 
							notify_hook(item, argument);
 | 
				
			||||||
 | 
							free(argument);
 | 
				
			||||||
		return (CMD_RETURN_NORMAL);
 | 
							return (CMD_RETURN_NORMAL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -123,25 +126,8 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
 | 
				
			|||||||
	else
 | 
						else
 | 
				
			||||||
		value = xstrdup(args->argv[1]);
 | 
							value = xstrdup(args->argv[1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/* Get the scope and table for the option .*/
 | 
				
			||||||
	 * Figure out the scope: for user options it comes from the arguments,
 | 
						scope = options_scope_from_name(args, window, name, fs, &oo, &cause);
 | 
				
			||||||
	 * otherwise from the option name.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	if (*name == '@') {
 | 
					 | 
				
			||||||
		window = (self->entry == &cmd_set_window_option_entry);
 | 
					 | 
				
			||||||
		scope = options_scope_from_flags(args, window, fs, &oo, &cause);
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		if (options_get_only(global_options, name) != NULL)
 | 
					 | 
				
			||||||
			scope = OPTIONS_TABLE_SERVER;
 | 
					 | 
				
			||||||
		else if (options_get_only(global_s_options, name) != NULL)
 | 
					 | 
				
			||||||
			scope = OPTIONS_TABLE_SESSION;
 | 
					 | 
				
			||||||
		else if (options_get_only(global_w_options, name) != NULL)
 | 
					 | 
				
			||||||
			scope = OPTIONS_TABLE_WINDOW;
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			scope = OPTIONS_TABLE_NONE;
 | 
					 | 
				
			||||||
			xasprintf(&cause, "unknown option: %s", argument);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (scope == OPTIONS_TABLE_NONE) {
 | 
						if (scope == OPTIONS_TABLE_NONE) {
 | 
				
			||||||
		if (args_has(args, 'q'))
 | 
							if (args_has(args, 'q'))
 | 
				
			||||||
			goto out;
 | 
								goto out;
 | 
				
			||||||
@@ -149,35 +135,6 @@ cmd_set_option_exec(struct cmd *self, struct cmdq_item *item)
 | 
				
			|||||||
		free(cause);
 | 
							free(cause);
 | 
				
			||||||
		goto fail;
 | 
							goto fail;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Which table should this option go into? */
 | 
					 | 
				
			||||||
	if (scope == OPTIONS_TABLE_SERVER)
 | 
					 | 
				
			||||||
		oo = global_options;
 | 
					 | 
				
			||||||
	else if (scope == OPTIONS_TABLE_SESSION) {
 | 
					 | 
				
			||||||
		if (args_has(self->args, 'g'))
 | 
					 | 
				
			||||||
			oo = global_s_options;
 | 
					 | 
				
			||||||
		else if (s == NULL) {
 | 
					 | 
				
			||||||
			target = args_get(args, 't');
 | 
					 | 
				
			||||||
			if (target != NULL)
 | 
					 | 
				
			||||||
				cmdq_error(item, "no such session: %s", target);
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				cmdq_error(item, "no current session");
 | 
					 | 
				
			||||||
			goto fail;
 | 
					 | 
				
			||||||
		} else
 | 
					 | 
				
			||||||
			oo = s->options;
 | 
					 | 
				
			||||||
	} else if (scope == OPTIONS_TABLE_WINDOW) {
 | 
					 | 
				
			||||||
		if (args_has(self->args, 'g'))
 | 
					 | 
				
			||||||
			oo = global_w_options;
 | 
					 | 
				
			||||||
		else if (wl == NULL) {
 | 
					 | 
				
			||||||
			target = args_get(args, 't');
 | 
					 | 
				
			||||||
			if (target != NULL)
 | 
					 | 
				
			||||||
				cmdq_error(item, "no such window: %s", target);
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				cmdq_error(item, "no current window");
 | 
					 | 
				
			||||||
			goto fail;
 | 
					 | 
				
			||||||
		} else
 | 
					 | 
				
			||||||
			oo = wl->window->options;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	o = options_get_only(oo, name);
 | 
						o = options_get_only(oo, name);
 | 
				
			||||||
	parent = options_get(oo, name);
 | 
						parent = options_get(oo, name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -84,11 +84,11 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
 | 
				
			|||||||
	struct options			*oo;
 | 
						struct options			*oo;
 | 
				
			||||||
	enum options_table_scope	 scope;
 | 
						enum options_table_scope	 scope;
 | 
				
			||||||
	char				*argument, *name = NULL, *cause;
 | 
						char				*argument, *name = NULL, *cause;
 | 
				
			||||||
	const char			*target;
 | 
					 | 
				
			||||||
	int				 window, idx, ambiguous, parent;
 | 
						int				 window, idx, ambiguous, parent;
 | 
				
			||||||
	struct options_entry		*o;
 | 
						struct options_entry		*o;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	window = (self->entry == &cmd_show_window_options_entry);
 | 
						window = (self->entry == &cmd_show_window_options_entry);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (args->argc == 0) {
 | 
						if (args->argc == 0) {
 | 
				
			||||||
		scope = options_scope_from_flags(args, window, fs, &oo, &cause);
 | 
							scope = options_scope_from_flags(args, window, fs, &oo, &cause);
 | 
				
			||||||
		if (scope == OPTIONS_TABLE_NONE) {
 | 
							if (scope == OPTIONS_TABLE_NONE) {
 | 
				
			||||||
@@ -112,49 +112,7 @@ cmd_show_options_exec(struct cmd *self, struct cmdq_item *item)
 | 
				
			|||||||
			cmdq_error(item, "invalid option: %s", argument);
 | 
								cmdq_error(item, "invalid option: %s", argument);
 | 
				
			||||||
		goto fail;
 | 
							goto fail;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (*name == '@')
 | 
						scope = options_scope_from_name(args, window, name, fs, &oo, &cause);
 | 
				
			||||||
		scope = options_scope_from_flags(args, window, fs, &oo, &cause);
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
		if (options_get_only(global_options, name) != NULL)
 | 
					 | 
				
			||||||
			scope = OPTIONS_TABLE_SERVER;
 | 
					 | 
				
			||||||
		else if (options_get_only(global_s_options, name) != NULL)
 | 
					 | 
				
			||||||
			scope = OPTIONS_TABLE_SESSION;
 | 
					 | 
				
			||||||
		else if (options_get_only(global_w_options, name) != NULL)
 | 
					 | 
				
			||||||
			scope = OPTIONS_TABLE_WINDOW;
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			scope = OPTIONS_TABLE_NONE;
 | 
					 | 
				
			||||||
			xasprintf(&cause, "unknown option: %s", argument);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (scope == OPTIONS_TABLE_SERVER)
 | 
					 | 
				
			||||||
			oo = global_options;
 | 
					 | 
				
			||||||
		else if (scope == OPTIONS_TABLE_SESSION) {
 | 
					 | 
				
			||||||
			if (args_has(self->args, 'g'))
 | 
					 | 
				
			||||||
				oo = global_s_options;
 | 
					 | 
				
			||||||
			else if (s == NULL) {
 | 
					 | 
				
			||||||
				target = args_get(args, 't');
 | 
					 | 
				
			||||||
				if (target != NULL) {
 | 
					 | 
				
			||||||
					cmdq_error(item, "no such session: %s",
 | 
					 | 
				
			||||||
					    target);
 | 
					 | 
				
			||||||
				} else
 | 
					 | 
				
			||||||
					cmdq_error(item, "no current session");
 | 
					 | 
				
			||||||
				goto fail;
 | 
					 | 
				
			||||||
			} else
 | 
					 | 
				
			||||||
				oo = s->options;
 | 
					 | 
				
			||||||
		} else if (scope == OPTIONS_TABLE_WINDOW) {
 | 
					 | 
				
			||||||
			if (args_has(self->args, 'g'))
 | 
					 | 
				
			||||||
				oo = global_w_options;
 | 
					 | 
				
			||||||
			else if (wl == NULL) {
 | 
					 | 
				
			||||||
				target = args_get(args, 't');
 | 
					 | 
				
			||||||
				if (target != NULL) {
 | 
					 | 
				
			||||||
					cmdq_error(item, "no such window: %s",
 | 
					 | 
				
			||||||
					    target);
 | 
					 | 
				
			||||||
				} else
 | 
					 | 
				
			||||||
					cmdq_error(item, "no current window");
 | 
					 | 
				
			||||||
				goto fail;
 | 
					 | 
				
			||||||
			} else
 | 
					 | 
				
			||||||
				oo = wl->window->options;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (scope == OPTIONS_TABLE_NONE) {
 | 
						if (scope == OPTIONS_TABLE_NONE) {
 | 
				
			||||||
		if (args_has(args, 'q'))
 | 
							if (args_has(args, 'q'))
 | 
				
			||||||
			goto fail;
 | 
								goto fail;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										52
									
								
								options.c
									
									
									
									
									
								
							
							
						
						
									
										52
									
								
								options.c
									
									
									
									
									
								
							@@ -725,13 +725,63 @@ options_set_style(struct options *oo, const char *name, int append,
 | 
				
			|||||||
	return (o);
 | 
						return (o);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum options_table_scope
 | 
				
			||||||
 | 
					options_scope_from_name(struct args *args, int window,
 | 
				
			||||||
 | 
					    const char *name, struct cmd_find_state *fs, struct options **oo,
 | 
				
			||||||
 | 
					    char **cause)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct session			*s = fs->s;
 | 
				
			||||||
 | 
						struct winlink			*wl = fs->wl;
 | 
				
			||||||
 | 
						const char			*target = args_get(args, 't');
 | 
				
			||||||
 | 
						enum options_table_scope	 scope;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (*name == '@')
 | 
				
			||||||
 | 
							return (options_scope_from_flags(args, window, fs, oo, cause));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (options_get_only(global_options, name) != NULL)
 | 
				
			||||||
 | 
							scope = OPTIONS_TABLE_SERVER;
 | 
				
			||||||
 | 
						else if (options_get_only(global_s_options, name) != NULL)
 | 
				
			||||||
 | 
							scope = OPTIONS_TABLE_SESSION;
 | 
				
			||||||
 | 
						else if (options_get_only(global_w_options, name) != NULL)
 | 
				
			||||||
 | 
							scope = OPTIONS_TABLE_WINDOW;
 | 
				
			||||||
 | 
						else {
 | 
				
			||||||
 | 
							xasprintf(cause, "unknown option: %s", name);
 | 
				
			||||||
 | 
							return (OPTIONS_TABLE_NONE);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (scope == OPTIONS_TABLE_SERVER)
 | 
				
			||||||
 | 
							*oo = global_options;
 | 
				
			||||||
 | 
						else if (scope == OPTIONS_TABLE_SESSION) {
 | 
				
			||||||
 | 
							if (args_has(args, 'g'))
 | 
				
			||||||
 | 
								*oo = global_s_options;
 | 
				
			||||||
 | 
							else if (s == NULL) {
 | 
				
			||||||
 | 
								if (target != NULL)
 | 
				
			||||||
 | 
									xasprintf(cause, "no such session: %s", target);
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									xasprintf(cause, "no current session");
 | 
				
			||||||
 | 
							} else
 | 
				
			||||||
 | 
								*oo = s->options;
 | 
				
			||||||
 | 
						} else if (scope == OPTIONS_TABLE_WINDOW) {
 | 
				
			||||||
 | 
							if (args_has(args, 'g'))
 | 
				
			||||||
 | 
								*oo = global_w_options;
 | 
				
			||||||
 | 
							else if (wl == NULL) {
 | 
				
			||||||
 | 
								if (target != NULL)
 | 
				
			||||||
 | 
									xasprintf(cause, "no such window: %s", target);
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									xasprintf(cause, "no current window");
 | 
				
			||||||
 | 
							} else
 | 
				
			||||||
 | 
								*oo = wl->window->options;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return (scope);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum options_table_scope
 | 
					enum options_table_scope
 | 
				
			||||||
options_scope_from_flags(struct args *args, int window,
 | 
					options_scope_from_flags(struct args *args, int window,
 | 
				
			||||||
    struct cmd_find_state *fs, struct options **oo, char **cause)
 | 
					    struct cmd_find_state *fs, struct options **oo, char **cause)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct session	*s = fs->s;
 | 
						struct session	*s = fs->s;
 | 
				
			||||||
	struct winlink	*wl = fs->wl;
 | 
						struct winlink	*wl = fs->wl;
 | 
				
			||||||
	const char	*target= args_get(args, 't');
 | 
						const char	*target = args_get(args, 't');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (args_has(args, 's')) {
 | 
						if (args_has(args, 's')) {
 | 
				
			||||||
		*oo = global_options;
 | 
							*oo = global_options;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1821,6 +1821,9 @@ struct options_entry *options_set_number(struct options *, const char *,
 | 
				
			|||||||
		     long long);
 | 
							     long long);
 | 
				
			||||||
struct options_entry *options_set_style(struct options *, const char *, int,
 | 
					struct options_entry *options_set_style(struct options *, const char *, int,
 | 
				
			||||||
		     const char *);
 | 
							     const char *);
 | 
				
			||||||
 | 
					enum options_table_scope options_scope_from_name(struct args *, int,
 | 
				
			||||||
 | 
							     const char *, struct cmd_find_state *, struct options **,
 | 
				
			||||||
 | 
							     char **);
 | 
				
			||||||
enum options_table_scope options_scope_from_flags(struct args *, int,
 | 
					enum options_table_scope options_scope_from_flags(struct args *, int,
 | 
				
			||||||
		     struct cmd_find_state *, struct options **, char **);
 | 
							     struct cmd_find_state *, struct options **, char **);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user