mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Add a set-default style attribute which replaces the current default
colours and attributes completely, useful at the start of compound format strings (like status-format) to set the default colours for all the following options.
This commit is contained in:
		@@ -719,7 +719,7 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
 | 
				
			|||||||
	int			 focus_start = -1, focus_end = -1;
 | 
						int			 focus_start = -1, focus_end = -1;
 | 
				
			||||||
	int			 list_state = -1, fill = -1, even;
 | 
						int			 list_state = -1, fill = -1, even;
 | 
				
			||||||
	enum style_align	 list_align = STYLE_ALIGN_DEFAULT;
 | 
						enum style_align	 list_align = STYLE_ALIGN_DEFAULT;
 | 
				
			||||||
	struct grid_cell	 gc, current_default;
 | 
						struct grid_cell	 gc, current_default, base_default;
 | 
				
			||||||
	struct style		 sy, saved_sy;
 | 
						struct style		 sy, saved_sy;
 | 
				
			||||||
	struct utf8_data	*ud = &sy.gc.data;
 | 
						struct utf8_data	*ud = &sy.gc.data;
 | 
				
			||||||
	const char		*cp, *end;
 | 
						const char		*cp, *end;
 | 
				
			||||||
@@ -729,7 +729,9 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
 | 
				
			|||||||
	struct format_ranges	 frs;
 | 
						struct format_ranges	 frs;
 | 
				
			||||||
	struct style_range	*sr;
 | 
						struct style_range	*sr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						memcpy(&base_default, base, sizeof base_default);
 | 
				
			||||||
	memcpy(¤t_default, base, sizeof current_default);
 | 
						memcpy(¤t_default, base, sizeof current_default);
 | 
				
			||||||
 | 
						base = &base_default;
 | 
				
			||||||
	style_set(&sy, ¤t_default);
 | 
						style_set(&sy, ¤t_default);
 | 
				
			||||||
	TAILQ_INIT(&frs);
 | 
						TAILQ_INIT(&frs);
 | 
				
			||||||
	log_debug("%s: %s", __func__, expanded);
 | 
						log_debug("%s: %s", __func__, expanded);
 | 
				
			||||||
@@ -847,6 +849,12 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
 | 
				
			|||||||
		} else if (sy.default_type == STYLE_DEFAULT_POP) {
 | 
							} else if (sy.default_type == STYLE_DEFAULT_POP) {
 | 
				
			||||||
			memcpy(¤t_default, base, sizeof current_default);
 | 
								memcpy(¤t_default, base, sizeof current_default);
 | 
				
			||||||
			sy.default_type = STYLE_DEFAULT_BASE;
 | 
								sy.default_type = STYLE_DEFAULT_BASE;
 | 
				
			||||||
 | 
							} else if (sy.default_type == STYLE_DEFAULT_SET) {
 | 
				
			||||||
 | 
								memcpy(&base_default, &saved_sy.gc,
 | 
				
			||||||
 | 
								    sizeof base_default);
 | 
				
			||||||
 | 
								memcpy(¤t_default, &saved_sy.gc,
 | 
				
			||||||
 | 
								    sizeof current_default);
 | 
				
			||||||
 | 
								sy.default_type = STYLE_DEFAULT_BASE;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Check the list state. */
 | 
							/* Check the list state. */
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								style.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								style.c
									
									
									
									
									
								
							@@ -98,6 +98,8 @@ style_parse(struct style *sy, const struct grid_cell *base, const char *in)
 | 
				
			|||||||
			sy->default_type = STYLE_DEFAULT_PUSH;
 | 
								sy->default_type = STYLE_DEFAULT_PUSH;
 | 
				
			||||||
		else if (strcasecmp(tmp, "pop-default") == 0)
 | 
							else if (strcasecmp(tmp, "pop-default") == 0)
 | 
				
			||||||
			sy->default_type = STYLE_DEFAULT_POP;
 | 
								sy->default_type = STYLE_DEFAULT_POP;
 | 
				
			||||||
 | 
							else if (strcasecmp(tmp, "set-default") == 0)
 | 
				
			||||||
 | 
								sy->default_type = STYLE_DEFAULT_SET;
 | 
				
			||||||
		else if (strcasecmp(tmp, "nolist") == 0)
 | 
							else if (strcasecmp(tmp, "nolist") == 0)
 | 
				
			||||||
			sy->list = STYLE_LIST_OFF;
 | 
								sy->list = STYLE_LIST_OFF;
 | 
				
			||||||
		else if (strncasecmp(tmp, "list=", 5) == 0) {
 | 
							else if (strncasecmp(tmp, "list=", 5) == 0) {
 | 
				
			||||||
@@ -310,6 +312,8 @@ style_tostring(struct style *sy)
 | 
				
			|||||||
			tmp = "push-default";
 | 
								tmp = "push-default";
 | 
				
			||||||
		else if (sy->default_type == STYLE_DEFAULT_POP)
 | 
							else if (sy->default_type == STYLE_DEFAULT_POP)
 | 
				
			||||||
			tmp = "pop-default";
 | 
								tmp = "pop-default";
 | 
				
			||||||
 | 
							else if (sy->default_type == STYLE_DEFAULT_SET)
 | 
				
			||||||
 | 
								tmp = "set-default";
 | 
				
			||||||
		off += xsnprintf(s + off, sizeof s - off, "%s%s", comma, tmp);
 | 
							off += xsnprintf(s + off, sizeof s - off, "%s%s", comma, tmp);
 | 
				
			||||||
		comma = ",";
 | 
							comma = ",";
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								tmux.1
									
									
									
									
									
								
							@@ -6357,6 +6357,10 @@ will be available in the
 | 
				
			|||||||
format variable.
 | 
					format variable.
 | 
				
			||||||
.Ql X
 | 
					.Ql X
 | 
				
			||||||
must be at most 15 bytes in length.
 | 
					must be at most 15 bytes in length.
 | 
				
			||||||
 | 
					.It Ic set-default
 | 
				
			||||||
 | 
					Set the current colours and attributes as the default, overwriting any previous
 | 
				
			||||||
 | 
					default.
 | 
				
			||||||
 | 
					The previous default cannot be restored.
 | 
				
			||||||
.El
 | 
					.El
 | 
				
			||||||
.Pp
 | 
					.Pp
 | 
				
			||||||
Examples are:
 | 
					Examples are:
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							@@ -881,7 +881,8 @@ TAILQ_HEAD(style_ranges, style_range);
 | 
				
			|||||||
enum style_default_type {
 | 
					enum style_default_type {
 | 
				
			||||||
	STYLE_DEFAULT_BASE,
 | 
						STYLE_DEFAULT_BASE,
 | 
				
			||||||
	STYLE_DEFAULT_PUSH,
 | 
						STYLE_DEFAULT_PUSH,
 | 
				
			||||||
	STYLE_DEFAULT_POP
 | 
						STYLE_DEFAULT_POP,
 | 
				
			||||||
 | 
						STYLE_DEFAULT_SET
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Style option. */
 | 
					/* Style option. */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user