Support true RGB coloring.

This commit is contained in:
Dianne Skoll
2020-01-25 16:16:51 -05:00
parent 57134a182c
commit 454d859fdd
3 changed files with 17 additions and 0 deletions

View File

@@ -397,11 +397,24 @@ Colorize256(int r, int g, int b)
sprintf(buf, "\x1B[38;5;%dm", best);
return buf;
}
static char const *
ColorizeTrue(int r, int g, int b)
{
static char buf[40];
sprintf(buf, "\x1B[38;2;%d;%d;%dm", r, g, b);
return buf;
}
char const *
Colorize(int r, int g, int b)
{
int bright = 0;
if (UseTrueColors) {
return ColorizeTrue(r, g, b);
}
if (Use256Colors) {
return Colorize256(r, g, b);
}

View File

@@ -104,6 +104,7 @@ EXTERN INIT( int UseVTChars, 0);
EXTERN INIT( int UseUTF8Chars, 0);
EXTERN INIT( int UseVTColors, 0);
EXTERN INIT( int Use256Colors, 0);
EXTERN INIT( int UseTrueColors, 0);
EXTERN INIT( int TerminalBackground, TERMINAL_BACKGROUND_UNKNOWN);
/* Latitude and longitude */

View File

@@ -218,6 +218,9 @@ void InitRemind(int argc, char const *argv[])
} else if (*arg == '4') {
Use256Colors = 1;
arg++;
} else if (*arg == '5') {
UseTrueColors = 1;
arg++;
}
break;