KSyntaxHighlighting

state.h
1/*
2 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#ifndef KSYNTAXHIGHLIGHTING_STATE_H
8#define KSYNTAXHIGHLIGHTING_STATE_H
9
10#include "ksyntaxhighlighting_export.h"
11
12#include <QExplicitlySharedDataPointer>
13#include <QHash>
14
15namespace KSyntaxHighlighting
16{
17class State;
18class StateData;
19
20KSYNTAXHIGHLIGHTING_EXPORT std::size_t qHash(const State &state, std::size_t seed = 0);
21
22/** Opaque handle to the state of the highlighting engine.
23 * This needs to be fed into AbstractHighlighter for every line of text
24 * and allows concrete highlighter implementations to store state per
25 * line for fast re-highlighting of specific lines (e.g. during editing).
26 *
27 * @since 5.28
28 */
29class KSYNTAXHIGHLIGHTING_EXPORT State
30{
31public:
32 /** Creates an initial state, ie. what should be used for the first line
33 * in a document.
34 */
36 State(State &&other) noexcept;
37 State(const State &other) noexcept;
38 ~State();
39 State &operator=(State &&rhs) noexcept;
40 State &operator=(const State &rhs) noexcept;
41
42 /** Compares two states for equality.
43 * For two equal states and identical text input, AbstractHighlighter
44 * guarantees to produce equal results. This can be used to only
45 * re-highlight as many lines as necessary during editing.
46 */
47 bool operator==(const State &other) const;
48 /** Compares two states for inequality.
49 * This is the opposite of operator==().
50 */
51 bool operator!=(const State &other) const;
52
53 /**
54 * Returns whether or not indentation-based folding is enabled in this state.
55 * When using a Definition with indentation-based folding, use
56 * this method to check if indentation-based folding has been
57 * suspended in the current line.
58 *
59 * @see Definition::indentationBasedFoldingEnabled()
60 */
61 bool indentationBasedFoldingEnabled() const;
62
63private:
64 friend class StateData;
65 friend KSYNTAXHIGHLIGHTING_EXPORT std::size_t qHash(const State &, std::size_t);
67};
68}
69
70QT_BEGIN_NAMESPACE
71Q_DECLARE_TYPEINFO(KSyntaxHighlighting::State, Q_RELOCATABLE_TYPE);
72QT_END_NAMESPACE
73
74#endif // KSYNTAXHIGHLIGHTING_STATE_H
Opaque handle to the state of the highlighting engine.
Definition state.h:30
State()
Creates an initial state, ie.
KCALENDARCORE_EXPORT size_t qHash(const KCalendarCore::Period &key, size_t seed=0)
Syntax highlighting engine for Kate syntax definitions.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.