]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlThesaurus.C
5 new lfuns, move all apply code out of ControlDocument and into the core.
[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 #include "ControlThesaurus.h"
14
15 #include "lyxfind.h"
16 #include "funcrequest.h"
17
18 using std::string;
19
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         string const data =
46                 lyx::find::replace2string(oldstr_, newstr,
47                                           true,  // case sensitive
48                                           true,  // match word
49                                           false, // all words
50                                           true); // forward
51         kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
52 }
53
54
55 Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str)
56 {
57         if (str != laststr_)
58                 meanings_ = thesaurus.lookup(str);
59         return meanings_;
60 }