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