* de.po: sync with branch.
[lyx.git] / src / lyxfind.h
blobf8a77494f05dc608ecd1ca769af763d5325b690c
1 // -*- C++ -*-
2 /**
3 * \file lyxfind.h
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
8 * \author John Levon
9 * \author Jürgen Vigna
10 * \author Alfredo Braunstein
11 * \author Tommaso Cucinotta
13 * Full author contact details are available in file CREDITS.
16 #ifndef LYXFIND_H
17 #define LYXFIND_H
19 #include "support/strfwd.h"
21 // FIXME
22 #include "support/docstring.h"
24 namespace lyx {
28 class Buffer;
29 class BufferView;
30 class DocIterator;
31 class FuncRequest;
32 class Text;
34 /** Encode the parameters needed to find \c search as a string
35 * that can be dispatched to the LyX core in a FuncRequest wrapper.
37 docstring const find2string(docstring const & search,
38 bool casesensitive,
39 bool matchword,
40 bool forward);
42 /** Encode the parameters needed to replace \c search with \c replace
43 * as a string that can be dispatched to the LyX core in a FuncRequest
44 * wrapper.
46 docstring const replace2string(docstring const & replace,
47 docstring const & search,
48 bool casesensitive,
49 bool matchword,
50 bool all,
51 bool forward);
53 /** Parse the string encoding of the find request that is found in
54 * \c ev.argument and act on it.
55 * The string is encoded by \c find2string.
56 * \return true if the string was found.
58 bool find(BufferView * bv, FuncRequest const & ev);
60 /** Parse the string encoding of the replace request that is found in
61 * \c ev.argument and act on it.
62 * The string is encoded by \c replace2string.
64 void replace(BufferView * bv, FuncRequest const &, bool has_deleted = false);
66 /// find the next change in the buffer
67 bool findNextChange(BufferView * bv);
69 /// find the previous change in the buffer
70 bool findPreviousChange(BufferView * bv);
72 /// find the change in the buffer
73 /// \param next true to find the next change, otherwise the previous
74 bool findChange(BufferView * bv, bool next);
76 // Hopefully, nobody will ever replace with something like this
77 #define LYX_FR_NULL_STRING "__LYX__F&R__NULL__STRING__"
79 class FindAndReplaceOptions {
80 public:
81 FindAndReplaceOptions(
82 docstring const & search,
83 bool casesensitive,
84 bool matchword,
85 bool forward,
86 bool expandmacros,
87 bool ignoreformat,
88 bool regexp,
89 docstring const & replace,
90 bool keep_case
92 FindAndReplaceOptions() { }
93 docstring search;
94 bool casesensitive;
95 bool matchword;
96 bool forward;
97 bool expandmacros;
98 bool ignoreformat;
99 bool regexp;
100 docstring replace;
101 bool keep_case;
104 /// Write a FindAdvOptions instance to a stringstream
105 std::ostringstream & operator<<(std::ostringstream & os, lyx::FindAndReplaceOptions const & opt);
107 /// Read a FindAdvOptions instance from a stringstream
108 std::istringstream & operator>>(std::istringstream & is, lyx::FindAndReplaceOptions & opt);
110 /// Dispatch a LFUN_WORD_FINDADV command request
111 void findAdv(BufferView * bv, FuncRequest const & ev);
113 /// Perform a FindAdv operation.
114 bool findAdv(BufferView * bv, FindAndReplaceOptions const & opt);
116 /** Computes the simple-text or LaTeX export (depending on opt) of buf starting
117 ** from cur and ending len positions after cur, if len is positive, or at the
118 ** paragraph or innermost inset end if len is -1.
120 ** This is useful for computing opt.search from the SearchAdvDialog controller (ControlSearchAdv).
121 ** Ideally, this should not be needed, and the opt.search field should become a Text const &.
123 docstring stringifyFromForSearch(
124 FindAndReplaceOptions const & opt,
125 DocIterator const & cur,
126 int len = -1);
128 } // namespace lyx
130 #endif // LYXFIND_H