Patch #1629 2006-11-06 23:02

dmoore

New editor option for search/replace with regex: POSIX style
Download
1629-New_editor_opt.patch (4.5 KB)
Category
 
Status
Accepted
Close date
2006-11-25 10:26
Assigned to
 
Index: src/sdk/editorconfigurationdlg.cpp
===================================================================
--- src/sdk/editorconfigurationdlg.cpp    (revision 3186)
+++ src/sdk/editorconfigurationdlg.cpp    (working copy)
@@ -122,6 +122,7 @@
        XRCCTRL(*this, "chkTabIndents", wxCheckBox)->SetValue(cfg->ReadBool(_T("/tab_indents"), true));
        XRCCTRL(*this, "chkBackspaceUnindents", wxCheckBox)->SetValue(cfg->ReadBool(_T("/backspace_unindents"), true));
        XRCCTRL(*this, "chkWordWrap", wxCheckBox)->SetValue(cfg->ReadBool(_T("/word_wrap"), false));
+       XRCCTRL(*this, "chkPosixRegex", wxCheckBox)->SetValue(cfg->ReadBool(_T("/use_posix_style_regexes"), false));
        XRCCTRL(*this, "chkShowLineNumbers", wxCheckBox)->SetValue(cfg->ReadBool(_T("/show_line_numbers"), true));
        XRCCTRL(*this, "chkHighlightCaretLine", wxCheckBox)->SetValue(cfg->ReadBool(_T("/highlight_caret_line"), false));
        XRCCTRL(*this, "spnTabSize", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/tab_size"), 4));
@@ -835,12 +836,16 @@
         cfg->Write(_T("/tab_indents"),             XRCCTRL(*this, "chkTabIndents", wxCheckBox)->GetValue());
         cfg->Write(_T("/backspace_unindents"),     XRCCTRL(*this, "chkBackspaceUnindents", wxCheckBox)->GetValue());
         cfg->Write(_T("/word_wrap"),             XRCCTRL(*this, "chkWordWrap", wxCheckBox)->GetValue());
+        cfg->Write(_T("/use_posix_style_regexes"),XRCCTRL(*this, "chkPosixRegex", wxCheckBox)->GetValue());
+
         cfg->Write(_T("/show_line_numbers"),     XRCCTRL(*this, "chkShowLineNumbers", wxCheckBox)->GetValue());
         cfg->Write(_T("/highlight_caret_line"), XRCCTRL(*this, "chkHighlightCaretLine", wxCheckBox)->GetValue());
         cfg->Write(_T("/tab_size"),             XRCCTRL(*this, "spnTabSize", wxSpinCtrl)->GetValue());
         cfg->Write(_T("/view_whitespace"),      XRCCTRL(*this, "cmbViewWS", wxComboBox)->GetSelection());
         cfg->Write(_T("/tab_text_relative"),    XRCCTRL(*this, "rbTabText", wxRadioBox)->GetSelection() ? true : false);

+        // find & replace, regex searches
+
         //caret
         cfg->Write(_T("/caret/width"), XRCCTRL(*this, "spnCaretWidth", wxSpinCtrl)->GetValue());
         cfg->Write(_T("/caret/colour"), XRCCTRL(*this, "btnCaretColour", wxButton)->GetBackgroundColour());
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp    (revision 3186)
+++ src/sdk/editormanager.cpp    (working copy)
@@ -1423,7 +1423,11 @@
     if (data->matchCase)
         flags |= wxSCI_FIND_MATCHCASE;
     if (data->regEx)
+    {
         flags |= wxSCI_FIND_REGEXP;
+        if (Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/use_posix_style_regexes"), false))
+            flags |= wxSCI_FIND_POSIX;
+    }

     control->BeginUndoAction();
     int pos = -1;
@@ -1658,7 +1662,11 @@
     if (data->matchCase)
         flags |= wxSCI_FIND_MATCHCASE;
     if (data->regEx)
+    {
         flags |= wxSCI_FIND_REGEXP;
+        if (Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/use_posix_style_regexes"), false))
+            flags |= wxSCI_FIND_POSIX;
+    }

     bool replace = false;
     bool confirm = true;
@@ -1884,7 +1892,11 @@
     if (data->matchCase)
         flags |= wxSCI_FIND_MATCHCASE;
     if (data->regEx)
+    {
         flags |= wxSCI_FIND_REGEXP;
+        if (Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/use_posix_style_regexes"), false))
+            flags |= wxSCI_FIND_POSIX;
+    }

     int pos = -1;
     // avoid infinite loop when wrapping search around, eventually crashing WinLogon O.O
Index: src/sdk/resources/editor_configuration.xrc
===================================================================
--- src/sdk/resources/editor_configuration.xrc    (revision 3186)
+++ src/sdk/resources/editor_configuration.xrc    (working copy)
@@ -308,6 +308,12 @@
                             </object>
                             <object class="sizeritem">
                               <flag>wxALIGN_LEFT|wxALIGN_TOP</flag>
+                              <object class="wxCheckBox" name="chkPosixRegex">
+                                <label>Use POSIX style for RegEx searches</label>
+                              </object>
+                            </object>
+                            <object class="sizeritem">
+                              <flag>wxALIGN_LEFT|wxALIGN_TOP</flag>
                               <object class="wxCheckBox" name="chkShowLineNumbers">
                                 <label>Show line numbers</label>
                               </object>