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