diff options
10 files changed, 16 insertions, 19 deletions
diff --git a/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp b/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp index 4fdc12b110..7c36019567 100644 --- a/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp +++ b/Userland/Applications/Spreadsheet/CellSyntaxHighlighter.cpp @@ -29,7 +29,6 @@ void CellSyntaxHighlighter::rehighlight(Palette const& palette) palette.syntax_keyword(), Optional<Color> {}, false, - false, }, (u64)-1, false); @@ -47,7 +46,6 @@ void CellSyntaxHighlighter::rehighlight(Palette const& palette) Color::Black, Color::Red, false, - false, }, (u64)-1, false }); diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index 3db73b6b16..0fe712fd44 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -292,8 +292,8 @@ void Editor::mousemove_event(GUI::MouseEvent& event) for (auto& span : document().spans()) { bool is_clickable = (highlighter->is_navigatable(span.data) || highlighter->is_identifier(span.data)); if (span.range.contains(m_previous_text_position) && !span.range.contains(text_position)) { - if (is_clickable && span.attributes.underline) { - span.attributes.underline = false; + if (is_clickable && span.attributes.underline_style.has_value()) { + span.attributes.underline_style.clear(); wrapper().editor().update(); } } @@ -304,9 +304,12 @@ void Editor::mousemove_event(GUI::MouseEvent& event) if (is_clickable) { is_over_clickable = true; - bool was_underlined = span.attributes.underline; - span.attributes.underline = event.modifiers() & Mod_Ctrl; - if (span.attributes.underline != was_underlined) { + bool was_underlined = span.attributes.underline_style.has_value(); + bool now_underlined = event.modifiers() & Mod_Ctrl; + span.attributes.underline_style.clear(); + if (now_underlined) + span.attributes.underline_style = Gfx::TextAttributes::UnderlineStyle::Solid; + if (now_underlined != was_underlined) { wrapper().editor().update(); } } diff --git a/Userland/Libraries/LibCMake/CMakeCache/SyntaxHighlighter.cpp b/Userland/Libraries/LibCMake/CMakeCache/SyntaxHighlighter.cpp index 2cb7db81a3..f57a209269 100644 --- a/Userland/Libraries/LibCMake/CMakeCache/SyntaxHighlighter.cpp +++ b/Userland/Libraries/LibCMake/CMakeCache/SyntaxHighlighter.cpp @@ -54,7 +54,6 @@ void SyntaxHighlighter::rehighlight(Gfx::Palette const& palette) span.attributes.color = style.color; span.attributes.bold = style.bold; if (type == Token::Type::Garbage) { - span.attributes.underline = true; span.attributes.underline_color = palette.red(); span.attributes.underline_style = Gfx::TextAttributes::UnderlineStyle::Wavy; } diff --git a/Userland/Libraries/LibCMake/SyntaxHighlighter.cpp b/Userland/Libraries/LibCMake/SyntaxHighlighter.cpp index 60856847db..672e3ff252 100644 --- a/Userland/Libraries/LibCMake/SyntaxHighlighter.cpp +++ b/Userland/Libraries/LibCMake/SyntaxHighlighter.cpp @@ -70,7 +70,6 @@ void SyntaxHighlighter::rehighlight(Gfx::Palette const& palette) span.attributes.color = style.color; span.attributes.bold = style.bold; if (type == Token::Type::Garbage) { - span.attributes.underline = true; span.attributes.underline_color = palette.red(); span.attributes.underline_style = Gfx::TextAttributes::UnderlineStyle::Wavy; } diff --git a/Userland/Libraries/LibGUI/TextDocument.cpp b/Userland/Libraries/LibGUI/TextDocument.cpp index 3633c2d0f9..8c1b729d8f 100644 --- a/Userland/Libraries/LibGUI/TextDocument.cpp +++ b/Userland/Libraries/LibGUI/TextDocument.cpp @@ -1391,9 +1391,8 @@ void TextDocument::merge_span_collections() merged_span.span.attributes.color = span_and_collection_index.collection_index > last_span_and_collection_index.collection_index ? span.attributes.color : last_span.attributes.color; merged_span.span.attributes.bold = span.attributes.bold | last_span.attributes.bold; merged_span.span.attributes.background_color = span.attributes.background_color.has_value() ? span.attributes.background_color.value() : last_span.attributes.background_color; - merged_span.span.attributes.underline = span.attributes.underline | last_span.attributes.underline; merged_span.span.attributes.underline_color = span.attributes.underline_color.has_value() ? span.attributes.underline_color.value() : last_span.attributes.underline_color; - merged_span.span.attributes.underline_style = span.attributes.underline_style; + merged_span.span.attributes.underline_style = span.attributes.underline_style.has_value() ? span.attributes.underline_style : last_span.attributes.underline_style; merged_spans.append(move(merged_span)); if (span.range.end() == last_span.range.end()) diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 8a9cf9ee86..7aa47bdc9b 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -503,7 +503,7 @@ void TextEditor::paint_event(PaintEvent& event) } else { painter.draw_text(rect, raw_text, font, alignment, attributes.color); } - if (attributes.underline) { + if (attributes.underline_style.has_value()) { auto bottom_left = [&]() { auto point = rect.bottom_left().translated(0, 1); @@ -2493,7 +2493,7 @@ void TextEditor::on_search_results(GUI::TextRange current, Vector<GUI::TextRange span.attributes.color = Color::from_argb(0xff000000); // So text without spans from a highlighter will have color if (i == m_search_result_index) { span.attributes.bold = true; - span.attributes.underline = true; + span.attributes.underline_style = Gfx::TextAttributes::UnderlineStyle::Solid; } spans.append(move(span)); } diff --git a/Userland/Libraries/LibGfx/TextAttributes.h b/Userland/Libraries/LibGfx/TextAttributes.h index e1f7b4850e..c628d78691 100644 --- a/Userland/Libraries/LibGfx/TextAttributes.h +++ b/Userland/Libraries/LibGfx/TextAttributes.h @@ -20,11 +20,10 @@ struct TextAttributes { Color color; Optional<Color> background_color {}; - bool underline { false }; bool bold { false }; + Optional<UnderlineStyle> underline_style {}; Optional<Color> underline_color {}; - UnderlineStyle underline_style { UnderlineStyle::Solid }; }; } diff --git a/Userland/Libraries/LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.cpp b/Userland/Libraries/LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.cpp index fc7950edf3..88f67cabb8 100644 --- a/Userland/Libraries/LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.cpp +++ b/Userland/Libraries/LibWeb/CSS/SyntaxHighlighter/SyntaxHighlighter.cpp @@ -131,7 +131,7 @@ void SyntaxHighlighter::rehighlight(Palette const& palette) case Parser::Token::Type::BadUrl: case Parser::Token::Type::BadString: // FIXME: Error highlighting color in palette? - highlight(token.start_position().line, token.start_position().column, token.end_position().line, token.end_position().column, { Color(Color::NamedColor::Red), {}, false, true }, token.type()); + highlight(token.start_position().line, token.start_position().column, token.end_position().line, token.end_position().column, { Color(Color::NamedColor::Red), {}, true }, token.type()); break; case Parser::Token::Type::EndOfFile: diff --git a/Userland/Libraries/LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.cpp b/Userland/Libraries/LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.cpp index 7b94272def..782750ff46 100644 --- a/Userland/Libraries/LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.cpp +++ b/Userland/Libraries/LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.cpp @@ -153,7 +153,7 @@ void SyntaxHighlighter::rehighlight(Palette const& palette) token->start_position().column + token_start_offset, token->start_position().line, token->start_position().column + token_start_offset + token->tag_name().length(), - { palette.syntax_keyword(), {}, false, true }, + { palette.syntax_keyword(), {}, true }, token->is_start_tag() ? AugmentedTokenKind::OpenTag : AugmentedTokenKind::CloseTag); token->for_each_attribute([&](auto& attribute) { diff --git a/Userland/Shell/SyntaxHighlighter.cpp b/Userland/Shell/SyntaxHighlighter.cpp index 2172f740d0..eb4f3f6bcb 100644 --- a/Userland/Shell/SyntaxHighlighter.cpp +++ b/Userland/Shell/SyntaxHighlighter.cpp @@ -80,7 +80,7 @@ private: if (node->path()->is_bareword()) { auto& span = span_for_node(node->path()); span.attributes.color = m_palette.link(); - span.attributes.underline = true; + span.attributes.underline_style = Gfx::TextAttributes::UnderlineStyle::Solid; } else { NodeVisitor::visit(node); } @@ -479,7 +479,7 @@ private: NodeVisitor::visit(node); auto& span = span_for_node(node); - span.attributes.underline = true; + span.attributes.underline_style = Gfx::TextAttributes::UnderlineStyle::Solid; span.attributes.background_color = Color(Color::NamedColor::MidRed).lightened(1.3f).with_alpha(128); span.attributes.color = m_palette.base_text(); } |