mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Rework color option
Rework the color option to support setting ANSI color code values ranging from 0..255 or "none" for no color or "list" to print a list of available ANSI colors codes. Also, disables color when piping.
This commit is contained in:
parent
2519e2081a
commit
46b5783789
8 changed files with 67 additions and 32 deletions
14
src/print.c
14
src/print.c
|
|
@ -47,16 +47,8 @@ void print_normal(char c)
|
|||
fflush(stdout);
|
||||
}
|
||||
|
||||
void print_enable_ansi_formatting()
|
||||
void print_init_ansi_formatting()
|
||||
{
|
||||
if (option.color < 0)
|
||||
{
|
||||
// Enable bold text
|
||||
sprintf(ansi_format, "\e[1m");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Enable bold text with user defined ANSI color
|
||||
sprintf(ansi_format, "\e[1;38;5;%dm", option.color);
|
||||
}
|
||||
// Set bold text with user defined ANSI color
|
||||
sprintf(ansi_format, "\e[1;38;5;%dm", option.color);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue