mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +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
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace GUI::GML {
|
||||
|
||||
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::LeftCurly:
|
||||
|
@ -21,7 +21,7 @@ static Syntax::TextStyle style_for_token_type(Gfx::Palette const& palette, Token
|
|||
case Token::Type::ClassMarker:
|
||||
return { palette.syntax_keyword() };
|
||||
case Token::Type::ClassName:
|
||||
return { palette.syntax_identifier(), true };
|
||||
return { palette.syntax_identifier(), {}, true };
|
||||
case Token::Type::Identifier:
|
||||
return { palette.syntax_identifier() };
|
||||
case Token::Type::JsonValue:
|
||||
|
@ -54,9 +54,7 @@ void SyntaxHighlighter::rehighlight(Palette const& palette)
|
|||
GUI::TextDocumentSpan span;
|
||||
span.range.set_start({ token.m_start.line, token.m_start.column });
|
||||
span.range.set_end({ token.m_end.line, token.m_end.column });
|
||||
auto style = style_for_token_type(palette, token.m_type);
|
||||
span.attributes.color = style.color;
|
||||
span.attributes.bold = style.bold;
|
||||
span.attributes = style_for_token_type(palette, token.m_type);
|
||||
span.is_skippable = false;
|
||||
span.data = static_cast<u64>(token.m_type);
|
||||
spans.append(span);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue