Patch #1571 2006-10-18 22:47

pecan

Find dlg wrap and Find uses selected text
Download
1571-Find_dlg_wrap.patch (13.6 KB)
Category
 
Status
Closed
Close date
2006-10-26 20:44
Assigned to
 
Index: src/sdk/editorconfigurationdlg.cpp
===================================================================
--- src/sdk/editorconfigurationdlg.cpp    (revision 3103)
+++ src/sdk/editorconfigurationdlg.cpp    (working copy)
@@ -127,7 +127,6 @@
        XRCCTRL(*this, "spnTabSize", wxSpinCtrl)->SetValue(cfg->ReadInt(_T("/tab_size"), 4));
        XRCCTRL(*this, "cmbViewWS", wxComboBox)->SetSelection(cfg->ReadInt(_T("/view_whitespace"), 0));
        XRCCTRL(*this, "rbTabText", wxRadioBox)->SetSelection(cfg->ReadBool(_T("/tab_text_relative"), true) ? 1 : 0);
-       XRCCTRL(*this, "chkAutoWrapSearch", wxCheckBox)->SetValue(cfg->ReadBool(_T("/auto_wrap_search"), true));
 
        // end-of-line
 // NOTE: a same block of code is in cbeditor.cpp (CreateEditor)
@@ -841,7 +840,6 @@
         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);
-        cfg->Write(_T("/auto_wrap_search"),     XRCCTRL(*this, "chkAutoWrapSearch", wxCheckBox)->GetValue());
 
         //caret
         cfg->Write(_T("/caret/width"), XRCCTRL(*this, "spnCaretWidth", wxSpinCtrl)->GetValue());
Index: src/sdk/editormanager.cpp
===================================================================
--- src/sdk/editormanager.cpp    (revision 3103)
+++ src/sdk/editormanager.cpp    (working copy)
@@ -97,6 +97,8 @@
     bool NewSearch;     //!< only true when a new search has been started
     int SearchInSelectionStart; //!< keep track of the start of a 'search' selection
     int SearchInSelectionEnd;  //!< keep track of the end of a 'search' selection
+    bool autoWrapSearch;
+    bool findUsesSelectedText;
 };
 
 static const int idNBTabSplitHorz = wxNewId();
@@ -1252,6 +1254,8 @@
     m_LastFindReplaceData->startWord = dlg->GetStartWord();
     m_LastFindReplaceData->matchCase = dlg->GetMatchCase();
     m_LastFindReplaceData->regEx = dlg->GetRegEx();
+    m_LastFindReplaceData->autoWrapSearch = dlg->GetAutoWrapSearch();
+    m_LastFindReplaceData->findUsesSelectedText = dlg->GetFindUsesSelectedText();
     m_LastFindReplaceData->directionDown = dlg->GetDirection() == 1;
     m_LastFindReplaceData->originEntireScope = dlg->GetOrigin() == 1;
     m_LastFindReplaceData->scope = dlg->GetScope();
@@ -1421,7 +1425,7 @@
                 else
                     msg = _("Text not found.\nSearch from the end of the document?");
 
-                bool auto_wrap_around = Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/auto_wrap_search"), true);
+                bool auto_wrap_around = data->autoWrapSearch;
                 if (auto_wrap_around)
                     wxBell();
                 if (auto_wrap_around || cbMessageBox(msg, _("Result"), wxOK | wxCANCEL | wxICON_QUESTION) == wxID_OK)
@@ -1892,7 +1896,7 @@
                         msg = _("Text not found.\nSearch from the end of the selection?");
                 }
 
-                bool auto_wrap_around = Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/auto_wrap_search"), true);
+                bool auto_wrap_around = data->autoWrapSearch;
                 if (auto_wrap_around)
                     wxBell();
                 if (auto_wrap_around || cbMessageBox(msg, _("Result"), wxOK | wxCANCEL | wxICON_QUESTION) == wxID_OK)
@@ -2175,11 +2179,23 @@
     if(!data->findInFiles)
     {
         wxString phraseAtCursor = control->GetSelectedText();
-        // NOTE (mandrav): it is not intuitive to change the search text
-        //                  just because there's a selection present...
-        // change findText to selected text (if any text is selected and no search text was set before)
-        if (!phraseAtCursor.IsEmpty() && data->findText.IsEmpty())
-            data->findText = phraseAtCursor;
+
+        if ( not data->findUsesSelectedText )
+        {   // The mandrav find behavior
+            // change findText to selected text (if any text is selected and no search text was set before)
+            if (!phraseAtCursor.IsEmpty() && data->findText.IsEmpty())
+                data->findText = phraseAtCursor;
+        }
+        else
+        {   // The tiwag find behavior
+            // change findText to selected text (if any text is selected)
+            if (!phraseAtCursor.IsEmpty())
+            {
+                data->findText = phraseAtCursor;
+                data->originEntireScope = false;  //search from cursor
+                data->scope = 0; // global ("selected text" is useful only from Find Dialog)
+            }
+        }
     }
 
     data->directionDown = goingDown;
Index: src/sdk/finddlg.cpp
===================================================================
--- src/sdk/finddlg.cpp    (revision 3103)
+++ src/sdk/finddlg.cpp    (working copy)
@@ -82,6 +82,9 @@
     XRCCT
download for full patch...
pecan 2006-10-18 22:49

Moves Find wrap checkbox to Find dlg and implements tiwags "Find uses Selected Text" as an option in Find dlg

killerbot 2006-10-26 20:44

has been applied