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 bool findOne(BufferView * bv, docstring const & searchstr,
67 bool case_sens, bool whole, bool forward,
68 bool find_del = true, bool check_wrap = false);
70 /** Parse the string encoding of the replace request that is found in
71 * \c ev.argument and act on it.
72 * The string is encoded by \c replace2string.
73 * \return whether we did anything
75 bool lyxreplace(BufferView * bv, FuncRequest const &);
77 /// find the next change in the buffer
78 bool findNextChange(BufferView * bv);
80 /// find the previous change in the buffer
81 bool findPreviousChange(BufferView * bv);
83 /// select change under the cursor
84 bool selectChange(Cursor & cur, bool forward = true);
87 class FindAndReplaceOptions {
99 FindAndReplaceOptions(
100 docstring const & find_buf_name,
106 docstring const & repl_buf_name,
108 SearchScope scope = S_BUFFER,
109 SearchRestriction restr = R_EVERYTHING,
110 bool replace_all = false
113 FindAndReplaceOptions() {}
115 docstring find_buf_name;
116 bool casesensitive = false;
117 bool matchword = false;
118 bool forward = false;
119 bool matchAtStart = false;
120 bool expandmacros = false;
121 bool ignoreformat = false;
122 /// This is docstring() if no replace was requested
123 docstring repl_buf_name;
124 bool keep_case = false;
125 SearchScope scope = S_BUFFER;
126 SearchRestriction restr = R_EVERYTHING;
127 bool replace_all = false;
130 /// Set the formats that should be ignored
131 void setIgnoreFormat(std::string const & type, bool value, bool fromUser = true);
133 /// Write a FindAdvOptions instance to a stringstream
134 std::ostringstream & operator<<(std::ostringstream & os, lyx::FindAndReplaceOptions const & opt);
136 /// Read a FindAdvOptions instance from a stringstream
137 std::istringstream & operator>>(std::istringstream & is, lyx::FindAndReplaceOptions & opt);
139 /// Perform a FindAdv operation.
140 bool findAdv(BufferView * bv, FindAndReplaceOptions & opt);
142 /** Computes the simple-text or LaTeX export (depending on opt) of buf starting
143 ** from cur and ending len positions after cur, if len is positive, or at the
144 ** paragraph or innermost inset end if len is -1.
146 ** This is useful for computing opt.search from the SearchAdvDialog controller (ControlSearchAdv).
147 ** Ideally, this should not be needed, and the opt.search field should become a Text const &.
149 docstring stringifyFromForSearch(
150 FindAndReplaceOptions const & opt,
151 DocIterator const & cur,