Patch #2310 2008-01-01 15:51

jgm

Adds new options to the Foldings editor
Download
2310-Adds_new_optio.patch (11.0 KB)
Category
Application::FeatureAdd
Status
Accepted
Close date
2008-01-10 10:26
Assigned to
 
Index: src/sdk/editorconfigurationdlg.cpp
===================================================================
--- src/sdk/editorconfigurationdlg.cpp    (revision 4764)
+++ src/sdk/editorconfigurationdlg.cpp    (working copy)
@@ -160,6 +160,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, "chkUnderlineFoldedLine", wxCheckBox)->SetValue(cfg->ReadBool(_T("/folding/underline_folded_line"), true));
+    XRCCTRL(*this, "lstIndicators", wxChoice)->SetSelection(cfg->ReadInt(_T("/folding/indicator"), 2));
 
     //gutter
     wxColour gutterColour = cfg->ReadColour(_T("/gutter/colour"), *wxLIGHT_GREY);
@@ -898,6 +900,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/underline_folded_line"), XRCCTRL(*this, "chkUnderlineFoldedLine", wxCheckBox)->GetValue());
+        cfg->Write(_T("/folding/indicator"),             XRCCTRL(*this, "lstIndicators", wxChoice)->GetSelection());
 
         //eol
         cfg->Write(_T("/show_eol"),                     XRCCTRL(*this, "chkShowEOL", wxCheckBox)->GetValue());
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp    (revision 4764)
+++ src/sdk/cbeditor.cpp    (working copy)
@@ -631,6 +631,21 @@
     }
 }
 
+void cbEditor::SetMarkerStyle(int marker, int markerType, wxColor fore, wxColor back)
+{
+    cbStyledTextCtrl* ctrl = GetControl();
+
+    ctrl->MarkerDefine(marker, markerType);
+    ctrl->MarkerSetForeground(marker, fore);
+    ctrl->MarkerSetBackground(marker, back);
+}
+
+void cbEditor::UnderlineFoldedLines(bool underline)
+{
+    cbStyledTextCtrl* ctrl = GetControl();
+    ctrl->SetFoldFlags(underline? 16 : 0);
+}
+
 cbStyledTextCtrl* cbEditor::CreateEditor()
 {
     m_ID = wxNewId();
@@ -845,6 +860,10 @@
     m_pData->m_ensure_consistent_line_ends = mgr->ReadBool(_T("/eol/ensure_consistent_line_ends"), false);
 
     InternalSetEditorStyleBeforeFileOpen(m_pControl);
+
+    SetFoldingIndicator(mgr->ReadInt(_T("/folding/indicator")));
+    UnderlineFoldedLines(mgr->ReadBool(_T("/folding/underline_folded_line")));
+
     if (m_pControl2)
         InternalSetEditorStyleBeforeFileOpen(m_pControl2);
 
@@ -982,6 +1001,7 @@
         control->SetMarginMask(2, wxSCI_MASK_FOLDERS);
         control->SetMarginSensitive(2, 1);
 
+        /*Default behaviour
         control->MarkerDefine(wxSCI_MARKNUM_FOLDEROPEN, wxSCI_MARK_BOXMINUS);
         control->MarkerSetForeground(wxSCI_MARKNUM_FOLDEROPEN, wxColour(0xff, 0xff, 0xff));
         control->MarkerSetBackground(wxSCI_MARKNUM_FOLDEROPEN, wxColour(0x80, 0x80, 0x80));
@@ -1003,6 +1023,7 @@
         control->MarkerDefine(wxSCI_MARKNUM_FOLDERMIDTAIL, wxSCI_MARK_TCORNER);
         control->MarkerSetForeground(wxSCI_MARKNUM_FOLDERMIDTAIL, wxColour(0xff, 0xff, 0xff));
         control->MarkerSetBackground(wxSCI_MARKNUM_FOLDERMIDTAIL, wxColour(0x80, 0x80, 0x80));
+        */
     }
     else
         control->SetMarginWidth(2, 0);
@@ -1558,6 +1579,57 @@
     DoFoldAll(2);
 }
 
+void cbEditor::SetFoldingIndicator(int id)
+{
+    //Arrow
+    if(id == 0)
+    {
+        SetMarkerStyle(wxSCI_MARKNUM_FOLDEROPEN, wxSCI_MARK_ARROWDOWN, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
+        SetMarkerStyle(wxSCI_MARKNUM_FOLDER, wxSCI_MARK_ARROW, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
+        SetMarkerStyle(wxSCI_MARKNUM_FOLDERSUB, wxSCI_MARK_BACKGROUND, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
+        SetMarkerStyle(wxSCI_MARKNUM_FOLDERTAIL, wxSCI_MARK_BACKGROUND, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
+        SetMarkerStyle(wxSCI_MARKNUM_FOLDEREND, wxSCI_MARK_ARROW, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
+        SetMarkerStyle(wxSCI_MARKNUM_FOLDEROPENMID, wxSCI_MARK_ARROWDOWN, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
+        SetMarkerStyle(wxSCI_MARKNUM_FOLDERMIDTAIL, wxSCI_MARK_BACKGROUND, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
+    }
+
+    //Circle
+    else if(id == 1)
+    {
+        SetMarkerStyle(wxSCI_MARKNUM_FOLDEROPEN, wxSCI_MARK_CIRCLEMINUS, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
+        SetMarkerStyle(wxSCI_MARKNUM_FOLDER, wxSCI_MARK_CIRCLEPLUS, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
+        SetMarkerStyle(wxSCI_MARKNUM_FOLDERSUB, wxSCI_MARK_VLINE, wxColor(0xff, 0xff, 0xff), w
download for full patch...
jgm 2008-01-01 16:07

This patch includes:

1. Changing the folding indicator (marker):

- arrow

- circle

- squares (default used by codeblocks right now)

- simple

2. Disable/Enable the black underlines on the folded lines

For screen shots here is the forum topic:

http://forums.codeblocks.org/index.php/topic,7543.0.html

mandrav 2008-01-10 10:26

Applied, thanks :)