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