diff options
-rw-r--r-- | usage.c | 2 | ||||
-rw-r--r-- | uxd.1 | 12 | ||||
-rw-r--r-- | uxd.c | 24 | ||||
-rw-r--r-- | uxd.rst | 12 |
4 files changed, 32 insertions, 18 deletions
@@ -1,7 +1,7 @@ char *usage_opts[] = { " -1: don't alternate colors for normal characters.", " -b: bold color output.", - " -c nnnn: colors (2 to 4 digits, 0 to 7).", + " -c nnnnn: colors (2 to 5 digits, 0 to 7).", " -d data: dump this data instead of a file.", " -h, --help: print this help message.", " -i: print number of bytes/chars/ascii/multibyte/bad sequences.", @@ -84,15 +84,15 @@ terminal and its color settings. Ignored if \fB\-m\fP given. . .INDENT 0.0 .TP -.BI \-c \ nnnn -Set the colors to use. Must be 2 to 4 digits, from 0 to 7. These are +.BI \-c \ nnnnn +Set the colors to use. Must be 2 to 5 digits, from 0 to 7. These are standard ANSI colors. The first 2 are the alternating colors for -normal characters, the 3rd digit (optional) is the color for non\-printable -and space characters, and the 4th (optional) is for invalid UTF\-8 -sequences. Default: \fB2351\fP\&. This option also disables a prior \fB\-m\fP +normal characters, the 3rd and 4th (optional) are the alternating color for non\-printable +and space characters, and the 5th (optional) is for invalid UTF\-8 +sequences. Default: \fB23561\fP\&. This option also disables a prior \fB\-m\fP option. .UNINDENT -.\" colors (2 to 4 digits, 0 to 7). +.\" colors (2 to 5 digits, 0 to 7). . .INDENT 0.0 .TP @@ -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; } @@ -69,15 +69,15 @@ as *K*, *M*, and *G* for power-of-10 based (e.g. *1K* is 1000 bytes). .. bold color output. --c nnnn - Set the colors to use. Must be 2 to 4 digits, from 0 to 7. These are +-c nnnnn + Set the colors to use. Must be 2 to 5 digits, from 0 to 7. These are standard ANSI colors. The first 2 are the alternating colors for - normal characters, the 3rd digit (optional) is the color for non-printable - and space characters, and the 4th (optional) is for invalid UTF-8 - sequences. Default: **2351**. This option also disables a prior **-m** + normal characters, the 3rd and 4th (optional) are the alternating color for non-printable + and space characters, and the 5th (optional) is for invalid UTF-8 + sequences. Default: **23561**. This option also disables a prior **-m** option. -.. colors (2 to 4 digits, 0 to 7). +.. colors (2 to 5 digits, 0 to 7). -d data Dump this data, instead of reading from a file or stdin. If *data* |