Add '-c, --color' option

Allow user to select which ANSI color code to use to colorize the tio
text. To successfully set the color the color code must be in the range
0..255.

If color code is negative tio will print all available ANSI colors.

The default color is changed to bold white to make tio defaults usable
for most users, including color blind users.
This commit is contained in:
Martin Lund 2022-02-14 09:08:54 +01:00
parent 32e853e46e
commit 274cb63197
7 changed files with 55 additions and 16 deletions

View file

@ -27,17 +27,9 @@
extern bool print_tainted;
extern bool print_color_mode;
extern const char *print_color;
extern char print_color[];
#define ANSI_COLOR_GRAY "\x1b[1;30m"
#define ANSI_COLOR_RED "\x1b[1;31m"
#define ANSI_COLOR_GREEN "\x1b[1;32m"
#define ANSI_COLOR_YELLOW "\x1b[1;33m"
#define ANSI_COLOR_BLUE "\x1b[1;34m"
#define ANSI_COLOR_PINK "\x1b[1;35m"
#define ANSI_COLOR_CYAN "\x1b[1;36m"
#define ANSI_COLOR_WHITE "\x1b[1;37m"
#define ANSI_COLOR_RESET "\x1b[0m"
#define ANSI_COLOR_RESET "\e[0m"
#define color_printf(format, args...) \
{ \
@ -48,6 +40,15 @@ extern const char *print_color;
fflush(stdout); \
}
#define color_printf_raw(format, args...) \
{ \
if (print_color_mode) \
fprintf (stdout, "%s" format ANSI_COLOR_RESET, print_color, ## args); \
else \
fprintf (stdout, format, ## args); \
fflush(stdout); \
}
#define warning_printf(format, args...) \
{ \
color_printf("[%s] Warning: " format, current_time(), ## args); \