mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 22:48:11 +00:00
LibGUI: Move GTextDocument out of GTextEditor
The idea here is to decouple the document from the editor widget so you could have multiple editors being views onto the same document. This doesn't work yet, since the document and editor are coupled in various ways still (including a per-line back-pointer to the editor.)
This commit is contained in:
parent
1bcbc3f827
commit
f1c6193d6d
6 changed files with 302 additions and 240 deletions
|
@ -286,12 +286,12 @@ static void rehighlight()
|
|||
CppLexer lexer(text);
|
||||
auto tokens = lexer.lex();
|
||||
|
||||
Vector<GTextEditor::Span> spans;
|
||||
Vector<GTextDocumentSpan> spans;
|
||||
for (auto& token : tokens) {
|
||||
#ifdef DEBUG_SYNTAX_HIGHLIGHTING
|
||||
dbg() << token.to_string() << " @ " << token.m_start.line << ":" << token.m_start.column << " - " << token.m_end.line << ":" << token.m_end.column;
|
||||
#endif
|
||||
GTextEditor::Span span;
|
||||
GTextDocumentSpan 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(token.m_type);
|
||||
|
@ -299,7 +299,7 @@ static void rehighlight()
|
|||
span.font = style.font;
|
||||
spans.append(span);
|
||||
}
|
||||
current_editor().set_spans(spans);
|
||||
current_editor().document().set_spans(spans);
|
||||
current_editor().update();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue