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