]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlThesaurus.C
This file is part of LyX, the document processor.
[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 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "ControlThesaurus.h"
18
19 #include "gettext.h"
20 #include "lyxfind.h"
21
22 #include "frontends/Liason.h"
23
24
25 using Liason::setMinibuffer;
26
27
28 ControlThesaurus::ControlThesaurus(LyXView & lv, Dialogs & d)
29         : ControlDialogBD(lv, d)
30 {}
31
32
33 void ControlThesaurus::showEntry(string const & entry)
34 {
35         oldstr_ = entry;
36         show();
37 }
38
39
40 void ControlThesaurus::replace(string const & newstr)
41 {
42         /* FIXME: this is not suitable ! We need to have a "lock"
43          * on a particular charpos in a paragraph that is broken on
44          * deletion/change !
45          */
46         int const replace_count =
47                 lyxfind::LyXReplace(bufferview(), oldstr_, newstr,
48                                     true, true, true, false, true);
49
50         oldstr_ = newstr;
51
52         if (replace_count == 0)
53                 setMinibuffer(&lv_, _("String not found!"));
54         else
55                 setMinibuffer(&lv_, _("String has been replaced."));
56 }
57
58
59 Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str)
60 {
61         if (str != laststr_)
62                 meanings_ = thesaurus.lookup(str);
63
64         return meanings_;
65 }