KTextEditor

kateplaintextsearch.h
1/*
2 SPDX-FileCopyrightText: 2009-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_PLAINTEXTSEARCH_H_
9#define _KATE_PLAINTEXTSEARCH_H_
10
11#include <QObject>
12
13#include <ktexteditor/range.h>
14
15#include <ktexteditor_export.h>
16
17namespace KTextEditor
18{
19class Document;
20}
21
22/**
23 * Object to help to search for plain text.
24 * This should be NO QObject, it is created too often!
25 * I measured that, if you create it 20k times to replace for example " " in a document, that takes seconds on a modern machine!
26 */
27class KTEXTEDITOR_EXPORT KatePlainTextSearch
28{
29public:
30 explicit KatePlainTextSearch(const KTextEditor::Document *document, Qt::CaseSensitivity caseSensitivity, bool wholeWords);
31 ~KatePlainTextSearch() = default;
32
33public:
34 /**
35 * Search for the given \p text inside the range \p inputRange taking
36 * into account whether to search \p casesensitive and \p backwards.
37 *
38 * \param text text to search for
39 * \param inputRange Range to search in
40 * \param backwards if \e true, the search will be backwards
41 * \return The valid range of the matched text if \p text was found. If
42 * the \p text was not found, the returned range is not valid
43 * (see Range::isValid()).
44 * \see KTextEditor::Range
45 */
46 KTextEditor::Range search(const QString &text, KTextEditor::Range inputRange, bool backwards = false);
47
48private:
49 const KTextEditor::Document *m_document;
50 Qt::CaseSensitivity m_caseSensitivity;
51 bool m_wholeWords;
52};
53
54#endif
A KParts derived class representing a text document.
Definition document.h:284
An object representing a section of text, from one Cursor to another.
Object to help to search for plain text.
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
CaseSensitivity
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:57:26 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.