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:
nicm
2025-05-22 07:43:38 +00:00
parent 37a2c98d3d
commit 833c7fbf6d
4 changed files with 19 additions and 2 deletions

View File

@ -98,6 +98,8 @@ style_parse(struct style *sy, const struct grid_cell *base, const char *in)
sy->default_type = STYLE_DEFAULT_PUSH;
else if (strcasecmp(tmp, "pop-default") == 0)
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)
sy->list = STYLE_LIST_OFF;
else if (strncasecmp(tmp, "list=", 5) == 0) {
@ -310,6 +312,8 @@ style_tostring(struct style *sy)
tmp = "push-default";
else if (sy->default_type == STYLE_DEFAULT_POP)
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);
comma = ",";
}