]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlThesaurus.C
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[lyx.git] / src / frontends / controllers / ControlThesaurus.C
1 /**
2  * \file ControlThesaurus.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13
14 #include "ControlThesaurus.h"
15
16 #include "gettext.h"
17 #include "lyxfind.h"
18
19 #include "frontends/LyXView.h"
20
21 ControlThesaurus::ControlThesaurus(Dialog & parent)
22         : Dialog::Controller(parent)
23 {}
24
25
26 bool ControlThesaurus::initialiseParams(string const & data)
27 {
28         oldstr_ = data;
29         return true;
30 }
31
32
33 void ControlThesaurus::clearParams()
34 {
35         oldstr_.erase();
36 }
37
38
39 void ControlThesaurus::replace(string const & newstr)
40 {
41         /* FIXME: this is not suitable ! We need to have a "lock"
42          * on a particular charpos in a paragraph that is broken on
43          * deletion/change !
44          */
45         int const replace_count =
46                 lyxfind::LyXReplace(kernel().bufferview(), oldstr_, newstr,
47                                     true, true, true, false, true);
48
49         oldstr_ = newstr;
50
51         if (replace_count == 0)
52                 kernel().lyxview().message(_("String not found!"));
53         else
54                 kernel().lyxview().message(_("String has been replaced."));
55 }
56
57
58 Thesaurus::Meanings const &
59 ControlThesaurus::getMeanings(string const & str)
60 {
61         if (str != laststr_)
62                 meanings_ = thesaurus.lookup(str);
63
64         return meanings_;
65 }