[Lldb-commits] [lldb] 5e79a00 - [lldb][gui] use symbolic names rather than hardcoded values
Luboš Luňák via lldb-commits
lldb-commits at lists.llvm.org
Sun Apr 3 08:52:29 PDT 2022
Author: Luboš Luňák
Date: 2022-04-03T17:52:01+02:00
New Revision: 5e79a00178c22dc00d2e5cf73b7b639d44e3f73d
URL: https://github.com/llvm/llvm-project/commit/5e79a00178c22dc00d2e5cf73b7b639d44e3f73d
DIFF: https://github.com/llvm/llvm-project/commit/5e79a00178c22dc00d2e5cf73b7b639d44e3f73d.diff
LOG: [lldb][gui] use symbolic names rather than hardcoded values
Added:
Modified:
lldb/source/Core/IOHandlerCursesGUI.cpp
Removed:
################################################################################
diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp
index a30665c3660aa..2240954bc47da 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -28,6 +28,7 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObjectUpdater.h"
#include "lldb/Host/File.h"
+#include "lldb/Utility/AnsiTerminal.h"
#include "lldb/Utility/Predicate.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
@@ -495,7 +496,7 @@ class Surface {
if (use_blue_background)
::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
while (!string.empty()) {
- size_t esc_pos = string.find('\x1b');
+ size_t esc_pos = string.find(ANSI_ESC_START);
if (esc_pos == StringRef::npos) {
string = string.substr(skip_first_count);
if (!string.empty()) {
@@ -517,26 +518,24 @@ class Surface {
string = string.drop_front(esc_pos);
}
}
- bool consumed = string.consume_front("\x1b");
+ bool consumed = string.consume_front(ANSI_ESC_START);
assert(consumed);
UNUSED_IF_ASSERT_DISABLED(consumed);
// This is written to match our Highlighter classes, which seem to
// generate only foreground color escape sequences. If necessary, this
// will need to be extended.
- if (!string.consume_front("[")) {
- llvm::errs() << "Missing '[' in color escape sequence.\n";
- continue;
- }
// Only 8 basic foreground colors and reset, our Highlighter doesn't use
// anything else.
int value;
if (!!string.consumeInteger(10, value) || // Returns false on success.
- !(value == 0 || (value >= 30 && value <= 37))) {
+ !(value == 0 ||
+ (value >= ANSI_FG_COLOR_BLACK && value <= ANSI_FG_COLOR_WHITE))) {
llvm::errs() << "No valid color code in color escape sequence.\n";
continue;
}
- if (!string.consume_front("m")) {
- llvm::errs() << "Missing 'm' in color escape sequence.\n";
+ if (!string.consume_front(ANSI_ESC_END)) {
+ llvm::errs() << "Missing '" << ANSI_ESC_END
+ << "' in color escape sequence.\n";
continue;
}
if (value == 0) { // Reset.
@@ -545,8 +544,8 @@ class Surface {
::wattron(m_window, COLOR_PAIR(WhiteOnBlue));
} else {
// Mapped directly to first 16 color pairs (black/blue background).
- ::wattron(m_window,
- COLOR_PAIR(value - 30 + 1 + (use_blue_background ? 8 : 0)));
+ ::wattron(m_window, COLOR_PAIR(value - ANSI_FG_COLOR_BLACK + 1 +
+ (use_blue_background ? 8 : 0)));
}
}
wattr_set(m_window, saved_attr, saved_pair, nullptr);
More information about the lldb-commits
mailing list