4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
10 * \author Alfredo Braunstein
11 * \author Tommaso Cucinotta
13 * Full author contact details are available in file CREDITS.
19 #include "support/strfwd.h"
22 #include "support/docstring.h"
34 /** Encode the parameters needed to find \c search as a string
35 * that can be dispatched to the LyX core in a FuncRequest wrapper.
37 docstring const find2string(docstring const & search,
42 /** Encode the parameters needed to replace \c search with \c replace
43 * as a string that can be dispatched to the LyX core in a FuncRequest
46 docstring const replace2string(docstring const & replace,
47 docstring const & search,
52 bool findnext = true);
54 /** Parse the string encoding of the find request that is found in
55 * \c ev.argument and act on it.
56 * The string is encoded by \c find2string.
57 * \return true if the string was found.
59 bool lyxfind(BufferView * bv, FuncRequest const & ev);
61 /** Parse the string encoding of the replace request that is found in
62 * \c ev.argument and act on it.
63 * The string is encoded by \c replace2string.
64 * \return whether we did anything
66 bool lyxreplace(BufferView * bv,
67 FuncRequest const &, bool has_deleted = false);
69 /// find the next change in the buffer
70 bool findNextChange(BufferView * bv);
72 /// find the previous change in the buffer
73 bool findPreviousChange(BufferView * bv);
75 class FindAndReplaceOptions {
87 FindAndReplaceOptions(
88 docstring const & find_buf_name,
94 docstring const & repl_buf_name,
96 SearchScope scope = S_BUFFER,
97 SearchRestriction restr = R_EVERYTHING
99 FindAndReplaceOptions() {}
100 docstring find_buf_name;
106 /// This is docstring() if no replace was requested
107 docstring repl_buf_name;
110 SearchRestriction restr;
113 /// Write a FindAdvOptions instance to a stringstream
114 std::ostringstream & operator<<(std::ostringstream & os, lyx::FindAndReplaceOptions const & opt);
116 /// Read a FindAdvOptions instance from a stringstream
117 std::istringstream & operator>>(std::istringstream & is, lyx::FindAndReplaceOptions & opt);
119 /// Perform a FindAdv operation.
120 bool findAdv(BufferView * bv, FindAndReplaceOptions const & opt);
122 /** Computes the simple-text or LaTeX export (depending on opt) of buf starting
123 ** from cur and ending len positions after cur, if len is positive, or at the
124 ** paragraph or innermost inset end if len is -1.
126 ** This is useful for computing opt.search from the SearchAdvDialog controller (ControlSearchAdv).
127 ** Ideally, this should not be needed, and the opt.search field should become a Text const &.
129 docstring stringifyFromForSearch(
130 FindAndReplaceOptions const & opt,
131 DocIterator const & cur,