-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 2001 The LyX Team.
+/**
+ * \file ControlSearch.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * ======================================================
+ * \author Angus Leeming
*
- * \file ControlSearch.C
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
#include "ControlSearch.h"
-#include "Dialogs.h"
-#include "Liason.h"
-#include "LyXView.h"
-#include "buffer.h"
+
+#include "funcrequest.h"
#include "lyxfind.h"
-#include "debug.h"
-#include "gettext.h"
-#include "BufferView.h"
-using Liason::setMinibuffer;
-using SigC::slot;
+using std::string;
-ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
- : ControlDialog<ControlConnectBD>(lv, d)
-{
- d_.showSearch.connect(SigC::slot(this, &ControlSearch::show));
+namespace lyx {
+namespace frontend {
- // perhaps in the future we'd like a
- // "search again" button/keybinding
- // d_.searchAgain.connect(SigC::slot(this, &ControlSearch::FindNext));
-}
+ControlSearch::ControlSearch(Dialog & parent)
+ : Dialog::Controller(parent)
+{}
-void ControlSearch::find(string const & search,
- bool casesensitive, bool matchword, bool forward) const
+void ControlSearch::find(string const & search, bool casesensitive,
+ bool matchword, bool forward)
{
- bool const found = LyXFind(lv_.view(), search,
- forward, false, casesensitive, matchword);
-
- if (!found)
- setMinibuffer(&lv_, _("String not found!"));
+ string const data = find::find2string(search, casesensitive,
+ matchword, forward);
+ kernel().dispatch(FuncRequest(LFUN_WORD_FIND, data));
}
void ControlSearch::replace(string const & search, string const & replace,
- bool casesensitive, bool matchword, bool all) const
+ bool casesensitive, bool matchword,
+ bool forward, bool all)
{
- int const replace_count = LyXReplace(lv_.view(),
- search, replace, true, casesensitive,
- matchword, all);
-
- if (replace_count == 0) {
- setMinibuffer(&lv_, _("String not found!"));
- } else {
- if (replace_count == 1) {
- setMinibuffer(&lv_, _("String has been replaced."));
- } else {
- string str = tostr(replace_count);
- str += _(" strings have been replaced.");
- setMinibuffer(&lv_, str.c_str());
- }
- }
+ string const data =
+ find::replace2string(search, replace, casesensitive,
+ matchword, all, forward);
+ kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
}
+
+} // namespace frontend
+} // namespace lyx