diff options
author | nicm <nicm> | 2019-09-15 21:42:57 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-09-15 21:42:57 +0000 |
commit | 63e07b245f898af17657c4655f1251aa43e19d0c (patch) | |
tree | 6c2db5b222dac64b3804e8b6731fa210f79f4548 /style.c | |
parent | a23ce1b45ff8b8999e2817c9e747188c559725e1 (diff) | |
download | rtmux-63e07b245f898af17657c4655f1251aa43e19d0c.tar.gz rtmux-63e07b245f898af17657c4655f1251aa43e19d0c.tar.bz2 rtmux-63e07b245f898af17657c4655f1251aa43e19d0c.zip |
Add push-default and pop-default in styles to change the default colours
and attributes and use them to restore the previous behaviour of
window-status-style being the default for window-status-format in the
status line. From John Drouhard in GitHub issue 1912.
Diffstat (limited to 'style.c')
-rw-r--r-- | style.c | 39 |
1 files changed, 19 insertions, 20 deletions
@@ -36,13 +36,15 @@ static struct style style_default = { STYLE_ALIGN_DEFAULT, STYLE_LIST_OFF, - STYLE_RANGE_NONE, 0 + STYLE_RANGE_NONE, 0, + + STYLE_DEFAULT_BASE }; /* - * Parse an embedded style of the form "fg=colour,bg=colour,bright,...". - * Note that this adds onto the given style, so it must have been initialized - * alredy. + * Parse an embedded style of the form "fg=colour,bg=colour,bright,...". Note + * that this adds onto the given style, so it must have been initialized + * already. */ int style_parse(struct style *sy, const struct grid_cell *base, const char *in) @@ -74,7 +76,11 @@ style_parse(struct style *sy, const struct grid_cell *base, const char *in) sy->gc.bg = base->bg; sy->gc.attr = base->attr; sy->gc.flags = base->flags; - } else if (strcasecmp(tmp, "nolist") == 0) + } else if (strcasecmp(tmp, "push-default") == 0) + sy->default_type = STYLE_DEFAULT_PUSH; + else if (strcasecmp(tmp, "pop-default") == 0) + sy->default_type = STYLE_DEFAULT_POP; + else if (strcasecmp(tmp, "nolist") == 0) sy->list = STYLE_LIST_OFF; else if (strncasecmp(tmp, "list=", 5) == 0) { if (strcasecmp(tmp + 5, "on") == 0) @@ -218,6 +224,14 @@ style_tostring(struct style *sy) tmp); comma = ","; } + if (sy->default_type != STYLE_DEFAULT_BASE) { + if (sy->default_type == STYLE_DEFAULT_PUSH) + tmp = "push-default"; + else if (sy->default_type == STYLE_DEFAULT_POP) + tmp = "pop-default"; + off += xsnprintf(s + off, sizeof s - off, "%s%s", comma, tmp); + comma = ","; + } if (sy->fill != 8) { off += xsnprintf(s + off, sizeof s - off, "%sfill=%s", comma, colour_tostring(sy->fill)); @@ -257,21 +271,6 @@ style_apply(struct grid_cell *gc, struct options *oo, const char *name) gc->attr |= sy->gc.attr; } -/* Apply a style, updating if default. */ -void -style_apply_update(struct grid_cell *gc, struct options *oo, const char *name) -{ - struct style *sy; - - sy = options_get_style(oo, name); - if (sy->gc.fg != 8) - gc->fg = sy->gc.fg; - if (sy->gc.bg != 8) - gc->bg = sy->gc.bg; - if (sy->gc.attr != 0) - gc->attr |= sy->gc.attr; -} - /* Initialize style from cell. */ void style_set(struct style *sy, const struct grid_cell *gc) |