mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Introduce bold color option
Introduce "bold" color option which only apply bold color formatting to existing system color. Also make "bold" the default color option. Fixes all white issue with black on white tio text.
This commit is contained in:
parent
9db7bb4fbb
commit
9733bdf19c
6 changed files with 31 additions and 10 deletions
|
|
@ -82,7 +82,7 @@ The command-line interface is straightforward as reflected in the output from
|
|||
--log-file <filename> Set log filename
|
||||
--log-strip Strip control characters and escape sequences
|
||||
-m, --map <flags> 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 <socket> Redirect I/O to file or network socket
|
||||
-x, --hexadecimal Enable hexadecimal mode
|
||||
-v, --version Display version
|
||||
|
|
|
|||
|
|
@ -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<socket>\fR\fB
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 <filename> Set log filename\n");
|
||||
printf(" --log-strip Strip control characters and escape sequences\n");
|
||||
printf(" -m, --map <flags> 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 <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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,14 @@ void print_normal(char c)
|
|||
|
||||
void print_init_ansi_formatting()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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); \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue