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"
35 /** Encode the parameters needed to find \c search as a string
36 * that can be dispatched to the LyX core in a FuncRequest wrapper.
38 docstring const find2string(docstring const & search,
43 /** Encode the parameters needed to replace \c search with \c replace
44 * as a string that can be dispatched to the LyX core in a FuncRequest
47 docstring const replace2string(docstring const & replace,
48 docstring const & search,
53 bool findnext = true);
55 /** Parse the string encoding of the find request that is found in
56 * \c ev.argument and act on it.
57 * The string is encoded by \c find2string.
58 * \return true if the string was found.
60 bool lyxfind(BufferView * bv, FuncRequest const & ev);
62 /** Parse the string encoding of the replace request that is found in
63 * \c ev.argument and act on it.
64 * The string is encoded by \c replace2string.
65 * \return whether we did anything
67 bool lyxreplace(BufferView * bv,
68 FuncRequest const &, bool has_deleted = false);
70 /// find the next change in the buffer
71 bool findNextChange(BufferView * bv);
73 /// find the previous change in the buffer
74 bool findPreviousChange(BufferView * bv);
76 /// select change under the cursor
77 bool selectChange(Cursor & cur, bool forward = true);
80 class FindAndReplaceOptions {
92 FindAndReplaceOptions(
93 docstring const & find_buf_name,
99 docstring const & repl_buf_name,
101 SearchScope scope = S_BUFFER,
102 SearchRestriction restr = R_EVERYTHING,
103 bool replace_all = false
105 FindAndReplaceOptions() : casesensitive(false), matchword(false), forward(false),
106 expandmacros(false), ignoreformat(false),
107 keep_case(false), scope(S_BUFFER), restr(R_EVERYTHING), replace_all(false) {}
108 docstring find_buf_name;
114 /// This is docstring() if no replace was requested
115 docstring repl_buf_name;
118 SearchRestriction restr;
122 /// Set the formats that should be ignored
123 void setIgnoreFormat(std::string type, bool value);
125 /// Write a FindAdvOptions instance to a stringstream
126 std::ostringstream & operator<<(std::ostringstream & os, lyx::FindAndReplaceOptions const & opt);
128 /// Read a FindAdvOptions instance from a stringstream
129 std::istringstream & operator>>(std::istringstream & is, lyx::FindAndReplaceOptions & opt);
131 /// Perform a FindAdv operation.
132 bool findAdv(BufferView * bv, FindAndReplaceOptions const & opt);
134 /** Computes the simple-text or LaTeX export (depending on opt) of buf starting
135 ** from cur and ending len positions after cur, if len is positive, or at the
136 ** paragraph or innermost inset end if len is -1.
138 ** This is useful for computing opt.search from the SearchAdvDialog controller (ControlSearchAdv).
139 ** Ideally, this should not be needed, and the opt.search field should become a Text const &.
141 docstring stringifyFromForSearch(
142 FindAndReplaceOptions const & opt,
143 DocIterator const & cur,
146 /** Set format type to be ignore by search
148 void setIgnoreFormat(std::string type, bool value);