]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlSearch.C
Really dull and boring header shit
[lyx.git] / src / frontends / controllers / ControlSearch.C
1 /**
2  * \file ControlSearch.C
3  * See the file COPYING.
4  *
5  * \author Angus Leeming
6  *
7  * Full author contact details are available in file CREDITS
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "ControlSearch.h"
17
18 #include "gettext.h"
19 #include "lyxfind.h"
20
21 #include "frontends/Liason.h"
22
23 #include "support/lstrings.h"
24
25 using Liason::setMinibuffer;
26
27
28 ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
29         : ControlDialogBD(lv, d)
30 {}
31
32
33 void ControlSearch::find(string const & search,
34                          bool casesensitive, bool matchword, bool forward)
35 {
36         bool const found = lyxfind::LyXFind(bufferview(), search,
37                                             forward, casesensitive,
38                                             matchword);
39
40         if (!found)
41                 setMinibuffer(&lv_, _("String not found!"));
42 }
43
44
45 void ControlSearch::replace(string const & search, string const & replace,
46                             bool casesensitive, bool matchword, bool all)
47 {
48         // If not replacing all instances of the word, then do not
49         // move on to the next instance once the present instance has been
50         // changed
51         bool const once = !all;
52         int const replace_count =
53                 lyxfind::LyXReplace(bufferview(),
54                                     search, replace, true, casesensitive,
55                                     matchword, all, once);
56
57         if (replace_count == 0) {
58                 setMinibuffer(&lv_, _("String not found!"));
59         } else {
60                 if (replace_count == 1) {
61                         setMinibuffer(&lv_, _("String has been replaced."));
62                 } else {
63                         string str = tostr(replace_count);
64                         str += _(" strings have been replaced.");
65                         setMinibuffer(&lv_, str.c_str());
66                 }
67         }
68 }