Patch #1810 2007-01-08 06:52

mcdave

"Fold All" Options within Editor Configuration
Download
1810-Fold_All_Optio.patch (126.2 KB)
Category
Application::FeatureAdd
Status
Rejected
Close date
2007-04-12 13:02
Assigned to
 
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp    (revision 3463)
+++ src/sdk/cbeditor.cpp    (working copy)
@@ -1480,22 +1480,28 @@
 bool cbEditor::DoFoldLine(int line, int fold)
 {
     int level = m_pControl->GetFoldLevel(line);
+    ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
     if ((level & wxSCI_FOLDLEVELHEADERFLAG) &&
             (wxSCI_FOLDLEVELBASE == (level & wxSCI_FOLDLEVELNUMBERMASK))) //Check for top fold headers
     {
-        bool expand = false;
-        int maxLine = m_pControl->GetLastChild(line, -1);
-        if (fold == 2) // toggle
-            expand = !m_pControl->GetFoldExpanded(line);
-        else
-            expand = fold == 0;
-        m_pControl->SetFoldExpanded(line, expand);
-        if (maxLine > line)
+        if (mgr->ReadInt(_T("/folding/fold_all_options"), 0) == 0 ||
+            mgr->ReadInt(_T("/folding/fold_all_options"), 0) == 2 ||
+            fold != 1)
         {
-            if (expand)
-                m_pControl->ShowLines(line + 1, maxLine);
+            bool expand = false;
+            int maxLine = m_pControl->GetLastChild(line, -1);
+            if (fold == 2) // toggle
+                expand = !m_pControl->GetFoldExpanded(line);
             else
-                m_pControl->HideLines(line + 1, maxLine);
+                expand = fold == 0;
+            m_pControl->SetFoldExpanded(line, expand);
+            if (maxLine > line)
+            {
+                if (expand)
+                    m_pControl->ShowLines(line + 1, maxLine);
+                else
+                    m_pControl->HideLines(line + 1, maxLine);
+            }
         }
         return true;
     }
@@ -1505,19 +1511,28 @@
     if ((level & wxSCI_FOLDLEVELHEADERFLAG) &&
             (wxSCI_FOLDLEVELBASE < (level & wxSCI_FOLDLEVELNUMBERMASK))) //Check for sub fold headers
     {
-        bool expand = false;
-        int maxLine = m_pControl->GetLastChild(line, -1);
-        if (fold == 2) // toggle
-            expand = !m_pControl->GetFoldExpanded(line);
-        else
-            expand = fold == 0;
-        m_pControl->SetFoldExpanded(line, expand);
-        if (maxLine > line)
+        if (mgr->ReadInt(_T("/folding/fold_all_options"), 0) == 1 ||
+            mgr->ReadInt(_T("/folding/fold_all_options"), 0) == 2 ||
+            fold != 1)
         {
-            if (expand)
-                m_pControl->ShowLines(line + 1, maxLine);
-            else
-                m_pControl->HideLines(line + 1, maxLine);
+            int thisLevel = (level & wxSCI_FOLDLEVELNUMBERMASK);
+            if (thisLevel <= (mgr->ReadInt(_T("/folding/fold_sub_depth"), 0) + wxSCI_FOLDLEVELBASE) || fold != 1)
+            {
+                bool expand = false;
+                int maxLine = m_pControl->GetLastChild(line, -1);
+                if (fold == 2) // toggle
+                    expand = !m_pControl->GetFoldExpanded(line);
+                else
+                    expand = fold == 0;
+                m_pControl->SetFoldExpanded(line, expand);
+                if (maxLine > line)
+                {
+                    if (expand)
+                        m_pControl->ShowLines(line + 1, maxLine);
+                    else
+                        m_pControl->HideLines(line + 1, maxLine);
+                }
+            }
         }
         return true;
     }
Index: src/sdk/editorconfigurationdlg.cpp
===================================================================
--- src/sdk/editorconfigurationdlg.cpp    (revision 3463)
+++ src/sdk/editorconfigurationdlg.cpp    (working copy)
@@ -156,6 +156,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, "spnSubLevelDepth", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/folding/fold_sub_depth"), 1));
+    XRCCTRL(*this, "rbFoldAllOptions", wxRadioBox)->SetSelection(cfg->ReadInt(_T("/folding/fold_all_options"), 0));
 
     //gutter
     wxColour gutterColour = cfg->ReadColour(_T("/gutter/colour"), *wxLIGHT_GREY);
@@ -871,6 +873,8 @@
         cfg->Write(_T("/folding/fold_preprocessor"),     XRCCTRL(*this, "chkFoldPreprocessor", wxCheckBox)->GetValue());
         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/fold_sub_depth"),         XRCCTRL(*this, "spnSubLevelDepth", wxSpinCtrl)->GetValue());
+        cfg->Write(_T("/folding/fold_all_options"),    XRCCTRL(*this, "rbFoldAllOptions", wxRadioBox)->GetSelection());
 
         //eol
         cfg
download for full patch...
mcdave 2007-01-08 06:55

This patch adds a wxRadioBox and a wxSpinControl to the folding tab within th editor options dialog to facilitate the selection of which folds get fold when a "Fold All" is done. Please note that the patch is huge due to the fact that the whole xrc file is added (I couldn't change it, sorry). The rest of the changes is minor. Enjoy

mandrav 2007-04-12 13:02

OK, please re-submit this patch. Our code has changed since your original submission (our fault for not having a look at this patch earlier). Also please try to post a diff file for the xrc too, instead of the whole file.

Sorry for the inconvenience and thank you.