From 3aa0d464fde753af26341d0c1a8740e756818582 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 21 Dec 2024 03:59:23 -0500 Subject: inverse special hilight for multibyte specials --- uxd.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/uxd.c b/uxd.c index 03cd6e8..180de80 100644 --- a/uxd.c +++ b/uxd.c @@ -67,7 +67,8 @@ extern int optind; #define HL_NORMAL 0 #define HL_NORM_INV 1 #define HL_SPECIAL 2 -#define HL_BAD 3 +#define HL_SPEC_INV 3 +#define HL_BAD 4 /* terminal codes for mono highlighting. */ #define MONO_NORMAL 0 @@ -123,7 +124,7 @@ int filepos = 0; /* Unicode control character printable equivalents. For 0, use the "empty set" symbol. It's a lot more readable than the "nul" symbol, ␀. Escape, tab, newline, space are what urxvt uses in - its "keycap picture" mode. The rest of there are hard to read at + its "keycap picture" mode. The rest of these are hard to read at normal font sizes, but it's still better than using a dot for everything like xxd does. */ char * const special_symbols[] = { @@ -139,7 +140,7 @@ char * const special_symbols[] = { int alternate_colors = 1; /* -1 */ int print_info_opt = 0; /* -i */ int bold = 0; /* -b */ -int hilite_multi = 0; /* -r */ +int hilite_multi = 1; /* -r */ int mono = 0; /* -m */ long display_offset = 0; /* -o */ long seekpos = 0; /* -s, -S */ @@ -305,7 +306,7 @@ void parse_args(int argc, char **argv) { } break; case 'r': - hilite_multi = 1; break; + hilite_multi = 0; break; case 'm': mono = 1; break; case 'o': @@ -444,6 +445,10 @@ void append_color(char *buf, int hl_type) { fgcolor = special_color; bgcolor = 0; break; + case HL_SPEC_INV: + fgcolor = 0; + bgcolor = special_color; + break; case HL_BAD: default: fgcolor = 0; @@ -471,6 +476,7 @@ void append_mono(char *buf, int hl_type) { code = cur_normal_hilite ? MONO_UNDERLINE : MONO_NORMAL; break; case HL_SPECIAL: + case HL_SPEC_INV: code = MONO_BOLD; break; default: @@ -623,14 +629,14 @@ char *classify_char(int *hl, unsigned char *bytes, int cont_count) { } if(cont_count == 2 && is_bom(bytes)) { - *hl = HL_SPECIAL; + *hl = HL_SPEC_INV; return PRINT_BOM; } if(is_overlong(cont_count, bytes)) { /* java mode (MUTF-8) allows exactly one overlong: */ if(java_mode && cont_count == 1 && bytes[0] == 0xc0 && bytes[1] == 0x80) { - *hl = HL_SPECIAL; /* or should it be normal? */ + *hl = HL_SPEC_INV; return get_special(0); } else if(permissive) { *hl = HL_NORMAL; @@ -642,7 +648,7 @@ char *classify_char(int *hl, unsigned char *bytes, int cont_count) { if(is_surrogate(cont_count, bytes)) { if(wtf8_mode || permissive) { - *hl = HL_SPECIAL; + *hl = HL_SPEC_INV; } else { *hl = HL_BAD; } @@ -651,7 +657,7 @@ char *classify_char(int *hl, unsigned char *bytes, int cont_count) { if(is_out_of_range(cont_count, bytes)) { if(permissive) { - *hl = HL_SPECIAL; + *hl = HL_SPEC_INV; } else { *hl = HL_BAD; } -- cgit v1.2.3