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 /src | |
parent | 228fcb30c6b21ef2756a07a3eaf34f6371e80a39 (diff) | |
download | scintilla-mirror-7fb06ca08a70dd9f9549b1e34c7dd38e9ca1413a.tar.gz |
Added SCI_CONTRACTEDFOLDNEXT as a way to find contracted fold headers efficiently.
Diffstat (limited to 'src')
-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 |
4 files changed, 34 insertions, 0 deletions
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); |