[Lldb-commits] [PATCH] D51615: Set Windows console mode to enable support for ansi escape codes
Dávid Bolvanský via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 4 07:54:05 PDT 2018
xbolva00 updated this revision to Diff 163820.
xbolva00 added a comment.
- Addressed review comments
https://reviews.llvm.org/D51615
Files:
source/Core/Debugger.cpp
Index: source/Core/Debugger.cpp
===================================================================
--- source/Core/Debugger.cpp
+++ source/Core/Debugger.cpp
@@ -50,8 +50,15 @@
#if defined(_WIN32)
#include "lldb/Host/windows/PosixApi.h" // for PATH_MAX
+#include "windows.h"
+
+#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
+// See https://docs.microsoft.com/en-us/windows/console/setconsolemode
+#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
+#endif
+
#include "llvm/ADT/None.h" // for None
#include "llvm/ADT/STLExtras.h" // for make_unique
#include "llvm/ADT/StringRef.h"
@@ -804,6 +811,17 @@
// Turn off use-color if we don't write to a terminal with color support.
if (!m_output_file_sp->GetFile().GetIsTerminalWithColors())
SetUseColor(false);
+
+#if defined(_WIN32)
+ // Enabling use of ANSI color codes because LLDB is using them to highlight
+ // text.
+ HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
+ DWORD console_mode;
+ GetConsoleMode(console_handle, &console_mode);
+ console_mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
+ bool ansi_colors_supported = SetConsoleMode(console_handle, console_mode);
+ SetUseColor(ansi_colors_supported);
+#endif
}
Debugger::~Debugger() { Clear(); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51615.163820.patch
Type: text/x-patch
Size: 1252 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180904/0eaf6cdc/attachment.bin>
More information about the lldb-commits
mailing list