summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c49
1 files changed, 42 insertions, 7 deletions
diff --git a/main.c b/main.c
index 7002dbc..b80520b 100644
--- a/main.c
+++ b/main.c
@@ -913,6 +913,7 @@ void init_curses(void) {
} else {
use_default_colors();
}
+ bkgdset(' ' | opt.color[0].attr);
for (ColorPair i = 1; i < CPAIR_MAX; i++) {
if (opt.color[i].init) {
init_pair(i, opt.color[i].fg, opt.color[i].bg);
@@ -1046,19 +1047,53 @@ int parse_color(Str s) {
return BAD_COLOR;
}
+int parse_attr(Str s) {
+ static struct {
+ Str s;
+ int v;
+ } attr_map[] = {
+ { Ss("standout"), A_STANDOUT },
+ { Ss("underline"), A_UNDERLINE },
+ { Ss("reverse"), A_REVERSE },
+ { Ss("blink"), A_BLINK },
+ { Ss("dim"), A_DIM },
+ { Ss("bold"), A_BOLD },
+ { Ss("italic"), A_ITALIC },
+ };
+ for (size_t i = 0; i < sizeof attr_map / sizeof *attr_map; i++) {
+ if (str_eql(s, attr_map[i].s)) {
+ return attr_map[i].v;
+ }
+ }
+ return 0;
+}
+
int sect_color(Str k, Str v, Arena *perm) {
(void)perm;
for (int i = 0; i < CPAIR_MAX; i++) {
if (!str_eql(k, cpair_name[i])) continue;
- Cut c = str_cut(v, ':');
- int fg = parse_color(str_trim(c.head));
- int bg = parse_color(str_trim(c.tail));
- if (fg == BAD_COLOR || bg == BAD_COLOR) return -1;
+ Str s = v;
opt.color[i] = (ColorOpt) {
- .fg = fg,
- .bg = bg,
- .init = 1
+ .fg = COLOR_NORM,
+ .bg = COLOR_NORM,
+ .attr = 0,
+ .init = 1,
};
+ for (;;) {
+ Cut k = str_cut(s, ',');
+ s = k.tail;
+ if (!k.head.n) break;
+ int attr = parse_attr(k.head);
+ if (!attr) {
+ Cut c = str_cut(k.head, ':');
+ int fg = parse_color(str_trim(c.head));
+ int bg = parse_color(str_trim(c.tail));
+ if (fg == BAD_COLOR || bg == BAD_COLOR) return -1;
+ opt.color[i].fg = fg;
+ opt.color[i].bg = bg;
+ }
+ opt.color[i].attr |= attr;
+ }
}
return -1;
}