aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaDoc.html6
-rw-r--r--doc/ScintillaHistory.html5
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface1
-rw-r--r--include/ScintillaTypes.h1
-rw-r--r--src/Editor.cxx29
6 files changed, 33 insertions, 10 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index bcbc88152..dfa138b29 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -7591,6 +7591,12 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){
<td align="left">Toggle between contracted and expanded.</td>
</tr>
+ <tr>
+ <td align="left">SC_FOLDACTION_CONTRACT_EVERY_LEVEL</td>
+ <td align="left">4</td>
+ <td align="left">Used for SCI_FOLDALL only, can be combined with SC_FOLDACTION_CONTRACT or SC_FOLDACTION_TOGGLE to contract all levels instead of only top-level.</td>
+ </tr>
+
</tbody>
</table>
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 08c00bf86..1188fbc00 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -605,6 +605,11 @@
<a href="https://sourceforge.net/p/scintilla/feature-requests/1441/">Feature #1441</a>.
</li>
<li>
+ Add SC_FOLDACTION_CONTRACT_EVERY_LEVEL option to contract every level for
+ SCI_FOLDALL.
+ <a href="https://sourceforge.net/p/scintilla/bugs/2340/">Bug #2340</a>.
+ </li>
+ <li>
Enable multiline regex for gcc and clang when REGEX_MULTILINE defined.
This requires gcc 11.3 or clang 14.
<a href="https://sourceforge.net/p/scintilla/bugs/2338/">Bug #2338</a>.
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 0dacb3c1b..5781674e3 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -598,6 +598,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SC_FOLDACTION_CONTRACT 0
#define SC_FOLDACTION_EXPAND 1
#define SC_FOLDACTION_TOGGLE 2
+#define SC_FOLDACTION_CONTRACT_EVERY_LEVEL 4
#define SCI_FOLDLINE 2237
#define SCI_FOLDCHILDREN 2238
#define SCI_EXPANDCHILDREN 2239
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 646c01a8a..bd6cb76de 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -1563,6 +1563,7 @@ enu FoldAction=SC_FOLDACTION_
val SC_FOLDACTION_CONTRACT=0
val SC_FOLDACTION_EXPAND=1
val SC_FOLDACTION_TOGGLE=2
+val SC_FOLDACTION_CONTRACT_EVERY_LEVEL=4
# Expand or contract a fold header.
fun void FoldLine=2237(line line, FoldAction action)
diff --git a/include/ScintillaTypes.h b/include/ScintillaTypes.h
index ba19b1253..343dec749 100644
--- a/include/ScintillaTypes.h
+++ b/include/ScintillaTypes.h
@@ -302,6 +302,7 @@ enum class FoldAction {
Contract = 0,
Expand = 1,
Toggle = 2,
+ ContractEveryLevel = 4,
};
enum class AutomaticFold {
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 08ee3fc6a..f7d6a784b 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5582,15 +5582,18 @@ void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) {
void Editor::FoldAll(FoldAction action) {
const Sci::Line maxLine = pdoc->LinesTotal();
+ const bool contractAll = FlagSet(action, FoldAction::ContractEveryLevel);
+ action = static_cast<FoldAction>(static_cast<int>(action) & ~static_cast<int>(FoldAction::ContractEveryLevel));
bool expanding = action == FoldAction::Expand;
if (!expanding) {
pdoc->EnsureStyledTo(pdoc->Length());
}
+ Sci::Line line = 0;
if (action == FoldAction::Toggle) {
// Discover current state
- for (Sci::Line lineSeek = 0; lineSeek < maxLine; lineSeek++) {
- if (LevelIsHeader(pdoc->GetFoldLevel(lineSeek))) {
- expanding = !pcs->GetExpanded(lineSeek);
+ for (; line < maxLine; line++) {
+ if (LevelIsHeader(pdoc->GetFoldLevel(line))) {
+ expanding = !pcs->GetExpanded(line);
break;
}
}
@@ -5599,14 +5602,20 @@ void Editor::FoldAll(FoldAction action) {
pcs->SetVisible(0, maxLine-1, true);
pcs->ExpandAll();
} else {
- for (Sci::Line line = 0; line < maxLine; line++) {
+ for (; line < maxLine; line++) {
const FoldLevel level = pdoc->GetFoldLevel(line);
- if (LevelIsHeader(level) &&
- (FoldLevel::Base == LevelNumberPart(level))) {
- SetFoldExpanded(line, false);
- const Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
- if (lineMaxSubord > line) {
- pcs->SetVisible(line + 1, lineMaxSubord, false);
+ if (LevelIsHeader(level)) {
+ if (FoldLevel::Base == LevelNumberPart(level)) {
+ SetFoldExpanded(line, false);
+ const Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
+ if (lineMaxSubord > line) {
+ pcs->SetVisible(line + 1, lineMaxSubord, false);
+ if (!contractAll) {
+ line = lineMaxSubord;
+ }
+ }
+ } else if (contractAll) {
+ SetFoldExpanded(line, false);
}
}
}