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"
31 using Liason::setMinibuffer;
34 ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
35 : ControlDialog<ControlConnectBD>(lv, d)
37 d_.showSearch.connect(SigC::slot(this, &ControlSearch::show));
39 // perhaps in the future we'd like a
40 // "search again" button/keybinding
41 // d_.searchAgain.connect(SigC::slot(this, &ControlSearch::FindNext));
45 void ControlSearch::find(string const & search,
46 bool casesensitive, bool matchword, bool forward) const
48 bool const found = LyXFind(lv_.view(), search, casesensitive,
52 setMinibuffer(&lv_, _("String not found!"));
56 void ControlSearch::replace(string const & search, string const & replace,
57 bool casesensitive, bool matchword, bool all) const
59 int const replace_count = LyXReplace(lv_.view(),
60 search, replace, casesensitive,
61 matchword, true, all);
63 if (replace_count == 0) {
64 setMinibuffer(&lv_, _("String not found!"));
66 if (replace_count == 1) {
67 setMinibuffer(&lv_, _("String has been replaced."));
69 string str = tostr(replace_count);
70 str += _(" strings have been replaced.");
71 setMinibuffer(&lv_, str.c_str());