1 | /* |
2 | SPDX-FileCopyrightText: 2010 Bernhard Beschow <bbeschow@cs.tu-berlin.de> |
3 | SPDX-FileCopyrightText: 2007 Sebastian Pipping <webmaster@hartwork.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef KATE_MATCH_H |
9 | #define KATE_MATCH_H |
10 | |
11 | #include <memory> |
12 | |
13 | #include <ktexteditor/document.h> |
14 | #include <ktexteditor/movingrange.h> |
15 | |
16 | namespace KTextEditor |
17 | { |
18 | class DocumentPrivate; |
19 | } |
20 | |
21 | class KateMatch |
22 | { |
23 | public: |
24 | KateMatch(KTextEditor::DocumentPrivate *document, KTextEditor::SearchOptions options); |
25 | KTextEditor::Range searchText(KTextEditor::Range range, const QString &pattern); |
26 | KTextEditor::Range replace(const QString &replacement, bool blockMode, int replacementCounter = 1); |
27 | bool isValid() const; |
28 | bool isEmpty() const; |
29 | KTextEditor::Range range() const; |
30 | |
31 | private: |
32 | /** |
33 | * Resolve references and escape sequences. |
34 | */ |
35 | QString buildReplacement(const QString &replacement, bool blockMode, int replacementCounter) const; |
36 | |
37 | private: |
38 | KTextEditor::DocumentPrivate *const m_document; |
39 | const KTextEditor::SearchOptions m_options; |
40 | QList<KTextEditor::Range> m_resultRanges; |
41 | |
42 | /** |
43 | * moving range to track replace changes |
44 | * kept for later reuse |
45 | */ |
46 | std::unique_ptr<KTextEditor::MovingRange> m_afterReplaceRange; |
47 | }; |
48 | |
49 | #endif // KATE_MATCH_H |
50 | |