authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-10-15 12:15:32-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-10-15 12:15:32-04:00
log3c198834930e9628802d2935e32e14e75baf2605
tree1a839c091f098ef10ca4b49b8e363aa9ef344d2a
parent6fe1c3186f56a31c6ff22602a5852955c8b4a700

only SetConsoleTextAttribute to do console colors on windows


1 files changed, 0 insertions(+), 19 deletions(-)

src/os.cpp-19
...@@ -964,13 +964,6 @@ void os_stderr_set_color(TermColor color) {...@@ -964,13 +964,6 @@ void os_stderr_set_color(TermColor color) {
964 if (stderr_handle == INVALID_HANDLE_VALUE)964 if (stderr_handle == INVALID_HANDLE_VALUE)
965 zig_panic("unable to get stderr handle");965 zig_panic("unable to get stderr handle");
966 fflush(stderr);966 fflush(stderr);
967 DWORD ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004;
968 if (color != TermColorReset) {
969 DWORD mode_flags = 0;
970 GetConsoleMode(stderr_handle, &mode_flags);
971 mode_flags |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
972 SetConsoleMode(stderr_handle, mode_flags);
973 }
974967
975 if (!got_orig_console_attrs) {968 if (!got_orig_console_attrs) {
976 got_orig_console_attrs = true;969 got_orig_console_attrs = true;
...@@ -984,32 +977,20 @@ void os_stderr_set_color(TermColor color) {...@@ -984,32 +977,20 @@ void os_stderr_set_color(TermColor color) {
984 switch (color) {977 switch (color) {
985 case TermColorRed:978 case TermColorRed:
986 SetConsoleTextAttribute(stderr_handle, FOREGROUND_RED|FOREGROUND_INTENSITY);979 SetConsoleTextAttribute(stderr_handle, FOREGROUND_RED|FOREGROUND_INTENSITY);
987 WriteConsole(stderr_handle, VT_RED, strlen(VT_RED), &chars_written, NULL);
988 break;980 break;
989 case TermColorGreen:981 case TermColorGreen:
990 SetConsoleTextAttribute(stderr_handle, FOREGROUND_GREEN|FOREGROUND_INTENSITY);982 SetConsoleTextAttribute(stderr_handle, FOREGROUND_GREEN|FOREGROUND_INTENSITY);
991 WriteConsole(stderr_handle, VT_GREEN, strlen(VT_GREEN), &chars_written, NULL);
992 break;983 break;
993 case TermColorCyan:984 case TermColorCyan:
994 SetConsoleTextAttribute(stderr_handle, FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);985 SetConsoleTextAttribute(stderr_handle, FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
995 WriteConsole(stderr_handle, VT_CYAN, strlen(VT_CYAN), &chars_written, NULL);
996 break;986 break;
997 case TermColorWhite:987 case TermColorWhite:
998 SetConsoleTextAttribute(stderr_handle,988 SetConsoleTextAttribute(stderr_handle,
999 FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);989 FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY);
1000 WriteConsole(stderr_handle, VT_WHITE, strlen(VT_WHITE), &chars_written, NULL);
1001 break;990 break;
1002 case TermColorReset:991 case TermColorReset:
1003 {
1004 SetConsoleTextAttribute(stderr_handle, original_console_attributes);992 SetConsoleTextAttribute(stderr_handle, original_console_attributes);
1005 WriteConsole(stderr_handle, VT_RESET, strlen(VT_RESET), &chars_written, NULL);
1006
1007 DWORD mode_flags = 0;
1008 GetConsoleMode(stderr_handle, &mode_flags);
1009 mode_flags &= ~ENABLE_VIRTUAL_TERMINAL_PROCESSING;
1010 SetConsoleMode(stderr_handle, mode_flags);
1011 break;993 break;
1012 }
1013 }994 }
1014#else995#else
1015 set_color_posix(color);996 set_color_posix(color);