diff options
-rw-r--r-- | mkusage.pl | 2 | ||||
-rw-r--r-- | usage.c | 1 | ||||
-rw-r--r-- | uxd.1 | 7 | ||||
-rw-r--r-- | uxd.c | 34 | ||||
-rw-r--r-- | uxd.rst | 5 |
5 files changed, 39 insertions, 10 deletions
@@ -4,7 +4,7 @@ print "char *usage_opts[] = {\n"; while(<>) { chomp; - if(/^-[a-zA-Z]/) { + if(/^-[a-zA-Z\d]/) { $opt = $_; next; } @@ -1,4 +1,5 @@ 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).", " -h, --help: print this help message.", @@ -63,6 +63,13 @@ by itself. . .INDENT 0.0 .TP +.B \-1 +Don\(aqt alternate colors for normal characters. +.UNINDENT +.\" don't alternate colors for normal characters. +. +.INDENT 0.0 +.TP .B \-b Bold output. This may be more or less readable, depending on your terminal and its color settings. Ignored if \fB\-m\fP given. @@ -66,7 +66,7 @@ int bad_color = RED; int special_color = PURPLE; /* toggles between 0 and 1 for each normal character */ -int cur_normal_hilite = 1; +int cur_normal_hilite = 0; /* highlight types */ #define HL_NORMAL 0 @@ -110,6 +110,7 @@ char * const special_symbols[] = { }; /* options */ +int alternate_colors = 1; /* -1 */ int print_info = 0; /* -i */ int bold = 0; /* -b */ int hilite_multi = 0; /* -r */ @@ -192,8 +193,18 @@ void parse_colors(char *arg) { bad_color = arg[3] - '0'; } -long parse_number(const char *s) { - return strtol(s, NULL, 0); /* TODO: error checking */ +long parse_number(int opt, const char *s) { + char *e; + long result; + + result = strtol(s, &e, 0); + + if(*e) { + fprintf(stderr, "%s: invalid number for -%c option.\n", self, opt); + exit(1); + } + + return result; } void parse_args(int argc, char **argv) { @@ -206,8 +217,10 @@ void parse_args(int argc, char **argv) { version(); } - while((opt = my_getopt(argc, argv, "ic:nbl:rmo:S:s:uhv")) != -1) { + while((opt = my_getopt(argc, argv, "1ic:nbl:rmo:S:s:uhv")) != -1) { switch(opt) { + case '1': + alternate_colors = 0; break; case 'i': print_info = 1; break; case 'c': @@ -217,18 +230,18 @@ void parse_args(int argc, char **argv) { case 'b': bold = 1; break; case 'l': - limit = parse_number(optarg); break; + limit = parse_number(opt, optarg); break; case 'r': hilite_multi = 1; break; case 'm': mono = 1; break; case 'o': - display_offset = parse_number(optarg); break; + display_offset = parse_number(opt, optarg); break; case 'S': seek_offset_zero = 1; /* fall thru */ case 's': - seekpos = parse_number(optarg); + seekpos = parse_number(opt, optarg); break; case 'u': hex_byte_fmt = "%02X"; hex_word_fmt = "%04X: "; break; @@ -330,7 +343,8 @@ void print_line(void) { } void next_normal_hilite() { - cur_normal_hilite = !cur_normal_hilite; + if(alternate_colors) + cur_normal_hilite = !cur_normal_hilite; } void append_color(char *buf, int hl_type) { @@ -557,7 +571,6 @@ int dump_utf8_char(void) { } else { hl_type = HL_NORMAL; printable = (char *)bytes; - next_normal_hilite(); } /* human-readable (right) column: */ @@ -572,6 +585,9 @@ int dump_utf8_char(void) { append_left(bytes[i], (i != cont_count), hl_type); } + if(hl_type == HL_NORMAL || hl_type == HL_NORM_INV) + next_normal_hilite(); + return 1; } @@ -52,6 +52,11 @@ by itself. .. the comments are turned into the --help message by mkusage.pl. +-1 + Don't alternate colors for normal characters. + +.. don't alternate colors for normal characters. + -b Bold output. This may be more or less readable, depending on your terminal and its color settings. Ignored if **-m** given. |