Index: lldb/source/Core/IOHandlerCursesGUI.cpp =================================================================== --- lldb/source/Core/IOHandlerCursesGUI.cpp +++ lldb/source/Core/IOHandlerCursesGUI.cpp @@ -273,6 +273,32 @@ const char *description; }; +// COLOR_PAIR index names +enum { + // First 16 colors are 8 black background and 8 blue background colors, + // needed by OutputColoredStringTruncated(). + BlackOnBlack = 1, + RedOnBlack, + GreenOnBlack, + YellowOnBlack, + BlueOnBlack, + MagentaOnBlack, + CyanOnBlack, + WhiteOnBlack, + BlackOnBlue, + RedOnBlue, + GreenOnBlue, + YellowOnBlue, + BlueOnBlue, + MagentaOnBlue, + CyanOnBlue, + WhiteOnBlue, + // Other colors, as needed. + BlackOnWhite, + MagentaOnWhite, + LastColorPairIndex = MagentaOnWhite +}; + class WindowDelegate { public: virtual ~WindowDelegate() = default; @@ -462,7 +488,7 @@ int saved_opts; ::wattr_get(m_window, &saved_attr, &saved_pair, &saved_opts); if (use_blue_background) - ::wattron(m_window, COLOR_PAIR(16)); + ::wattron(m_window, COLOR_PAIR(WhiteOnBlue)); while (!string.empty()) { size_t esc_pos = string.find('\x1b'); if (esc_pos == StringRef::npos) { @@ -498,7 +524,7 @@ if (value == 0) { // Reset. ::wattr_set(m_window, saved_attr, saved_pair, &saved_opts); if (use_blue_background) - ::wattron(m_window, COLOR_PAIR(16)); + ::wattron(m_window, COLOR_PAIR(WhiteOnBlue)); } else { // Mapped directly to first 16 color pairs (black/blue background). ::wattron(m_window, @@ -596,7 +622,7 @@ void DrawTitleBox(const char *title, const char *bottom_message = nullptr) { attr_t attr = 0; if (IsActive()) - attr = A_BOLD | COLOR_PAIR(18); + attr = A_BOLD | COLOR_PAIR(BlackOnWhite); else attr = 0; if (attr) @@ -1026,14 +1052,14 @@ if (m_key_name.empty()) { if (!underlined_shortcut && llvm::isPrint(m_key_value)) { - window.AttributeOn(COLOR_PAIR(19)); + window.AttributeOn(COLOR_PAIR(MagentaOnWhite)); window.Printf(" (%c)", m_key_value); - window.AttributeOff(COLOR_PAIR(19)); + window.AttributeOff(COLOR_PAIR(MagentaOnWhite)); } } else { - window.AttributeOn(COLOR_PAIR(19)); + window.AttributeOn(COLOR_PAIR(MagentaOnWhite)); window.Printf(" (%s)", m_key_name.c_str()); - window.AttributeOff(COLOR_PAIR(19)); + window.AttributeOff(COLOR_PAIR(MagentaOnWhite)); } } } @@ -2440,7 +2466,7 @@ attr_t changd_attr = 0; if (valobj->GetValueDidChange()) - changd_attr = COLOR_PAIR(2) | A_BOLD; + changd_attr = COLOR_PAIR(RedOnBlack) | A_BOLD; if (value && value[0]) { window.PutCStringTruncated(1, " = "); @@ -3581,7 +3607,7 @@ } const attr_t selected_highlight_attr = A_REVERSE; - const attr_t pc_highlight_attr = COLOR_PAIR(9); + const attr_t pc_highlight_attr = COLOR_PAIR(BlackOnBlue); for (size_t i = 0; i < num_visible_lines; ++i) { const uint32_t curr_line = m_first_visible_line + i; @@ -3600,7 +3626,7 @@ highlight_attr = selected_highlight_attr; if (bp_lines.find(curr_line + 1) != bp_lines.end()) - bp_attr = COLOR_PAIR(18); + bp_attr = COLOR_PAIR(BlackOnWhite); if (bp_attr) window.AttributeOn(bp_attr); @@ -3641,7 +3667,7 @@ window.Printf("%*s", desc_x - window.GetCursorX(), ""); window.MoveCursor(window_width - stop_description_len - 16, line_y); - const attr_t stop_reason_attr = COLOR_PAIR(17); + const attr_t stop_reason_attr = COLOR_PAIR(WhiteOnBlue); window.AttributeOn(stop_reason_attr); window.PrintfTruncated(1, " <<< Thread %u: %s ", thread->GetIndexID(), stop_description); @@ -3685,7 +3711,7 @@ } const attr_t selected_highlight_attr = A_REVERSE; - const attr_t pc_highlight_attr = COLOR_PAIR(17); + const attr_t pc_highlight_attr = COLOR_PAIR(WhiteOnBlue); StreamString strm; @@ -3733,7 +3759,7 @@ if (bp_file_addrs.find(inst->GetAddress().GetFileAddress()) != bp_file_addrs.end()) - bp_attr = COLOR_PAIR(18); + bp_attr = COLOR_PAIR(BlackOnWhite); if (bp_attr) window.AttributeOn(bp_attr); @@ -4263,10 +4289,10 @@ init_pair(14, COLOR_MAGENTA, COLOR_BLUE); init_pair(15, COLOR_CYAN, COLOR_BLUE); init_pair(16, COLOR_WHITE, COLOR_BLUE); - - init_pair(17, COLOR_WHITE, COLOR_BLUE); - init_pair(18, COLOR_BLACK, COLOR_WHITE); - init_pair(19, COLOR_MAGENTA, COLOR_WHITE); + // These must match the order in the color indexes enum. + init_pair(17, COLOR_BLACK, COLOR_WHITE); + init_pair(18, COLOR_MAGENTA, COLOR_WHITE); + static_assert(LastColorPairIndex == 18, "Color indexes do not match."); } }