// -*- C++ -*-
+/**
+ * \file lyxfind.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ * \author Jürgen Vigna
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
#ifndef LYXFIND_H
#define LYXFIND_H
-#include "LString.h"
-#include "support/types.h"
-
-class BufferView;
-class LyXText;
-
-namespace lyxfind {
+#include "support/docstring.h"
-enum SearchResult {
- //
- SR_NOT_FOUND = 0,
- //
- SR_FOUND,
- //
- SR_FOUND_NOUPDATE
-};
+namespace lyx {
+class BufferView;
+class FuncRequest;
+class Text;
-int LyXReplace(BufferView * bv,
- string const &, string const &,
- bool, bool = true, bool = false,
- bool = false, bool = false);
-
-/**
- * This function is called as a general interface to find some
- * text from the actual cursor position in whatever direction
- * we want to go. This does also update the screen.
+/** Encode the parameters needed to find \c search as a string
+ * that can be dispatched to the LyX core in a FuncRequest wrapper.
*/
-bool LyXFind(BufferView *,
- string const & searchstr, bool forward,
- bool casesens = true, bool matchwrd = false);
-
-/**
- * This function does search from the cursor position inside the
- * passed LyXText parameter and regards this LyXText as the root
- * LyXText. It will NOT update any screen stuff. It will however
- * set the cursor to the new position inside LyXText, before
- * returning to the calling function.
+docstring const find2string(docstring const & search,
+ bool casesensitive,
+ bool matchword,
+ bool forward);
+
+/** Encode the parameters needed to replace \c search with \c replace
+ * as a string that can be dispatched to the LyX core in a FuncRequest
+ * wrapper.
+ */
+docstring const replace2string(docstring const & search,
+ docstring const & replace,
+ bool casesensitive,
+ bool matchword,
+ bool all,
+ bool forward);
+
+/** Parse the string encoding of the find request that is found in
+ * \c ev.argument and act on it.
+ * The string is encoded by \c find2string.
*/
+void find(BufferView * bv, FuncRequest const & ev);
-SearchResult LyXFind(BufferView *, LyXText * text,
- string const & searchstr, bool forward,
- bool casesens = true, bool matchwrd = false);
+/** Parse the string encoding of the replace request that is found in
+ * \c ev.argument and act on it.
+ * The string is encoded by \c replace2string.
+ */
+void replace(BufferView * bv, FuncRequest const &);
/// find the next change in the buffer
bool findNextChange(BufferView * bv);
-
-SearchResult findNextChange(BufferView * bv, LyXText * text, lyx::pos_type & length);
-
-SearchResult nextChange(BufferView * bv, LyXText * text, lyx::pos_type & length);
-
-} // end namespace LyXFind
-
+
+} // namespace lyx
+
#endif // LYXFIND_H