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,
41 /** Encode the parameters needed to find \c search as a string
42 * that can be dispatched to the LyX core in a FuncRequest wrapper.
44 docstring const find2string(docstring const & search,
51 /** Encode the parameters needed to replace \c search with \c replace
52 * as a string that can be dispatched to the LyX core in a FuncRequest
55 docstring const replace2string(docstring const & replace,
56 docstring const & search,
64 /** Parse the string encoding of the find request that is found in
65 * \c ev.argument and act on it.
66 * The string is encoded by \c find2string.
67 * \return true if the string was found.
69 bool lyxfind(BufferView * bv, FuncRequest const & ev);
71 bool findOne(BufferView * bv, docstring const & searchstr,
72 bool case_sens, bool whole, bool forward,
73 bool find_del = true, bool check_wrap = false,
74 bool auto_wrap = false, bool instant = false);
76 /** Parse the string encoding of the replace request that is found in
77 * \c ev.argument and act on it.
78 * The string is encoded by \c replace2string.
79 * \return whether we did anything
81 bool lyxreplace(BufferView * bv, FuncRequest const &);
83 /// find the next change in the buffer
84 bool findNextChange(BufferView * bv);
86 /// find the previous change in the buffer
87 bool findPreviousChange(BufferView * bv);
89 /// select change under the cursor
90 bool selectChange(Cursor & cur, bool forward = true);
93 class FindAndReplaceOptions {
105 FindAndReplaceOptions(
106 docstring const & find_buf_name,
112 docstring const & repl_buf_name,
114 SearchScope scope = S_BUFFER,
115 SearchRestriction restr = R_EVERYTHING,
116 bool replace_all = false
119 FindAndReplaceOptions() {}
121 docstring find_buf_name;
122 bool casesensitive = false;
123 bool matchword = false;
124 bool forward = false;
125 bool matchAtStart = false;
126 bool expandmacros = false;
127 bool ignoreformat = false;
128 /// This is docstring() if no replace was requested
129 docstring repl_buf_name;
130 bool keep_case = false;
131 SearchScope scope = S_BUFFER;
132 SearchRestriction restr = R_EVERYTHING;
133 bool replace_all = false;
136 /// Set the formats that should be ignored
137 void setIgnoreFormat(std::string const & type, bool value, bool fromUser = true);
139 /// Write a FindAdvOptions instance to a stringstream
140 std::ostringstream & operator<<(std::ostringstream & os, lyx::FindAndReplaceOptions const & opt);
142 /// Read a FindAdvOptions instance from a stringstream
143 std::istringstream & operator>>(std::istringstream & is, lyx::FindAndReplaceOptions & opt);
145 /// Perform a FindAdv operation.
146 bool findAdv(BufferView * bv, FindAndReplaceOptions & opt);
148 /** Computes the simple-text or LaTeX export (depending on opt) of buf starting
149 ** from cur and ending len positions after cur, if len is positive, or at the
150 ** paragraph or innermost inset end if len is -1.
152 ** This is useful for computing opt.search from the SearchAdvDialog controller (ControlSearchAdv).
153 ** Ideally, this should not be needed, and the opt.search field should become a Text const &.
155 docstring stringifyFromForSearch(
156 FindAndReplaceOptions const & opt,
157 DocIterator const & cur,