]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlThesaurus.C
prefs/tabular MVC work
[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/LyXView.h"
23
24
25 ControlThesaurus::ControlThesaurus(LyXView & lv, Dialogs & d)
26         : ControlDialogBD(lv, d)
27 {}
28
29
30 void ControlThesaurus::showEntry(string const & entry)
31 {
32         oldstr_ = entry;
33         show();
34 }
35
36
37 void ControlThesaurus::replace(string const & newstr)
38 {
39         /* FIXME: this is not suitable ! We need to have a "lock"
40          * on a particular charpos in a paragraph that is broken on
41          * deletion/change !
42          */
43         int const replace_count =
44                 lyxfind::LyXReplace(bufferview(), oldstr_, newstr,
45                                     true, true, true, false, true);
46
47         oldstr_ = newstr;
48
49         if (replace_count == 0)
50                 lv_.message(_("String not found!"));
51         else
52                 lv_.message(_("String has been replaced."));
53 }
54
55
56 Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str)
57 {
58         if (str != laststr_)
59                 meanings_ = thesaurus.lookup(str);
60
61         return meanings_;
62 }