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

@ -719,7 +719,7 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
int focus_start = -1, focus_end = -1;
int list_state = -1, fill = -1, even;
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 utf8_data *ud = &sy.gc.data;
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 style_range *sr;
memcpy(&base_default, base, sizeof base_default);
memcpy(&current_default, base, sizeof current_default);
base = &base_default;
style_set(&sy, &current_default);
TAILQ_INIT(&frs);
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) {
memcpy(&current_default, base, sizeof current_default);
sy.default_type = STYLE_DEFAULT_BASE;
} else if (sy.default_type == STYLE_DEFAULT_SET) {
memcpy(&base_default, &saved_sy.gc,
sizeof base_default);
memcpy(&current_default, &saved_sy.gc,
sizeof current_default);
sy.default_type = STYLE_DEFAULT_BASE;
}
/* Check the list state. */