]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlSearch.C
do not include language.h and gettext.h in lyxfont.h and lyxparagraph.h
[lyx.git] / src / frontends / controllers / ControlSearch.C
1 /* This file is part of
2  * ====================================================== 
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file ControlSearch.C
11  * \author Angus Leeming <a.leeming@ic.ac.uk>
12  */
13
14 #include <config.h>
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif
19
20 #include "ControlSearch.h"
21 #include "Dialogs.h"
22 #include "Liason.h"
23 #include "LyXView.h"
24 #include "buffer.h"
25 #include "lyxfind.h"
26 #include "debug.h"
27 #include "gettext.h"
28
29 using Liason::setMinibuffer;
30 using SigC::slot;
31
32 ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
33         : ControlDialog<ControlConnectBD>(lv, d)
34 {
35         d_.showSearch.connect(SigC::slot(this, &ControlSearch::show));
36
37         // perhaps in the future we'd like a
38         // "search again" button/keybinding
39         // d_.searchAgain.connect(SigC::slot(this, &ControlSearch::FindNext));
40 }
41
42
43 void ControlSearch::find(string const & search,
44                          bool casesensitive, bool matchword, bool forward) const
45 {
46         bool const found = LyXFind(lv_.view(), search, casesensitive,
47                                    matchword, forward);
48    
49         if (!found)
50                 setMinibuffer(&lv_, _("String not found!"));
51 }
52
53
54 void ControlSearch::replace(string const & search, string const & replace,
55                             bool casesensitive, bool matchword, bool all) const
56 {
57         int const replace_count = LyXReplace(lv_.view(),
58                                              search, replace, casesensitive, 
59                                              matchword, true, all);
60                                   
61         if (replace_count == 0) {
62                 setMinibuffer(&lv_, _("String not found!"));
63         } else {
64                 if (replace_count == 1) {
65                         setMinibuffer(&lv_, _("String has been replaced."));
66                 } else {
67                         string str = tostr(replace_count);
68                         str += _(" strings have been replaced.");
69                         setMinibuffer(&lv_, str.c_str());
70                 }
71         }
72 }