1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-18 02:28:30 +02:00

Separate color being supported from being enabled

Previously, we were using `color_enabled` to mean both that the color
was supported and that it was enabled by the user (which it is enabled
by default). But this logic doesn't work well if the color check
function is called again and ends up enabling color after the user
disabled it. To fix this, just separate the two so the user controls one
`color_supported` variable and the `color_enabled` variable is separate.
Check both of them in order to print color, of course.
This commit is contained in:
Misa 2022-11-14 21:51:53 -08:00
parent 3fc23f2b2c
commit 0a181d8c3d

View File

@ -16,7 +16,7 @@
# define STDERR_IS_TTY 0
#endif
#define COLOR(EXPR) color_enabled ? EXPR : ""
#define COLOR(EXPR) (color_enabled && color_supported ? EXPR : "")
#define Color_RESET COLOR("\x1b[0m")
#define Color_BOLD COLOR("\x1b[1m")
@ -25,7 +25,8 @@
#define Color_BOLD_GRAY COLOR("\x1b[1;90m")
static int output_enabled = 1;
static int color_enabled = 0;
static int color_supported = 0;
static int color_enabled = 1;
static int debug_enabled = 0;
static int info_enabled = 1;
static int warn_enabled = 1;
@ -35,7 +36,7 @@ static void check_color_support(void)
{
if (STDOUT_IS_TTY && STDERR_IS_TTY)
{
color_enabled = 1;
color_supported = 1;
}
}