Possibly enable color output on Windows (#1494)

Windows 10 supports color output, but it must be explicitly enabled;
ANSICON provides support for other versions.  Enable color if either of
those are available.  Resolves #1494.
This commit is contained in:
Jason Hood authored and Nico Williams committed 2019-02-16 20:40:41 -06:00
1 parent 605bfb3577
commit def42a31ca
1 file changed
+11
+11
View File
@@ -538,6 +538,17 @@ int main(int argc, char* argv[]) {
/* Disable color by default on Windows builds as Windows
terminals tend not to display it correctly */
dumpopts |= JV_PRINT_COLOR;
#else
// Unless ANSICON is installed, or it's Windows 10
if (getenv("ANSICON") != NULL)
dumpopts |= JV_PRINT_COLOR;
else {
DWORD mode;
HANDLE con = GetStdHandle(STD_OUTPUT_HANDLE);
if (GetConsoleMode(con, &mode) &&
SetConsoleMode(con, mode | 4/*ENABLE_VIRTUAL_TERMINAL_PROCESSING*/))
dumpopts |= JV_PRINT_COLOR;
}
#endif
}
#endif