File indexing completed on 2024-04-14 03:55:21
0001 /* 0002 SPDX-FileCopyrightText: 2010 Bernhard Beschow <bbeschow@cs.tu-berlin.de> 0003 SPDX-FileCopyrightText: 2007 Sebastian Pipping <webmaster@hartwork.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KATE_MATCH_H 0009 #define KATE_MATCH_H 0010 0011 #include <memory> 0012 0013 #include <ktexteditor/document.h> 0014 #include <ktexteditor/movingrange.h> 0015 0016 namespace KTextEditor 0017 { 0018 class DocumentPrivate; 0019 } 0020 0021 class KateMatch 0022 { 0023 public: 0024 KateMatch(KTextEditor::DocumentPrivate *document, KTextEditor::SearchOptions options); 0025 KTextEditor::Range searchText(KTextEditor::Range range, const QString &pattern); 0026 KTextEditor::Range replace(const QString &replacement, bool blockMode, int replacementCounter = 1); 0027 bool isValid() const; 0028 bool isEmpty() const; 0029 KTextEditor::Range range() const; 0030 0031 private: 0032 /** 0033 * Resolve references and escape sequences. 0034 */ 0035 QString buildReplacement(const QString &replacement, bool blockMode, int replacementCounter) const; 0036 0037 private: 0038 KTextEditor::DocumentPrivate *const m_document; 0039 const KTextEditor::SearchOptions m_options; 0040 QList<KTextEditor::Range> m_resultRanges; 0041 0042 /** 0043 * moving range to track replace changes 0044 * kept for later reuse 0045 */ 0046 std::unique_ptr<KTextEditor::MovingRange> m_afterReplaceRange; 0047 }; 0048 0049 #endif // KATE_MATCH_H