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,
42 /** Encode the parameters needed to find \c search as a string
43 * that can be dispatched to the LyX core in a FuncRequest wrapper.
45 docstring const find2string(docstring const & search,
53 /** Encode the parameters needed to replace \c search with \c replace
54 * as a string that can be dispatched to the LyX core in a FuncRequest
57 docstring const replace2string(docstring const & replace,
58 docstring const & search,
65 bool onlysel = false);
67 /** Parse the string encoding of the find request that is found in
68 * \c ev.argument and act on it.
69 * The string is encoded by \c find2string.
70 * \return true if the string was found.
72 bool lyxfind(BufferView * bv, FuncRequest const & ev);
74 bool findOne(BufferView * bv, docstring const & searchstr,
75 bool case_sens, bool whole, bool forward,
76 bool find_del = true, bool check_wrap = false,
77 bool const auto_wrap = false, bool instant = false,
78 bool onlysel = false);
80 /** Parse the string encoding of the replace request that is found in
81 * \c ev.argument and act on it.
82 * The string is encoded by \c replace2string.
83 * \return whether we did anything
85 bool lyxreplace(BufferView * bv, FuncRequest const &);
87 /// find the next change in the buffer
88 bool findNextChange(BufferView * bv);
90 /// find the previous change in the buffer
91 bool findPreviousChange(BufferView * bv);
93 /// select change under the cursor
94 bool selectChange(Cursor & cur, bool forward = true);
97 class FindAndReplaceOptions {
109 FindAndReplaceOptions(
110 docstring const & find_buf_name,
116 docstring const & repl_buf_name,
118 SearchScope scope = S_BUFFER,
119 SearchRestriction restr = R_EVERYTHING,
120 bool replace_all = false
123 FindAndReplaceOptions() {}
125 docstring find_buf_name;
126 bool casesensitive = false;
127 bool matchword = false;
128 bool forward = false;
129 bool matchAtStart = false;
130 bool expandmacros = false;
131 bool ignoreformat = false;
132 /// This is docstring() if no replace was requested
133 docstring repl_buf_name;
134 bool keep_case = false;
135 SearchScope scope = S_BUFFER;
136 SearchRestriction restr = R_EVERYTHING;
137 bool replace_all = false;
140 /// Set the formats that should be ignored
141 void setIgnoreFormat(std::string const & type, bool value, bool fromUser = true);
143 /// Write a FindAdvOptions instance to a stringstream
144 std::ostringstream & operator<<(std::ostringstream & os, lyx::FindAndReplaceOptions const & opt);
146 /// Read a FindAdvOptions instance from a stringstream
147 std::istringstream & operator>>(std::istringstream & is, lyx::FindAndReplaceOptions & opt);
149 /// Perform a FindAdv operation.
150 bool findAdv(BufferView * bv, FindAndReplaceOptions & opt);
152 /** Computes the simple-text or LaTeX export (depending on opt) of buf starting
153 ** from cur and ending len positions after cur, if len is positive, or at the
154 ** paragraph or innermost inset end if len is -1.
156 ** This is useful for computing opt.search from the SearchAdvDialog controller (ControlSearchAdv).
157 ** Ideally, this should not be needed, and the opt.search field should become a Text const &.
159 docstring stringifyFromForSearch(
160 FindAndReplaceOptions const & opt,
161 DocIterator const & cur,