mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
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.
This commit is contained in:
parent
6d8f046fd0
commit
406a7ea577
10 changed files with 59 additions and 90 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue