Merge pull request #94839 from alvinhochun/win-set-console-mode
Combine existing modes when calling SetConsoleMode
This commit is contained in:
commit
2c8ab6e7eb
|
@ -65,7 +65,9 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// Enable virtual terminal sequences processing.
|
// Enable virtual terminal sequences processing.
|
||||||
HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
DWORD out_mode = ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
DWORD out_mode = 0;
|
||||||
|
GetConsoleMode(stdout_handle, &out_mode);
|
||||||
|
out_mode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||||
SetConsoleMode(stdout_handle, out_mode);
|
SetConsoleMode(stdout_handle, out_mode);
|
||||||
|
|
||||||
// Find main executable name and check if it exist.
|
// Find main executable name and check if it exist.
|
||||||
|
|
|
@ -2044,7 +2044,9 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) {
|
||||||
// NOTE: The engine does not use ANSI escape codes to color error/warning messages; it uses Windows API calls instead.
|
// NOTE: The engine does not use ANSI escape codes to color error/warning messages; it uses Windows API calls instead.
|
||||||
// Therefore, error/warning messages are still colored on Windows versions older than 10.
|
// Therefore, error/warning messages are still colored on Windows versions older than 10.
|
||||||
HANDLE stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
DWORD outMode = ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
DWORD outMode = 0;
|
||||||
|
GetConsoleMode(stdoutHandle, &outMode);
|
||||||
|
outMode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||||
if (!SetConsoleMode(stdoutHandle, outMode)) {
|
if (!SetConsoleMode(stdoutHandle, outMode)) {
|
||||||
// Windows 8.1 or below, or Windows 10 prior to Anniversary Update.
|
// Windows 8.1 or below, or Windows 10 prior to Anniversary Update.
|
||||||
print_verbose("Can't set the ENABLE_VIRTUAL_TERMINAL_PROCESSING Windows console mode. `print_rich()` will not work as expected.");
|
print_verbose("Can't set the ENABLE_VIRTUAL_TERMINAL_PROCESSING Windows console mode. `print_rich()` will not work as expected.");
|
||||||
|
|
Loading…
Reference in New Issue