From d7546f793ca01866ba1a1351e2f139a7c0ed9711 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 21 Dec 2024 04:29:14 -0500 Subject: alternating colors for specials --- uxd.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'uxd.c') diff --git a/uxd.c b/uxd.c index 180de80..5775ef4 100644 --- a/uxd.c +++ b/uxd.c @@ -101,11 +101,12 @@ FILE *input; /* default colors */ int normal_colors[] = { GREEN, YELLOW }; +int special_colors[] = { PURPLE, CYAN }; int bad_color = RED; -int special_color = PURPLE; -/* toggles between 0 and 1 for each normal character */ +/* toggles between 0 and 1 for each normal/special character */ int cur_normal_hilite = 0; +int cur_special_hilite = 0; /* these buffers are bigger than they need to be really. */ /* offset and hex bytes: */ @@ -219,11 +220,16 @@ void parse_colors(char *arg) { /* optional 3rd color */ if(!arg[2]) return; check_color(arg[2]); - special_color = arg[2] - '0'; + special_colors[0] = arg[2] - '0'; /* optional 4th color */ if(!arg[3]) return; check_color(arg[3]); + special_colors[1] = arg[2] - '0'; + + /* optional 5th color */ + if(!arg[4]) return; + check_color(arg[3]); bad_color = arg[3] - '0'; } @@ -428,6 +434,11 @@ void next_normal_hilite(void) { cur_normal_hilite = !cur_normal_hilite; } +void next_special_hilite(void) { + if(alternate_colors) + cur_special_hilite = !cur_special_hilite; +} + void append_color(char *buf, int hl_type) { char tmpbuf[100]; int fgcolor, bgcolor; @@ -442,12 +453,12 @@ void append_color(char *buf, int hl_type) { bgcolor = normal_colors[cur_normal_hilite]; break; case HL_SPECIAL: - fgcolor = special_color; + fgcolor = special_colors[cur_special_hilite]; bgcolor = 0; break; case HL_SPEC_INV: fgcolor = 0; - bgcolor = special_color; + bgcolor = special_colors[cur_special_hilite]; break; case HL_BAD: default: @@ -764,6 +775,9 @@ int dump_utf8_char(void) { if(hl_type == HL_NORMAL || hl_type == HL_NORM_INV) next_normal_hilite(); + if(hl_type == HL_SPECIAL || hl_type == HL_SPEC_INV) + next_special_hilite(); + return 1; } -- cgit v1.2.3