]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlSearch.C
Port the tabular dialog to the new scheme based on class Dialog.
[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
14 #include "ControlSearch.h"
15
16 #include "gettext.h"
17 #include "lyxfind.h"
18
19 #include "frontends/LyXView.h"
20
21 #include "support/lstrings.h"
22
23
24 ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
25         : ControlDialogBD(lv, d)
26 {}
27
28
29 void ControlSearch::find(string const & search,
30                          bool casesensitive, bool matchword, bool forward)
31 {
32         bool const found = lyxfind::LyXFind(bufferview(), search,
33                                             forward, casesensitive,
34                                             matchword);
35
36         if (!found)
37                 lv_.message(_("String not found!"));
38 }
39
40
41 void ControlSearch::replace(string const & search, string const & replace,
42                             bool casesensitive, bool matchword, bool all)
43 {
44         // If not replacing all instances of the word, then do not
45         // move on to the next instance once the present instance has been
46         // changed
47         bool const once = !all;
48         int const replace_count =
49                 lyxfind::LyXReplace(bufferview(),
50                                     search, replace, true, casesensitive,
51                                     matchword, all, once);
52
53         if (replace_count == 0) {
54                 lv_.message(_("String not found!"));
55         } else {
56                 if (replace_count == 1) {
57                         lv_.message(_("String has been replaced."));
58                 } else {
59                         string str = tostr(replace_count);
60                         str += _(" strings have been replaced.");
61                         lv_.message(str);
62                 }
63         }
64 }