Index: src/sdk/editorconfigurationdlg.cpp
===================================================================
--- src/sdk/editorconfigurationdlg.cpp (revision 4581)
+++ src/sdk/editorconfigurationdlg.cpp (working copy)
@@ -159,6 +159,8 @@
XRCCTRL(*this, "chkFoldPreprocessor", wxCheckBox)->SetValue(cfg->ReadBool(_T("/folding/fold_preprocessor"), false));
XRCCTRL(*this, "chkFoldComments", wxCheckBox)->SetValue(cfg->ReadBool(_T("/folding/fold_comments"), true));
XRCCTRL(*this, "chkFoldXml", wxCheckBox)->SetValue(cfg->ReadBool(_T("/folding/fold_xml"), true));
+ XRCCTRL(*this, "chkFoldLimit", wxCheckBox)->SetValue(cfg->ReadBool(_T("/folding/limit"), false));
+ XRCCTRL(*this, "spnFoldLimitLevel", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/folding/limit_level"), 1));
//gutter
wxColour gutterColour = cfg->ReadColour(_T("/gutter/colour"), *wxLIGHT_GREY);
@@ -345,7 +347,7 @@
wxXmlResource::Get()->AttachUnknownControl(_T("txtColoursSample"), m_TextColourControl);
}
-
+
int breakLine = -1;
int debugLine = -1;
int errorLine = -1;
@@ -902,6 +904,10 @@
cfg->Write(_T("/folding/fold_comments"), XRCCTRL(*this, "chkFoldComments", wxCheckBox)->GetValue());
cfg->Write(_T("/folding/fold_xml"), XRCCTRL(*this, "chkFoldXml", wxCheckBox)->GetValue());
+ cfg->Write(_T("/folding/limit"), XRCCTRL(*this, "chkFoldLimit", wxCheckBox)->GetValue());
+ cfg->Write(_T("/folding/limit_level"), XRCCTRL(*this, "spnFoldLimitLevel", wxSpinCtrl)->GetValue());
+
+
//eol
cfg->Write(_T("/show_eol"), XRCCTRL(*this, "chkShowEOL", wxCheckBox)->GetValue());
cfg->Write(_T("/eol/strip_trailing_spaces"), XRCCTRL(*this, "chkStripTrailings", wxCheckBox)->GetValue());
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp (revision 4581)
+++ src/sdk/cbeditor.cpp (working copy)
@@ -368,6 +368,9 @@
int m_LastMarginMenuLine;
int m_LastDebugLine;
+ bool mFoldingLimit;
+ int mFoldingLimitLevel;
+
wxFontEncoding m_encoding;
bool m_useByteOrderMark;
int m_byteOrderMarkLength;
@@ -909,6 +912,10 @@
SetEditorTitle(m_Shortname);
}
+ // Folding properties.
+ m_pData->mFoldingLimit = mgr->ReadBool(_T("/folding/limit"), false);
+ m_pData->mFoldingLimitLevel = mgr->ReadInt(_T("/folding/limit_level"), 1);
+
// EOL properties
m_pData->m_strip_trailing_spaces = mgr->ReadBool(_T("/eol/strip_trailing_spaces"), true);
m_pData->m_ensure_final_line_end = mgr->ReadBool(_T("/eol/ensure_final_line_end"), true);
@@ -1588,27 +1595,31 @@
cbAssert(m_pControl2);
cbStyledTextCtrl* ctrl = GetControl();
int level = ctrl->GetFoldLevel(line);
+
+ // The fold parameter is the type of folding action requested
+ // 0 = Unfold; 1 = Fold; 2 = Toggle folding.
+
+ // Check if the line is a header (fold point).
if (level & wxSCI_FOLDLEVELHEADERFLAG)
{
- bool expand = false;
- if (fold == 2) // toggle
- {
- ctrl->ToggleFold(line);
- return true;
- }
- else
- expand = fold == 0;
- bool IsCurLineFolded = ctrl->GetFoldExpanded(line);
- /* -------------------------------------------------------
- * fold = 0 (Unfold), 1 (fold), 2 (toggle)
- * So check if fold = 0 then GetFoldExpanded(line) = false
- * before toggling it and vice-versa
- * -----------------------------------------------------*/
- if ((!IsCurLineFolded && expand) || (IsCurLineFolded && !expand))
- {
- ctrl->ToggleFold(line);
- return true;
- }
+ bool IsExpanded = ctrl->GetFoldExpanded(line);
+
+ // If a fold/unfold request is issued when the block is already
+ // folded/unfolded, ignore the request.
+ if (fold == 0 && IsExpanded) return true;
+ if (fold == 1 && !IsExpanded) return true;
+
+ // Apply the folding level limit only if the current block will be
+ // folded (that means it's currently expanded), folding level limiter
+ // must be enabled of course. Unfolding will not be affected.
+ if (m_pData->mFoldingLimit && IsExpanded)
+ {
+ if ((level & wxSCI_FOLDLEVELNUMBERMASK) > (wxSCI_FOLDLEVELBASE + m_pData->mFoldingLimitLevel-1))
+ return false;
+ }
+
+ ctrl->ToggleFold(line);
+ return true;
}
return false;
}
Index: src/sdk/resources/editor_configuration.xrc
===================================================================
--- src/sdk/resources/editor_configuration.xrc (revision 4581)
+++ src/sdk/resources/editor_configuration.xrc (working copy)
@@ -9,7 +9,6 @@
<object class="sizeritem">
<object class="wxStaticText" name="lblBigTitle">
download for full patch...
History
xayc 2007-11-08 15:45
Comments about this patch are in the forums.
http://forums.codeblocks.org/index.php/topic,7193.msg54923.html
mandrav 2007-12-12 14:35
The patch doesn't apply in revision 4726.
Can you update it?
kkez 2008-01-16 10:47