]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlSearch.C
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[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 ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
24         : ControlDialogBD(lv, d)
25 {}
26
27
28 void ControlSearch::find(string const & search,
29                          bool casesensitive, bool matchword, bool forward)
30 {
31         bool const found = lyxfind::LyXFind(bufferview(), search,
32                                             forward, casesensitive,
33                                             matchword);
34
35         if (!found)
36                 lv_.message(_("String not found!"));
37 }
38
39
40 void ControlSearch::replace(string const & search, string const & replace,
41                             bool casesensitive, bool matchword, bool all)
42 {
43         // If not replacing all instances of the word, then do not
44         // move on to the next instance once the present instance has been
45         // changed
46         bool const once = !all;
47         int const replace_count =
48                 lyxfind::LyXReplace(bufferview(),
49                                     search, replace, true, casesensitive,
50                                     matchword, all, once);
51
52         if (replace_count == 0) {
53                 lv_.message(_("String not found!"));
54         } else {
55                 if (replace_count == 1) {
56                         lv_.message(_("String has been replaced."));
57                 } else {
58                         string str = tostr(replace_count);
59                         str += _(" strings have been replaced.");
60                         lv_.message(str);
61                 }
62         }
63 }