diff --git a/README.md b/README.md index c02a238..a7a29cf 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ The command-line interface is straightforward as reflected in the output from --log-file Set log filename --log-strip Strip control characters and escape sequences -m, --map Map characters - -c, --color 0..255|none|list Colorize tio text (default: 15) + -c, --color 0..255|bold|none|list Colorize tio text (default: bold) -S, --socket Redirect I/O to file or network socket -x, --hexadecimal Enable hexadecimal mode -v, --version Display version diff --git a/man/tio.1.in b/man/tio.1.in index 1b8514a..f1e97c4 100644 --- a/man/tio.1.in +++ b/man/tio.1.in @@ -155,14 +155,15 @@ If defining more than one flag, the flags must be comma separated. Enable hexadecimal mode. .TP -.BR \-c ", " "\-\-color " \fI0..255|none|list +.BR \-c ", " "\-\-color " \fI0..255|bold|none|list Colorize tio text using ANSI color code value ranging from 0 to 255 or use -"none" for no color. +"none" for no color or use "bold" to apply bold formatting to existing system +color. Use "list" to print a list of available ANSI color codes. -Default value is 15. +Default value is "bold". .TP .BR \-S ", " "\-\-socket \fI\fR\fB diff --git a/src/configfile.c b/src/configfile.c index e49fa96..2eb7b18 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -226,6 +226,12 @@ static int data_handler(void *user, const char *section, const char *name, return 0; } + if (!strcmp(value, "bold")) + { + option.color = 256; // Bold + return 0; + } + option.color = atoi(value); if ((option.color < 0) || (option.color > 255)) { diff --git a/src/options.c b/src/options.c index 43ee530..5ab47da 100644 --- a/src/options.c +++ b/src/options.c @@ -65,7 +65,7 @@ struct option_t option = .timestamp = TIMESTAMP_NONE, .socket = NULL, .map = "", - .color = 15, + .color = 256, // Bold .hex_mode = false, .prefix_code = 20, // ctrl-t .prefix_key = 't', @@ -95,7 +95,7 @@ void print_help(char *argv[]) printf(" --log-file Set log filename\n"); printf(" --log-strip Strip control characters and escape sequences\n"); printf(" -m, --map Map characters\n"); - printf(" -c, --color 0..255|none|list Colorize tio text (default: 15)\n"); + printf(" -c, --color 0..255|bold|none|list Colorize tio text (default: bold)\n"); printf(" -S, --socket Redirect I/O to file or network socket\n"); printf(" -x, --hexadecimal Enable hexadecimal mode\n"); printf(" -v, --version Display version\n"); @@ -333,7 +333,13 @@ void options_parse(int argc, char *argv[]) if (!strcmp(optarg, "none")) { - option.color = -1; + option.color = -1; // No color + break; + } + + if (!strcmp(optarg, "bold")) + { + option.color = 256; // Bold break; } diff --git a/src/print.c b/src/print.c index 68e663c..359c078 100644 --- a/src/print.c +++ b/src/print.c @@ -39,6 +39,14 @@ void print_normal(char c) void print_init_ansi_formatting() { - // Set bold text with user defined ANSI color - sprintf(ansi_format, "\e[1;38;5;%dm", option.color); + if (option.color == 256) + { + // Set bold text with no color changes + sprintf(ansi_format, "\e[1m"); + } + else + { + // Set bold text with user defined ANSI color + sprintf(ansi_format, "\e[1;38;5;%dm", option.color); + } } diff --git a/src/print.h b/src/print.h index 5e3dbb2..c212a7c 100644 --- a/src/print.h +++ b/src/print.h @@ -42,7 +42,7 @@ extern char ansi_format[]; #define ansi_error_printf(format, args...) \ { \ if (option.color < 0) \ - fprintf (stdout, "\r" format "\r\n", ## args); \ + fprintf (stderr, "\r" format "\r\n", ## args); \ else \ fprintf (stderr, "\r%s" format ANSI_RESET "\r\n", ansi_format, ## args); \ fflush(stderr); \