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"
25 #include "BufferView.h"
27 #include "frontends/LyXView.h"
29 #include "support/lstrings.h"
31 using Liason::setMinibuffer;
34 ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
35 : ControlDialogBD(lv, d)
39 void ControlSearch::find(string const & search,
40 bool casesensitive, bool matchword, bool forward) const
42 bool const found = lyxfind::LyXFind(lv_.view(), search,
43 forward, casesensitive,
47 setMinibuffer(&lv_, _("String not found!"));
51 void ControlSearch::replace(string const & search, string const & replace,
52 bool casesensitive, bool matchword, bool all) const
54 // If not replacing all instances of the word, then do not
55 // move on to the next instance once the present instance has been
57 bool const once = !all;
58 int const replace_count =
59 lyxfind::LyXReplace(lv_.view(),
60 search, replace, true, casesensitive,
61 matchword, all, once);
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());