1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2001 The LyX Team.
8 * ======================================================
10 * \file ControlSearch.C
11 * \author Angus Leeming <a.leeming@ic.ac.uk>
17 #pragma implementation
21 #include "ButtonControllerBase.h"
22 #include "ControlSearch.h"
30 #include "BufferView.h"
31 #include "support/lstrings.h"
33 using Liason::setMinibuffer;
36 ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
37 : ControlDialog<ControlConnectBD>(lv, d)
39 d_.showSearch.connect(SigC::slot(this, &ControlSearch::show));
41 // perhaps in the future we'd like a
42 // "search again" button/keybinding
43 // d_.searchAgain.connect(SigC::slot(this, &ControlSearch::FindNext));
47 void ControlSearch::find(string const & search,
48 bool casesensitive, bool matchword, bool forward) const
50 bool const found = LyXFind(lv_.view(), search,
51 forward, false, casesensitive, matchword);
54 setMinibuffer(&lv_, _("String not found!"));
58 void ControlSearch::replace(string const & search, string const & replace,
59 bool casesensitive, bool matchword, bool all) const
61 // If not replacing all instances of the word, then do not
62 // move on to the next instance once the present instance has been
64 bool const once = !all;
65 int const replace_count = LyXReplace(lv_.view(),
66 search, replace, true, casesensitive,
67 matchword, all, once);
69 if (replace_count == 0) {
70 setMinibuffer(&lv_, _("String not found!"));
72 if (replace_count == 1) {
73 setMinibuffer(&lv_, _("String has been replaced."));
75 string str = tostr(replace_count);
76 str += _(" strings have been replaced.");
77 setMinibuffer(&lv_, str.c_str());