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 /** Decode the \c argument to extract search plus options from a string
32 * that came to the LyX core in a FuncRequest wrapper.
34 docstring const string2find(docstring const & argument,
39 /** Encode the parameters needed to find \c search as a string
40 * that can be dispatched to the LyX core in a FuncRequest wrapper.
42 docstring const find2string(docstring const & search,
47 /** Encode the parameters needed to replace \c search with \c replace
48 * as a string that can be dispatched to the LyX core in a FuncRequest
51 docstring const replace2string(docstring const & replace,
52 docstring const & search,
57 bool findnext = true);
59 /** Parse the string encoding of the find request that is found in
60 * \c ev.argument and act on it.
61 * The string is encoded by \c find2string.
62 * \return true if the string was found.
64 bool lyxfind(BufferView * bv, FuncRequest const & ev);
66 /** Parse the string encoding of the replace request that is found in
67 * \c ev.argument and act on it.
68 * The string is encoded by \c replace2string.
69 * \return whether we did anything
71 bool lyxreplace(BufferView * bv, FuncRequest const &);
73 /// find the next change in the buffer
74 bool findNextChange(BufferView * bv);
76 /// find the previous change in the buffer
77 bool findPreviousChange(BufferView * bv);
79 /// select change under the cursor
80 bool selectChange(Cursor & cur, bool forward = true);
83 class FindAndReplaceOptions {
95 FindAndReplaceOptions(
96 docstring const & find_buf_name,
102 docstring const & repl_buf_name,
104 SearchScope scope = S_BUFFER,
105 SearchRestriction restr = R_EVERYTHING,
106 bool replace_all = false
109 FindAndReplaceOptions() {}
111 docstring find_buf_name;
112 bool casesensitive = false;
113 bool matchword = false;
114 bool forward = false;
115 bool matchAtStart = false;
116 bool expandmacros = false;
117 bool ignoreformat = false;
118 /// This is docstring() if no replace was requested
119 docstring repl_buf_name;
120 bool keep_case = false;
121 SearchScope scope = S_BUFFER;
122 SearchRestriction restr = R_EVERYTHING;
123 bool replace_all = false;
126 /// Set the formats that should be ignored
127 void setIgnoreFormat(std::string const & type, bool value);
129 /// Write a FindAdvOptions instance to a stringstream
130 std::ostringstream & operator<<(std::ostringstream & os, lyx::FindAndReplaceOptions const & opt);
132 /// Read a FindAdvOptions instance from a stringstream
133 std::istringstream & operator>>(std::istringstream & is, lyx::FindAndReplaceOptions & opt);
135 /// Perform a FindAdv operation.
136 bool findAdv(BufferView * bv, FindAndReplaceOptions & opt);
138 /** Computes the simple-text or LaTeX export (depending on opt) of buf starting
139 ** from cur and ending len positions after cur, if len is positive, or at the
140 ** paragraph or innermost inset end if len is -1.
142 ** This is useful for computing opt.search from the SearchAdvDialog controller (ControlSearchAdv).
143 ** Ideally, this should not be needed, and the opt.search field should become a Text const &.
145 docstring stringifyFromForSearch(
146 FindAndReplaceOptions const & opt,
147 DocIterator const & cur,