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"
22 #include "ButtonControllerBase.h"
29 #include "BufferView.h"
31 #include "frontends/LyXView.h"
33 #include "support/lstrings.h"
35 #include <boost/bind.hpp>
37 using Liason::setMinibuffer;
39 ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
40 : ControlDialogBD(lv, d)
42 d_.showSearch = boost::bind(&ControlSearch::show, this);
44 // perhaps in the future we'd like a
45 // "search again" button/keybinding
46 // d_.searchAgain.connect(SigC::slot(this, &ControlSearch::FindNext));
50 void ControlSearch::find(string const & search,
51 bool casesensitive, bool matchword, bool forward) const
53 bool const found = LyXFind(lv_.view(), search,
54 forward, false, casesensitive, matchword);
57 setMinibuffer(&lv_, _("String not found!"));
61 void ControlSearch::replace(string const & search, string const & replace,
62 bool casesensitive, bool matchword, bool all) const
64 // If not replacing all instances of the word, then do not
65 // move on to the next instance once the present instance has been
67 bool const once = !all;
68 int const replace_count = LyXReplace(lv_.view(),
69 search, replace, true, casesensitive,
70 matchword, all, once);
72 if (replace_count == 0) {
73 setMinibuffer(&lv_, _("String not found!"));
75 if (replace_count == 1) {
76 setMinibuffer(&lv_, _("String has been replaced."));
78 string str = tostr(replace_count);
79 str += _(" strings have been replaced.");
80 setMinibuffer(&lv_, str.c_str());