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
20 #include "ControlSearch.h"
28 using Liason::setMinibuffer;
31 ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
32 : ControlDialog<ControlConnectBD>(lv, d)
34 d_.showSearch.connect(SigC::slot(this, &ControlSearch::show));
36 // perhaps in the future we'd like a
37 // "search again" button/keybinding
38 // d_.searchAgain.connect(SigC::slot(this, &ControlSearch::FindNext));
42 void ControlSearch::find(string const & search,
43 bool casesensitive, bool matchword, bool forward) const
45 bool const found = LyXFind(lv_.view(), search, casesensitive,
49 setMinibuffer(&lv_, _("String not found!"));
53 void ControlSearch::replace(string const & search, string const & replace,
54 bool casesensitive, bool matchword, bool all) const
56 int const replace_count = LyXReplace(lv_.view(),
57 search, replace, casesensitive,
58 matchword, true, all);
60 if (replace_count == 0) {
61 setMinibuffer(&lv_, _("String not found!"));
63 if (replace_count == 1) {
64 setMinibuffer(&lv_, _("String has been replaced."));
66 string str = tostr(replace_count);
67 str += _(" strings have been replaced.");
68 setMinibuffer(&lv_, str.c_str());