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"
31 /** Encode the parameters needed to find \c search as a string
32 * that can be dispatched to the LyX core in a FuncRequest wrapper.
34 docstring const find2string(docstring const & search,
39 /** Encode the parameters needed to replace \c search with \c replace
40 * as a string that can be dispatched to the LyX core in a FuncRequest
43 docstring const replace2string(docstring const & replace,
44 docstring const & search,
49 bool findnext = true);
51 /** Parse the string encoding of the find request that is found in
52 * \c ev.argument and act on it.
53 * The string is encoded by \c find2string.
54 * \return true if the string was found.
56 bool lyxfind(BufferView * bv, FuncRequest const & ev);
58 /** Parse the string encoding of the replace request that is found in
59 * \c ev.argument and act on it.
60 * The string is encoded by \c replace2string.
61 * \return whether we did anything
63 bool lyxreplace(BufferView * bv,
64 FuncRequest const &, bool has_deleted = false);
66 /// find the next change in the buffer
67 bool findNextChange(BufferView * bv);
69 /// find the previous change in the buffer
70 bool findPreviousChange(BufferView * bv);
72 /// select change under the cursor
73 bool selectChange(Cursor & cur, bool forward = true);
76 class FindAndReplaceOptions {
88 FindAndReplaceOptions(
89 docstring const & find_buf_name,
95 docstring const & repl_buf_name,
97 SearchScope scope = S_BUFFER,
98 SearchRestriction restr = R_EVERYTHING,
99 bool replace_all = false
101 FindAndReplaceOptions() : casesensitive(false), matchword(false), forward(false),
102 expandmacros(false), ignoreformat(false),
103 keep_case(false), scope(S_BUFFER), restr(R_EVERYTHING), replace_all(false) {}
104 docstring find_buf_name;
110 /// This is docstring() if no replace was requested
111 docstring repl_buf_name;
114 SearchRestriction restr;
118 /// Set the formats that should be ignored
119 void setIgnoreFormat(std::string const & type, bool value);
121 /// Write a FindAdvOptions instance to a stringstream
122 std::ostringstream & operator<<(std::ostringstream & os, lyx::FindAndReplaceOptions const & opt);
124 /// Read a FindAdvOptions instance from a stringstream
125 std::istringstream & operator>>(std::istringstream & is, lyx::FindAndReplaceOptions & opt);
127 /// Perform a FindAdv operation.
128 bool findAdv(BufferView * bv, FindAndReplaceOptions const & opt);
130 /** Computes the simple-text or LaTeX export (depending on opt) of buf starting
131 ** from cur and ending len positions after cur, if len is positive, or at the
132 ** paragraph or innermost inset end if len is -1.
134 ** This is useful for computing opt.search from the SearchAdvDialog controller (ControlSearchAdv).
135 ** Ideally, this should not be needed, and the opt.search field should become a Text const &.
137 docstring stringifyFromForSearch(
138 FindAndReplaceOptions const & opt,
139 DocIterator const & cur,