Selaa lähdekoodia

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.
Daniel Bertalan 4 vuotta sitten
vanhempi
commit
99a79a364a
1 muutettua tiedostoa jossa 8 lisäystä ja 8 poistoa
  1. 8 8
      Userland/Libraries/LibVT/TerminalWidget.cpp

+ 8 - 8
Userland/Libraries/LibVT/TerminalWidget.cpp

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