Skip to content

Commit

Permalink
[lldb][gui] fix background of syntax-highlighted non-selected PC line
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
llunak committed Apr 3, 2022
1 parent 11b6d2f commit 5c540c7
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lldb/source/Core/IOHandlerCursesGUI.cpp
Expand Up @@ -6977,24 +6977,20 @@ 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) {
const int line_y = m_min_y + i;
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 differently
// 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 differently.
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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5c540c7

Please sign in to comment.