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