Patch #3247 2012-01-10 08:19

marazm

Remember folding
Download
3247-Remember_foldi.patch (6.2 KB)
Category
Application::FeatureAdd
Status
Accepted
Close date
2012-06-04 14:05
Assigned to
mortenmacfly
Index: src/include/projectfile.h
===================================================================
--- src/include/projectfile.h    (revision 7666)
+++ src/include/projectfile.h    (working copy)
@@ -32,6 +32,8 @@
 class ProjectFile;
 typedef std::vector<ProjectFile*> ProjectFilesVector;
 
+WX_DEFINE_ARRAY_INT(int, editorFoldLinesArray);
+
 /** Represents a file in a Code::Blocks project. */
 class ProjectFile
 {
@@ -169,6 +171,9 @@
         /** The position of the editor-tab for this file. */
         int editorTabPos; // layout info
 
+        /** Fold lines */
+        wxArrayInt editorFoldLinesArray; // layout info
+
         /** A map for custom builds. Key is compiler ID, value is pfCustomBuild struct. */
         pfCustomBuildMap customBuild;
 
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp    (revision 7666)
+++ src/sdk/cbeditor.cpp    (working copy)
@@ -893,6 +893,13 @@
             }
         }
 
+        ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
+        if (mgr->ReadBool(_T("/folding/show_folds"), true))
+        {
+            for (unsigned int i = 0; i < m_pProjectFile->editorFoldLinesArray.GetCount(); i++)
+                m_pControl->ToggleFold(m_pProjectFile->editorFoldLinesArray[i]);
+        }
+
         m_pProjectFile->editorOpen = true;
 
         if (Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/tab_text_relative"), true))
@@ -939,6 +946,13 @@
             if (GetControl()==m_pControl2)
                 m_pProjectFile->editorSplitActive = 2;
         }
+
+        if (m_pProjectFile->editorFoldLinesArray.GetCount() != 0)
+            m_pProjectFile->editorFoldLinesArray.Clear();
+
+        int i = 0;
+        while ((i = m_pControl->ContractedFoldNext(i)) != -1)
+            m_pProjectFile->editorFoldLinesArray.Add(i++);
     }
 }
 
Index: src/sdk/projectlayoutloader.cpp
===================================================================
--- src/sdk/projectlayoutloader.cpp    (revision 7666)
+++ src/sdk/projectlayoutloader.cpp    (working copy)
@@ -127,27 +127,43 @@
             if (elem->QueryIntAttribute("zoom_2", &getInt) == TIXML_SUCCESS)
                 pf->editorZoom_2 = getInt;
 
-            TiXmlElement* cursor = elem->FirstChildElement();
+            TiXmlElement* cursor = elem->FirstChildElement("Cursor");
             if (cursor)
             {
-                if (cursor->QueryIntAttribute("position", &getInt) == TIXML_SUCCESS)
-                    pf->editorPos = getInt;
-                if (cursor->QueryIntAttribute("topLine", &getInt) == TIXML_SUCCESS)
-                    pf->editorTopLine = getInt;
-                if (pf->editorSplit != cbEditor::stNoSplit)
+                cursor = cursor->FirstChildElement();
+                if (cursor)
                 {
-                    cursor = cursor->NextSiblingElement();
-                    if (cursor)
+                    if (cursor->QueryIntAttribute("position", &getInt) == TIXML_SUCCESS)
+                        pf->editorPos = getInt;
+                    if (cursor->QueryIntAttribute("topLine", &getInt) == TIXML_SUCCESS)
+                        pf->editorTopLine = getInt;
+                    if (pf->editorSplit != cbEditor::stNoSplit)
                     {
-                        if (cursor->QueryIntAttribute("position", &getInt) == TIXML_SUCCESS)
-                            pf->editorPos_2 = getInt;
-                        if (cursor->QueryIntAttribute("topLine", &getInt) == TIXML_SUCCESS)
-                            pf->editorTopLine_2 = getInt;
+                        cursor = cursor->NextSiblingElement();
+                        if (cursor)
+                        {
+                            if (cursor->QueryIntAttribute("position", &getInt) == TIXML_SUCCESS)
+                                pf->editorPos_2 = getInt;
+                            if (cursor->QueryIntAttribute("topLine", &getInt) == TIXML_SUCCESS)
+                                pf->editorTopLine_2 = getInt;
+                        }
                     }
                 }
             }
+
+            TiXmlElement* folding = elem->FirstChildElement("Folding");
+            if (folding)
+            {
+                folding = folding->FirstChildElement();
+                while (folding)
+                {
+                    if (folding->QueryIntAttribute("line", &getInt) == TIXML_SUCCESS)
+                        pf->editorFoldLinesArray.Add(getInt);
+
+                    folding = folding->NextSiblingElement();
+                }
+            }
         }
-
         elem = elem->NextSiblingElement();
     }
 
@@ -190,16 +206,28 @@
             node->SetAttribute("zoom_1", f->editorZoom);
             node->SetAttribute("zoom_2", f->editorZoom_2);
 
-            TiXmlElement* cursor_1 = static_cast<TiXmlElement*>(node->InsertEndChild(TiXmlElement("Cursor1")));
+
+            TiXmlElement* cursor = static_c
download for full patch...
tpetrov 2012-01-28 21:57