diff options
author | B. Watson <urchlay@slackware.uk> | 2024-12-17 06:52:01 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-12-17 06:52:01 -0500 |
commit | 548e7d04b4b2fa60b71615ed590be54016dac52d (patch) | |
tree | 8701234e0bc3f8f325793455acf40b74cd220b94 | |
parent | 1cf3a186985712d9b210b451949a0742dcb9261f (diff) | |
download | uxd-548e7d04b4b2fa60b71615ed590be54016dac52d.tar.gz |
turn some magic constants into #defines
-rw-r--r-- | uxd.c | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -72,12 +72,22 @@ int special_color = PURPLE; int cur_normal_hilite = 0; /* highlight types. HL_NORM_INV is only used for the hex bytes, not - the human-readable right column. */ + the human-readable right column. */ #define HL_NORMAL 0 #define HL_NORM_INV 1 #define HL_SPECIAL 2 #define HL_BAD 3 +/* terminal codes for mono highlighting. */ +#define MONO_NORMAL 0 +#define MONO_UNDERLINE 4 +#define MONO_BOLD 1 +#define MONO_REVERSE 7 + +/* replacement character � is U+FFFD */ +#define PRINT_BAD "�" +#define PRINT_BOM "B" + /* name (read from argv[0]), for error/warning messages. */ const char *self; @@ -431,14 +441,14 @@ void append_mono(char *buf, int hl_type) { switch(hl_type) { case HL_NORMAL: case HL_NORM_INV: - code = cur_normal_hilite ? 4 : 0; /* underline : normal */ + code = cur_normal_hilite ? MONO_UNDERLINE : MONO_NORMAL; break; case HL_SPECIAL: - code = 1; /* bold */ + code = MONO_BOLD; break; default: case HL_BAD: - code = 7; /* reverse video */ + code = MONO_REVERSE; break; } @@ -626,14 +636,13 @@ int dump_utf8_char(void) { /* decide how to highlight the current character */ if(bad) { hl_type = HL_BAD; - /* replacement character � is U+FFFD */ - printable = "�"; + printable = PRINT_BAD; } else if(special) { hl_type = HL_SPECIAL; printable = get_special(bytes[0]); } else if(cont_count == 2 && is_bom(bytes)) { hl_type = HL_SPECIAL; - printable = "B"; + printable = PRINT_BOM; } else { hl_type = HL_NORMAL; printable = (char *)bytes; |