summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.cpp6
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.h3
-rw-r--r--Userland/Libraries/LibSyntax/Highlighter.h5
-rw-r--r--Userland/Libraries/LibSyntax/HighlighterClient.h5
4 files changed, 19 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(); }
diff --git a/Userland/Libraries/LibSyntax/Highlighter.h b/Userland/Libraries/LibSyntax/Highlighter.h
index 9903f08379..a5a2cf2ed8 100644
--- a/Userland/Libraries/LibSyntax/Highlighter.h
+++ b/Userland/Libraries/LibSyntax/Highlighter.h
@@ -132,13 +132,18 @@ private:
virtual Vector<GUI::TextDocumentSpan> const& spans() const override { return m_spans; }
virtual void set_span_at_index(size_t index, GUI::TextDocumentSpan span) override { m_spans.at(index) = move(span); }
+ virtual Vector<GUI::TextDocumentFoldingRegion>& folding_regions() override { return m_folding_regions; }
+ virtual Vector<GUI::TextDocumentFoldingRegion> const& folding_regions() const override { return m_folding_regions; }
+
virtual DeprecatedString highlighter_did_request_text() const override { return m_text; }
virtual void highlighter_did_request_update() override { }
virtual GUI::TextDocument& highlighter_did_request_document() override { return m_document; }
virtual GUI::TextPosition highlighter_did_request_cursor() const override { return {}; }
virtual void highlighter_did_set_spans(Vector<GUI::TextDocumentSpan> spans) override { m_spans = move(spans); }
+ virtual void highlighter_did_set_folding_regions(Vector<GUI::TextDocumentFoldingRegion> folding_regions) override { m_folding_regions = folding_regions; }
Vector<GUI::TextDocumentSpan> m_spans;
+ Vector<GUI::TextDocumentFoldingRegion> m_folding_regions;
GUI::TextDocument& m_document;
StringView m_text;
GUI::TextPosition m_start;
diff --git a/Userland/Libraries/LibSyntax/HighlighterClient.h b/Userland/Libraries/LibSyntax/HighlighterClient.h
index 373506b808..3491ca8995 100644
--- a/Userland/Libraries/LibSyntax/HighlighterClient.h
+++ b/Userland/Libraries/LibSyntax/HighlighterClient.h
@@ -21,13 +21,18 @@ public:
virtual Vector<GUI::TextDocumentSpan> const& spans() const = 0;
virtual void set_span_at_index(size_t index, GUI::TextDocumentSpan span) = 0;
+ virtual Vector<GUI::TextDocumentFoldingRegion>& folding_regions() = 0;
+ virtual Vector<GUI::TextDocumentFoldingRegion> const& folding_regions() const = 0;
+
virtual DeprecatedString highlighter_did_request_text() const = 0;
virtual void highlighter_did_request_update() = 0;
virtual GUI::TextDocument& highlighter_did_request_document() = 0;
virtual GUI::TextPosition highlighter_did_request_cursor() const = 0;
virtual void highlighter_did_set_spans(Vector<GUI::TextDocumentSpan>) = 0;
+ virtual void highlighter_did_set_folding_regions(Vector<GUI::TextDocumentFoldingRegion>) = 0;
void do_set_spans(Vector<GUI::TextDocumentSpan> spans) { highlighter_did_set_spans(move(spans)); }
+ void do_set_folding_regions(Vector<GUI::TextDocumentFoldingRegion> folding_regions) { highlighter_did_set_folding_regions(move(folding_regions)); }
void do_update() { highlighter_did_request_update(); }
DeprecatedString get_text() const { return highlighter_did_request_text(); }