summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/TextDocument.h
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2022-03-29 16:31:26 +0300
committerAndreas Kling <kling@serenityos.org>2022-03-29 17:45:36 +0200
commitab0b4f46f7a440d16ff5e58d3f63e38daa9c59fb (patch)
tree67d831b27f2fc30738b7455246fa5574f8b2673c /Userland/Libraries/LibGUI/TextDocument.h
parentb75ed992a651825d7105266a3c23fb49f6585dd9 (diff)
downloadserenity-ab0b4f46f7a440d16ff5e58d3f63e38daa9c59fb.zip
LibGUI: Support multiple layers of TextDocument spans
TextDocument::set_spans() now also takes a "span collection index" argument. TextDocument keeps a map between a span collection index and its spans. It merges the spans from all collections into a single set of spans whenever set_spans() is called. This allows us to style a document with multiple layers of spans, where as previously we only supported a single layer of spans that was set from the SyntaxHighlighter.
Diffstat (limited to 'Userland/Libraries/LibGUI/TextDocument.h')
-rw-r--r--Userland/Libraries/LibGUI/TextDocument.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/TextDocument.h b/Userland/Libraries/LibGUI/TextDocument.h
index db611dda69..ee43a0cf2b 100644
--- a/Userland/Libraries/LibGUI/TextDocument.h
+++ b/Userland/Libraries/LibGUI/TextDocument.h
@@ -62,7 +62,7 @@ public:
const TextDocumentLine& line(size_t line_index) const { return m_lines[line_index]; }
TextDocumentLine& line(size_t line_index) { return m_lines[line_index]; }
- void set_spans(Vector<TextDocumentSpan> spans) { m_spans = move(spans); }
+ void set_spans(u32 span_collection_index, Vector<TextDocumentSpan> spans);
bool set_text(StringView, AllowCallback = AllowCallback::Yes);
@@ -136,7 +136,10 @@ protected:
explicit TextDocument(Client* client);
private:
+ void merge_span_collections();
+
NonnullOwnPtrVector<TextDocumentLine> m_lines;
+ HashMap<u32, Vector<TextDocumentSpan>> m_span_collections;
Vector<TextDocumentSpan> m_spans;
HashTable<Client*> m_clients;