summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows/Process.inc
diff options
context:
space:
mode:
authorDavid Bolvansky <david.bolvansky@gmail.com>2018-09-04 19:23:05 +0000
committerDavid Bolvansky <david.bolvansky@gmail.com>2018-09-04 19:23:05 +0000
commitecf0c55b63526443720be994fad18081dbe3b672 (patch)
tree14f988a687411b0dbbd083fd7344916057e9f08e /llvm/lib/Support/Windows/Process.inc
parent2d4173c3c70e660622df46a2e69e1c7d4667019d (diff)
downloadbcm5719-llvm-ecf0c55b63526443720be994fad18081dbe3b672.tar.gz
bcm5719-llvm-ecf0c55b63526443720be994fad18081dbe3b672.zip
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
Diffstat (limited to 'llvm/lib/Support/Windows/Process.inc')
-rw-r--r--llvm/lib/Support/Windows/Process.inc9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/Process.inc b/llvm/lib/Support/Windows/Process.inc
index 30126568769..668d0b7a2e4 100644
--- a/llvm/lib/Support/Windows/Process.inc
+++ b/llvm/lib/Support/Windows/Process.inc
@@ -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;
}
OpenPOWER on IntegriCloud