diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-02-23 15:33:48 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-28 13:23:55 +0100 |
commit | d169af117d99712eb5d58fc69bb4c91db1d26bea (patch) | |
tree | 5009da5b85595491d4f66d86a2f4f149a68f043b /Userland/Libraries/LibGUI | |
parent | 92b128e20a09a1fba354494b289d9c488e501482 (diff) | |
download | serenity-d169af117d99712eb5d58fc69bb4c91db1d26bea.zip |
LibSyntax+LibGUI: Let syntax highlighters assign folding regions
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/TextEditor.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/TextEditor.h | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 7264da8b6b..75c4399c3d 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -2483,4 +2483,10 @@ void TextEditor::on_search_results(GUI::TextRange current, Vector<GUI::TextRange update(); } +void TextEditor::highlighter_did_set_folding_regions(Vector<GUI::TextDocumentFoldingRegion> folding_regions) +{ + document().set_folding_regions(move(folding_regions)); + recompute_all_visual_lines(); +} + } diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h index 8a9d4132ea..0eb80b2052 100644 --- a/Userland/Libraries/LibGUI/TextEditor.h +++ b/Userland/Libraries/LibGUI/TextEditor.h @@ -281,6 +281,7 @@ protected: int fixed_elements_width() const { return gutter_width() + ruler_width() + folding_indicator_width(); } virtual void highlighter_did_set_spans(Vector<TextDocumentSpan> spans) final { document().set_spans(Syntax::HighlighterClient::span_collection_index, move(spans)); } + virtual void highlighter_did_set_folding_regions(Vector<TextDocumentFoldingRegion> folding_regions) final; private: friend class TextDocumentLine; @@ -299,6 +300,8 @@ private: virtual Vector<TextDocumentSpan>& spans() final { return document().spans(); } virtual Vector<TextDocumentSpan> const& spans() const final { return document().spans(); } virtual void set_span_at_index(size_t index, TextDocumentSpan span) final { document().set_span_at_index(index, move(span)); } + virtual Vector<GUI::TextDocumentFoldingRegion>& folding_regions() final { return document().folding_regions(); }; + virtual Vector<GUI::TextDocumentFoldingRegion> const& folding_regions() const final { return document().folding_regions(); }; virtual void highlighter_did_request_update() final { update(); } virtual DeprecatedString highlighter_did_request_text() const final { return text(); } virtual GUI::TextDocument& highlighter_did_request_document() final { return document(); } |