1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

Set console mode when -fansi-escape-codes is enabled

Summary:
Windows console now supports supports ANSI escape codes, but we need to enable it using SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_PROCESSING flag.

Fixes https://bugs.llvm.org/show_bug.cgi?id=38817


Tested on Windows 10, screenshot:
https://i.imgur.com/bqYq0Uy.png

Reviewers: zturner, chandlerc

Reviewed By: zturner

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D51611

llvm-svn: 341396
This commit is contained in:
David Bolvansky 2018-09-04 19:23:05 +00:00
parent 76928b42ba
commit 2b323c39a7

View File

@ -328,6 +328,15 @@ bool Process::StandardErrHasColors() {
static bool UseANSI = false;
void Process::UseANSIEscapeCodes(bool enable) {
#if defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING)
if (enable) {
HANDLE Console = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD Mode;
GetConsoleMode(Console, &Mode);
Mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(Console, Mode);
}
#endif
UseANSI = enable;
}