diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2020-04-28 13:50:07 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2020-04-28 13:50:07 +0100 |
commit | 1f8256fc508bbee24b53fcd588ebf74653d69dfa (patch) | |
tree | d664861f00c35ccb98431281618fa84a7d1da0fd /style.c | |
parent | a43a15684667d0ef223b8ad88538cca04186dd8b (diff) | |
download | rtmux-1f8256fc508bbee24b53fcd588ebf74653d69dfa.tar.gz rtmux-1f8256fc508bbee24b53fcd588ebf74653d69dfa.tar.bz2 rtmux-1f8256fc508bbee24b53fcd588ebf74653d69dfa.zip |
Drop having a separate type for style options and make them all strings, which
allows formats to be expanded. Any styles without a '#{' are still validated
when they are set but any with a '#{' are not. Formats are not expanded
usefully in many cases yet, that will be changed later.
To make this work, a few other changes:
- set-option -a with a style option automatically appends a ",".
- OSC 10 and 11 don't set the window-style option anymore, instead the fg and
bg are stored in the pane struct and act as the defaults that can be
overridden by window-style.
- status-fg and -bg now override status-style instead of trying to keep them in
sync.
Diffstat (limited to 'style.c')
-rw-r--r-- | style.c | 34 |
1 files changed, 27 insertions, 7 deletions
@@ -260,17 +260,37 @@ style_tostring(struct style *sy) return (s); } -/* Apply a style. */ +/* Apply a style on top of the given style. */ void -style_apply(struct grid_cell *gc, struct options *oo, const char *name) +style_add(struct grid_cell *gc, struct options *oo, const char *name, + struct format_tree *ft) { - struct style *sy; + struct style *sy; + struct format_tree *ft0 = NULL; - memcpy(gc, &grid_default_cell, sizeof *gc); - sy = options_get_style(oo, name); - gc->fg = sy->gc.fg; - gc->bg = sy->gc.bg; + if (ft == NULL) + ft = ft0 = format_create(NULL, NULL, 0, FORMAT_NOJOBS); + + sy = options_string_to_style(oo, name, ft); + if (sy == NULL) + sy = &style_default; + if (sy->gc.fg != 8) + gc->fg = sy->gc.fg; + if (sy->gc.bg != 8) + gc->bg = sy->gc.bg; gc->attr |= sy->gc.attr; + + if (ft0 != NULL) + format_free(ft0); +} + +/* Apply a style on top of the default style. */ +void +style_apply(struct grid_cell *gc, struct options *oo, const char *name, + struct format_tree *ft) +{ + memcpy(gc, &grid_default_cell, sizeof *gc); + style_add(gc, oo, name, ft); } /* Initialize style from cell. */ |