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:
1 parent
605bfb3577
commit
def42a31ca
1 file changed
+11
+11
@@ -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
|
||||
|
||||
Reference in new issue
Block a user