diff options
| author | David Bolvansky <david.bolvansky@gmail.com> | 2018-09-05 22:06:58 +0000 |
|---|---|---|
| committer | David Bolvansky <david.bolvansky@gmail.com> | 2018-09-05 22:06:58 +0000 |
| commit | 8aa23614af3c466d196a9aadaf641fc34e1b83cd (patch) | |
| tree | 69398b513856758d01b673692baa4455142e774d | |
| parent | a7f38f7ca363ac1e2907d4aab67ae85929c63e2b (diff) | |
| download | bcm5719-llvm-8aa23614af3c466d196a9aadaf641fc34e1b83cd.tar.gz bcm5719-llvm-8aa23614af3c466d196a9aadaf641fc34e1b83cd.zip | |
Set Windows console mode to enable support for ansi escape codes
Summary:
Windows console now supports supports ANSI escape codes, but we need to enable it using SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_PROCESSING flag.
https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences.
Syntax hightlighting now works fine on Windows:
https://i.imgur.com/P0i04A7.png
Reviewers: JDevlieghere, teemperor, zturner
Reviewed By: zturner
Subscribers: abidh, lldb-commits
Differential Revision: https://reviews.llvm.org/D51615
llvm-svn: 341497
| -rw-r--r-- | lldb/source/Core/Debugger.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 692856f17bf..17bec036564 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -50,6 +50,7 @@ #if defined(_WIN32) #include "lldb/Host/windows/PosixApi.h" // for PATH_MAX +#include "lldb/Host/windows/windows.h" #endif #include "llvm/ADT/None.h" // for None @@ -58,6 +59,7 @@ #include "llvm/ADT/iterator.h" // for iterator_facade_... #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Process.h" #include "llvm/Support/Threading.h" #include "llvm/Support/raw_ostream.h" // for raw_fd_ostream @@ -804,6 +806,13 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton) // 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) && defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) + // Enabling use of ANSI color codes because LLDB is using them to highlight + // text. + llvm::sys::Process::UseANSIEscapeCodes(true); + SetUseColor(true); +#endif } Debugger::~Debugger() { Clear(); } |

