]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlThesaurus.C
fix crash due to invalidated iterator
[lyx.git] / src / frontends / controllers / ControlThesaurus.C
index 457931c5ad2a5214c606d9957c0379d65c45ecb2..f99770f071409a4eb84bfbb4a39ca6020c8c1a0c 100644 (file)
@@ -5,18 +5,20 @@
  *
  * \author John Levon
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-
 #include "ControlThesaurus.h"
 
-#include "gettext.h"
 #include "lyxfind.h"
+#include "funcrequest.h"
+
+using std::string;
 
-#include "frontends/LyXView.h"
+namespace lyx {
+namespace frontend {
 
 ControlThesaurus::ControlThesaurus(Dialog & parent)
        : Dialog::Controller(parent)
@@ -42,24 +44,22 @@ void ControlThesaurus::replace(string const & newstr)
         * on a particular charpos in a paragraph that is broken on
         * deletion/change !
         */
-       int const replace_count =
-               lyxfind::LyXReplace(kernel().bufferview(), oldstr_, newstr,
-                                   true, true, true, false, true);
-
-       oldstr_ = newstr;
-
-       if (replace_count == 0)
-               kernel().lyxview().message(_("String not found!"));
-       else
-               kernel().lyxview().message(_("String has been replaced."));
+       string const data =
+               find::replace2string(oldstr_, newstr,
+                                    true,  // case sensitive
+                                    true,  // match word
+                                    false, // all words
+                                    true); // forward
+       kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
 }
 
 
-Thesaurus::Meanings const &
-ControlThesaurus::getMeanings(string const & str)
+Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str)
 {
        if (str != laststr_)
                meanings_ = thesaurus.lookup(str);
-
        return meanings_;
 }
+
+} // namespace frontend
+} // namespace lyx