]> 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 d6692583f4f76515252ea9db094f6d1554000ebe..f99770f071409a4eb84bfbb4a39ca6020c8c1a0c 100644 (file)
 
 #include <config.h>
 
-
 #include "ControlThesaurus.h"
 
-#include "gettext.h"
 #include "lyxfind.h"
-
-#include "frontends/LyXView.h"
-
+#include "funcrequest.h"
 
 using std::string;
 
+namespace lyx {
+namespace frontend {
 
 ControlThesaurus::ControlThesaurus(Dialog & parent)
        : Dialog::Controller(parent)
@@ -46,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 =
-               lyx::find::replace(kernel().bufferview(), oldstr_, newstr,
-                                  true /*cs*/, true /*mw*/, true /*fw*/);
-
-       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