summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCMake/CMakeCache
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-03-15 12:49:17 +0000
committerAndreas Kling <kling@serenityos.org>2023-03-15 14:55:49 +0100
commit406a7ea577f5044e39afd2911de190609b322d23 (patch)
tree3fbfd8285a553b6a7cdce2ab08006aec0eeefef1 /Userland/Libraries/LibCMake/CMakeCache
parent6d8f046fd047bca5f476cb48ec42fa9ce4e1d11f (diff)
downloadserenity-406a7ea577f5044e39afd2911de190609b322d23.zip
LibSyntax+Libraries: Replace TextStyle with Gfx::TextAttributes
Rather than creating a TextStyle struct, and then copying its fields over to a TextAttributes, let's just create a TextAttributes to start with. This also simplifies the syntax highlighting code by letting us define underlines along with the other text styling.
Diffstat (limited to 'Userland/Libraries/LibCMake/CMakeCache')
-rw-r--r--Userland/Libraries/LibCMake/CMakeCache/SyntaxHighlighter.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/Userland/Libraries/LibCMake/CMakeCache/SyntaxHighlighter.cpp b/Userland/Libraries/LibCMake/CMakeCache/SyntaxHighlighter.cpp
index f57a209269..ad83a04091 100644
--- a/Userland/Libraries/LibCMake/CMakeCache/SyntaxHighlighter.cpp
+++ b/Userland/Libraries/LibCMake/CMakeCache/SyntaxHighlighter.cpp
@@ -9,7 +9,7 @@
namespace CMake::Cache {
-static Syntax::TextStyle style_for_token_type(Gfx::Palette const& palette, Token::Type type)
+static Gfx::TextAttributes style_for_token_type(Gfx::Palette const& palette, Token::Type type)
{
switch (type) {
case Token::Type::Comment:
@@ -25,7 +25,7 @@ static Syntax::TextStyle style_for_token_type(Gfx::Palette const& palette, Token
case Token::Type::Value:
return { palette.syntax_string() };
case Token::Type::Garbage:
- return { palette.red() };
+ return { palette.red(), {}, false, Gfx::TextAttributes::UnderlineStyle::Wavy, palette.red() };
default:
return { palette.base_text() };
}
@@ -50,13 +50,7 @@ void SyntaxHighlighter::rehighlight(Gfx::Palette const& palette)
if (!span.range.is_valid())
return;
- auto style = style_for_token_type(palette, type);
- span.attributes.color = style.color;
- span.attributes.bold = style.bold;
- if (type == Token::Type::Garbage) {
- span.attributes.underline_color = palette.red();
- span.attributes.underline_style = Gfx::TextAttributes::UnderlineStyle::Wavy;
- }
+ span.attributes = style_for_token_type(palette, type);
span.is_skippable = false;
span.data = static_cast<u64>(type);
spans.append(move(span));