]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlSearch.C
fix crash due to invalidated iterator
[lyx.git] / src / frontends / controllers / ControlSearch.C
index 7b3fdbff6a90ea0be0a269327f2604e7d49ab33a..b0e46a52dcc0680f0ef0d5baa5c7f834a7bdb4c2 100644 (file)
 
 #include "ControlSearch.h"
 
-#include "gettext.h"
+#include "funcrequest.h"
 #include "lyxfind.h"
 
-#include "frontends/LyXView.h"
-
-#include "support/tostr.h"
-
-
 using std::string;
 
+namespace lyx {
+namespace frontend {
 
-ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
-       : ControlDialogBD(lv, d)
+ControlSearch::ControlSearch(Dialog & parent)
+       : Dialog::Controller(parent)
 {}
 
 
-void ControlSearch::find(string const & search,
-                        bool casesensitive, bool matchword, bool forward)
+void ControlSearch::find(string const & search, bool casesensitive,
+                        bool matchword, bool forward)
 {
-       bool const found = lyx::find::find(bufferview(), search,
-                                           forward, casesensitive,
-                                           matchword);
-
-       if (!found)
-               lv_.message(_("String not found!"));
+       string const data = find::find2string(search, casesensitive,
+                                             matchword, forward);
+       kernel().dispatch(FuncRequest(LFUN_WORD_FIND, data));
 }
 
 
 void ControlSearch::replace(string const & search, string const & replace,
-                           bool casesensitive, bool matchword, bool all)
+                           bool casesensitive, bool matchword,
+                           bool forward, bool all)
 {
-       // If not replacing all instances of the word, then do not
-       // move on to the next instance once the present instance has been
-       // changed
-       bool const once = !all;
-       int const replace_count =
-               lyx::find::replace(bufferview(),
-                                   search, replace, true, casesensitive,
-                                   matchword, all, once);
-
-       if (replace_count == 0) {
-               lv_.message(_("String not found!"));
-       } else {
-               if (replace_count == 1) {
-                       lv_.message(_("String has been replaced."));
-               } else {
-                       string str = tostr(replace_count);
-                       str += _(" strings have been replaced.");
-                       lv_.message(str);
-               }
-       }
+       string const data =
+               find::replace2string(search, replace, casesensitive,
+                                    matchword, all, forward);
+       kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
 }
+
+} // namespace frontend
+} // namespace lyx