Expand colours as formats like styles.

This commit is contained in:
nicm
2026-06-25 16:32:42 +00:00
parent 7c1ef6a387
commit 0d016195ac
9 changed files with 101 additions and 38 deletions

23
style.c
View File

@@ -434,6 +434,29 @@ style_apply(struct grid_cell *gc, struct options *oo, const char *name,
style_add(gc, oo, name, ft);
}
/* Parse a single colour into a style */
int
style_parse_colour(struct style *sy, const struct grid_cell *base,
const char *s)
{
int c;
style_set(sy, base);
if (*s == '\0') {
sy->gc.fg = -1;
return (0);
}
if ((c = colour_fromstring(s)) == -1)
return (-1);
if (c == 8)
sy->gc.fg = base->fg;
else
sy->gc.fg = c;
return (0);
}
/* Initialize style from cell. */
void
style_set(struct style *sy, const struct grid_cell *gc)