[Lldb-commits] [lldb] 5c540c7 - [lldb][gui] fix background of syntax-highlighted non-selected PC line

Luboš Luňák via lldb-commits lldb-commits at lists.llvm.org
Sun Apr 3 08:52:27 PDT 2022


Author: Luboš Luňák
Date: 2022-04-03T17:52:01+02:00
New Revision: 5c540c751c0210ba7a04f901fbbb6840777c9ef2

URL: https://github.com/llvm/llvm-project/commit/5c540c751c0210ba7a04f901fbbb6840777c9ef2
DIFF: https://github.com/llvm/llvm-project/commit/5c540c751c0210ba7a04f901fbbb6840777c9ef2.diff

LOG: [lldb][gui] fix background of syntax-highlighted non-selected PC line

It is the PC line, selected or not, that gets the blue-background
highlight. Without this, a keyword like 'bool' got black background
if the line wasn't selected.
And the blue-background highlight is handled by OutputColoredStringTruncated(),
so no point in setting it explicitly in the calling code.

Added: 
    

Modified: 
    lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp
index dbeb5b28e501c..a30665c3660aa 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -6977,9 +6977,6 @@ class SourceFileWindowDelegate : public WindowDelegate {
         }
       }
 
-      const attr_t selected_highlight_attr = A_REVERSE;
-      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;
         if (curr_line < num_source_lines) {
@@ -6987,14 +6984,13 @@ class SourceFileWindowDelegate : public WindowDelegate {
           window.MoveCursor(1, line_y);
           const bool is_pc_line = curr_line == m_pc_line;
           const bool line_is_selected = m_selected_line == curr_line;
-          // Highlight the line as the PC line first, then if the selected
-          // line isn't the same as the PC line, highlight it 
diff erently
+          // Highlight the line as the PC line first (done by passing
+          // argument to OutputColoredStringTruncated()), then if the selected
+          // line isn't the same as the PC line, highlight it 
diff erently.
           attr_t highlight_attr = 0;
           attr_t bp_attr = 0;
-          if (is_pc_line)
-            highlight_attr = pc_highlight_attr;
-          else if (line_is_selected)
-            highlight_attr = selected_highlight_attr;
+          if (line_is_selected && !is_pc_line)
+            highlight_attr = A_REVERSE;
 
           if (bp_lines.find(curr_line + 1) != bp_lines.end())
             bp_attr = COLOR_PAIR(BlackOnWhite);
@@ -7023,7 +7019,7 @@ class SourceFileWindowDelegate : public WindowDelegate {
           if (line.endswith("\n"))
             line = line.drop_back();
           bool wasWritten = window.OutputColoredStringTruncated(
-              1, line, m_first_visible_column, line_is_selected);
+              1, line, m_first_visible_column, is_pc_line);
           if (!wasWritten && (line_is_selected || is_pc_line)) {
             // Draw an empty space to show the selected/PC line if empty,
             // or draw '<' if nothing is visible because of scrolling too much


        


More information about the lldb-commits mailing list