diff options
author | nyamatongwe <unknown> | 2010-09-24 13:14:40 +1000 |
---|---|---|
committer | nyamatongwe <unknown> | 2010-09-24 13:14:40 +1000 |
commit | 7fb06ca08a70dd9f9549b1e34c7dd38e9ca1413a (patch) | |
tree | f16cf3c34093167f55e567d7a02edeef19675d19 | |
parent | 228fcb30c6b21ef2756a07a3eaf34f6371e80a39 (diff) | |
download | scintilla-mirror-7fb06ca08a70dd9f9549b1e34c7dd38e9ca1413a.tar.gz |
Added SCI_CONTRACTEDFOLDNEXT as a way to find contracted fold headers efficiently.
-rw-r--r-- | doc/ScintillaDoc.html | 8 | ||||
-rw-r--r-- | include/Scintilla.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 7 | ||||
-rw-r--r-- | src/ContractionState.cxx | 17 | ||||
-rw-r--r-- | src/ContractionState.h | 1 | ||||
-rw-r--r-- | src/Editor.cxx | 15 | ||||
-rw-r--r-- | src/Editor.h | 1 |
7 files changed, 49 insertions, 1 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index fbffd64aa..02747ee69 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -4699,6 +4699,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <a class="message" href="#SCI_SETFOLDEXPANDED">SCI_SETFOLDEXPANDED(int line, bool expanded)</a><br /> <a class="message" href="#SCI_GETFOLDEXPANDED">SCI_GETFOLDEXPANDED(int line)</a><br /> + <a class="message" href="#SCI_CONTRACTEDFOLDNEXT">SCI_CONTRACTEDFOLDNEXT(int lineStart)</a><br /> <a class="message" href="#SCI_TOGGLEFOLD">SCI_TOGGLEFOLD(int line)</a><br /> <a class="message" href="#SCI_ENSUREVISIBLE">SCI_ENSUREVISIBLE(int line)</a><br /> <a class="message" href="#SCI_ENSUREVISIBLEENFORCEPOLICY">SCI_ENSUREVISIBLEENFORCEPOLICY(int @@ -4849,6 +4850,13 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ until you had finished. See <code>SciTEBase::FoldAll()</code> and <code>SciTEBase::Expand()</code> for examples of the use of these messages.</p> + <p><b id="SCI_CONTRACTEDFOLDNEXT">SCI_CONTRACTEDFOLDNEXT(int lineStart)</b><br /> + 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 <code>lineStart</code> and continues forwards to the end of the file. + <code>lineStart</code> 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.</p> + <p><b id="SCI_ENSUREVISIBLE">SCI_ENSUREVISIBLE(int line)</b><br /> <b id="SCI_ENSUREVISIBLEENFORCEPOLICY">SCI_ENSUREVISIBLEENFORCEPOLICY(int line)</b><br /> 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<pdoc->LinesTotal(); ) { + if (!cs.GetExpanded(line) && (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG)) + return line; + line = cs.ContractedNext(line+1); + if (line < 0) + return -1; + } + + return -1; +} + /** * Recurse up from this line to find any folds that prevent this line from being visible * and unfold them all. @@ -7866,6 +7878,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { ToggleContraction(wParam); break; + case SCI_CONTRACTEDFOLDNEXT: + return ContractedFoldNext(wParam); + case SCI_ENSUREVISIBLE: EnsureLineVisible(wParam, false); break; diff --git a/src/Editor.h b/src/Editor.h index aa4fc9236..3f36c9088 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -508,6 +508,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void Expand(int &line, bool doExpand); void ToggleContraction(int line); + int ContractedFoldNext(int lineStart); void EnsureLineVisible(int lineDoc, bool enforcePolicy); int GetTag(char *tagValue, int tagNumber); int ReplaceTarget(bool replacePatterns, const char *text, int length=-1); |