1
Fork 0
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:
Andreas Kling 2019-10-27 16:10:07 +01:00
parent 1bcbc3f827
commit f1c6193d6d
6 changed files with 302 additions and 240 deletions

View file

@ -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();
}