mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
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.
This commit is contained in:
parent
b75ed992a6
commit
ab0b4f46f7
5 changed files with 107 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue