mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:57:45 +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
|
@ -11,13 +11,13 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
static Syntax::TextStyle style_for_token_type(Gfx::Palette const& palette, IniToken::Type type)
|
||||
static Gfx::TextAttributes style_for_token_type(Gfx::Palette const& palette, IniToken::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case IniToken::Type::LeftBracket:
|
||||
case IniToken::Type::RightBracket:
|
||||
case IniToken::Type::Section:
|
||||
return { palette.syntax_keyword(), true };
|
||||
return { palette.syntax_keyword(), {}, true };
|
||||
case IniToken::Type::Name:
|
||||
return { palette.syntax_identifier() };
|
||||
case IniToken::Type::Value:
|
||||
|
@ -25,7 +25,7 @@ static Syntax::TextStyle style_for_token_type(Gfx::Palette const& palette, IniTo
|
|||
case IniToken::Type::Comment:
|
||||
return { palette.syntax_comment() };
|
||||
case IniToken::Type::Equal:
|
||||
return { palette.syntax_operator(), true };
|
||||
return { palette.syntax_operator(), {}, true };
|
||||
default:
|
||||
return { palette.base_text() };
|
||||
}
|
||||
|
@ -52,9 +52,7 @@ void IniSyntaxHighlighter::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 = token.m_type == IniToken::Type::Whitespace;
|
||||
span.data = static_cast<u64>(token.m_type);
|
||||
spans.append(span);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue