]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlThesaurus.C
Really dull and boring header shit
[lyx.git] / src / frontends / controllers / ControlThesaurus.C
1 /**
2  * \file ControlThesaurus.C
3  * Read the file COPYING
4  *
5  * \author John Levon
6  *
7  * Full author contact details are available in file CREDITS
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "ControlThesaurus.h"
17
18 #include "gettext.h"
19 #include "lyxfind.h"
20
21 #include "frontends/Liason.h"
22
23
24 using Liason::setMinibuffer;
25
26
27 ControlThesaurus::ControlThesaurus(LyXView & lv, Dialogs & d)
28         : ControlDialogBD(lv, d)
29 {}
30
31
32 void ControlThesaurus::showEntry(string const & entry)
33 {
34         oldstr_ = entry;
35         show();
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(bufferview(), oldstr_, newstr,
47                                     true, true, true, false, true);
48
49         oldstr_ = newstr;
50
51         if (replace_count == 0)
52                 setMinibuffer(&lv_, _("String not found!"));
53         else
54                 setMinibuffer(&lv_, _("String has been replaced."));
55 }
56
57
58 Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str)
59 {
60         if (str != laststr_)
61                 meanings_ = thesaurus.lookup(str);
62
63         return meanings_;
64 }