From 7fb06ca08a70dd9f9549b1e34c7dd38e9ca1413a Mon Sep 17 00:00:00 2001
From: nyamatongwe
+
SCI_CONTRACTEDFOLDNEXT(int lineStart)
+ Search efficiently for lines that are contracted fold headers.
+ This is useful when saving the user's folding when switching documents or saving folding with a file.
+ The search starts at line number lineStart and continues forwards to the end of the file.
+ lineStart is returned if it is a contracted fold header otherwise the next contracted
+ fold header is returned. If there are no more contracted fold headers then -1 is returned.
SCI_ENSUREVISIBLE(int line)
SCI_ENSUREVISIBLEENFORCEPOLICY(int line)
A line may be hidden because more than one of its parent lines is contracted. Both these
diff --git a/include/Scintilla.h b/include/Scintilla.h
index c20a063f9..54f104437 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -786,6 +786,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_ROTATESELECTION 2606
#define SCI_SWAPMAINANCHORCARET 2607
#define SCI_CHANGELEXERSTATE 2617
+#define SCI_CONTRACTEDFOLDNEXT 2618
#define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002
#define SCI_SETLEXER 4001
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 2516b7134..679bce53b 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -304,7 +304,8 @@ fun void MarkerDeleteAll=2045(int markerNumber,)
# Get a bit mask of all the markers set on a line.
fun int MarkerGet=2046(int line,)
-# Find the next line after lineStart that includes a marker in mask.
+# Find the next line at or after lineStart that includes a marker in mask.
+# Return -1 when no more lines.
fun int MarkerNext=2047(int lineStart, int markerMask)
# Find the previous line before lineStart that includes a marker in mask.
@@ -2090,6 +2091,10 @@ fun void SwapMainAnchorCaret=2607(,)
# there may be a need to redraw.
fun int ChangeLexerState=2617(position start, position end)
+# Find the next line at or after lineStart that is a contracted fold header line.
+# Return -1 when no more lines.
+fun int ContractedFoldNext=2618(int lineStart,)
+
# Start notifying the container of all key presses and commands.
fun void StartRecord=3001(,)
diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx
index f2cc2f07b..8a1b486e7 100644
--- a/src/ContractionState.cxx
+++ b/src/ContractionState.cxx
@@ -193,6 +193,23 @@ bool ContractionState::SetExpanded(int lineDoc, bool expanded_) {
}
}
+int ContractionState::ContractedNext(int lineDocStart) const {
+ if (OneToOne()) {
+ return -1;
+ } else {
+ Check();
+ if (!expanded->ValueAt(lineDocStart)) {
+ return lineDocStart;
+ } else {
+ int lineDocNextChange = expanded->EndRun(lineDocStart);
+ if (lineDocNextChange < LinesInDoc())
+ return lineDocNextChange;
+ else
+ return -1;
+ }
+ }
+}
+
int ContractionState::GetHeight(int lineDoc) const {
if (OneToOne()) {
return 1;
diff --git a/src/ContractionState.h b/src/ContractionState.h
index ba6297512..8e7b39b9b 100644
--- a/src/ContractionState.h
+++ b/src/ContractionState.h
@@ -51,6 +51,7 @@ public:
bool GetExpanded(int lineDoc) const;
bool SetExpanded(int lineDoc, bool expanded);
+ int ContractedNext(int lineDocStart) const;
int GetHeight(int lineDoc) const;
bool SetHeight(int lineDoc, int height);
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 762156c23..bca458037 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -6481,6 +6481,18 @@ void Editor::ToggleContraction(int line) {
}
}
+int Editor::ContractedFoldNext(int lineStart) {
+ for (int line = lineStart; line