]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlThesaurus.C
Switch from SigC signals to boost::signals
[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 #include "ViewBase.h"
17 #include "ButtonControllerBase.h"
18 #include "Dialogs.h"
19 #include "Liason.h"
20 #include "lyxfind.h"
21 #include "buffer.h"
22 #include "debug.h"
23 #include "gettext.h"
24 #include "BufferView.h"
25
26 #include "frontends/LyXView.h"
27
28 #include <boost/bind.hpp>
29
30 using Liason::setMinibuffer;
31
32 ControlThesaurus::ControlThesaurus(LyXView & lv, Dialogs & d)
33         : ControlDialogBD(lv, d)
34 {
35         d_.showThesaurus = boost::bind(&ControlThesaurus::showEntry, this, _1);
36 }
37
38
39 void ControlThesaurus::showEntry(string const & entry)
40 {
41         oldstr_ = entry;
42         show();
43 }
44
45
46 void ControlThesaurus::replace(string const & newstr)
47 {
48         /* FIXME: this is not suitable ! We need to have a "lock"
49          * on a particular charpos in a paragraph that is broken on
50          * deletion/change !
51          */
52         int const replace_count = LyXReplace(lv_.view(), oldstr_, newstr,
53                                         true, true, true, false, true);
54
55         oldstr_ = newstr;
56
57         if (replace_count == 0)
58                 setMinibuffer(&lv_, _("String not found!"));
59         else
60                 setMinibuffer(&lv_, _("String has been replaced."));
61 }
62
63
64 Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str)
65 {
66         if (str != laststr_)
67                 meanings_ = thesaurus.lookup(str);
68
69         return meanings_;
70 }