[llvm] r341396 - Set console mode when -fansi-escape-codes is enabled
    David Bolvansky via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Tue Sep  4 12:23:06 PDT 2018
    
    
  
Author: xbolva00
Date: Tue Sep  4 12:23:05 2018
New Revision: 341396
URL: http://llvm.org/viewvc/llvm-project?rev=341396&view=rev
Log:
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
Modified:
    llvm/trunk/lib/Support/Windows/Process.inc
Modified: llvm/trunk/lib/Support/Windows/Process.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Process.inc?rev=341396&r1=341395&r2=341396&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Process.inc (original)
+++ llvm/trunk/lib/Support/Windows/Process.inc Tue Sep  4 12:23:05 2018
@@ -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;
 }
 
    
    
More information about the llvm-commits
mailing list