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, FuncRequest const &);
65 /// find the next change in the buffer
66 bool findNextChange(BufferView * bv);
68 /// find the previous change in the buffer
69 bool findPreviousChange(BufferView * bv);
71 /// select change under the cursor
72 bool selectChange(Cursor & cur, bool forward = true);
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,
98 bool replace_all = false
101 FindAndReplaceOptions() {}
103 docstring find_buf_name;
104 bool casesensitive = false;
105 bool matchword = false;
106 bool forward = false;
107 bool matchAtStart = false;
108 bool expandmacros = false;
109 bool ignoreformat = false;
110 /// This is docstring() if no replace was requested
111 docstring repl_buf_name;
112 bool keep_case = false;
113 SearchScope scope = S_BUFFER;
114 SearchRestriction restr = R_EVERYTHING;
115 bool replace_all = false;
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 & 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,