1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:07:46 +00:00

LibVT: Fix underlines incorrectly rendering in red

Previously, `href` attributes weren't checked for not being empty when
drawing their underlines. This caused any underline to be treated as an
active `href`, hence the red color.
This commit is contained in:
Daniel Bertalan 2021-06-03 17:42:37 +02:00 committed by Linus Groh
parent 53099b216c
commit 99a79a364a

View file

@ -346,31 +346,31 @@ void TerminalWidget::paint_event(GUI::PaintEvent& event)
};
auto underline_style = UnderlineStyle::None;
auto underline_color = text_color;
if (attribute.flags & VT::Attribute::Underline) {
// Content has specified underline
underline_style = UnderlineStyle::Solid;
} else if (!attribute.href.is_empty()) {
// We're hovering a hyperlink
if (m_hovered_href_id == attribute.href_id || m_active_href_id == attribute.href_id)
if (m_hovered_href_id == attribute.href_id || m_active_href_id == attribute.href_id) {
underline_style = UnderlineStyle::Solid;
else
underline_color = palette().active_link();
} else {
underline_style = UnderlineStyle::Dotted;
underline_color = text_color.darkened(0.6f);
}
}
if (underline_style == UnderlineStyle::Solid) {
if (attribute.href_id == m_active_href_id && m_hovered_href_id == m_active_href_id)
text_color = palette().active_link();
painter.draw_line(cell_rect.bottom_left(), cell_rect.bottom_right(), text_color);
painter.draw_line(cell_rect.bottom_left(), cell_rect.bottom_right(), underline_color);
} else if (underline_style == UnderlineStyle::Dotted) {
auto dotted_line_color = text_color.darkened(0.6f);
int x1 = cell_rect.bottom_left().x();
int x2 = cell_rect.bottom_right().x();
int y = cell_rect.bottom_left().y();
for (int x = x1; x <= x2; ++x) {
if ((x % 3) == 0)
painter.set_pixel({ x, y }, dotted_line_color);
painter.set_pixel({ x, y }, underline_color);
}
}
}