From 99a79a364a27c35ddef89bc8e41f8fbce19222e7 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Thu, 3 Jun 2021 17:42:37 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibVT/TerminalWidget.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp index 520855ce6e..aeb4996218 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.cpp +++ b/Userland/Libraries/LibVT/TerminalWidget.cpp @@ -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); } } }