File indexing completed on 2024-05-12 15:50:06
0001 /* 0002 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #ifndef KSYNTAXHIGHLIGHTING_STATE_H 0008 #define KSYNTAXHIGHLIGHTING_STATE_H 0009 0010 #include "ksyntaxhighlighting_export.h" 0011 0012 #include <QExplicitlySharedDataPointer> 0013 0014 namespace KSyntaxHighlighting 0015 { 0016 class StateData; 0017 0018 /** Opaque handle to the state of the highlighting engine. 0019 * This needs to be fed into AbstractHighlighter for every line of text 0020 * and allows concrete highlighter implementations to store state per 0021 * line for fast re-highlighting of specific lines (e.g. during editing). 0022 * 0023 * @since 5.28 0024 */ 0025 class KSYNTAXHIGHLIGHTING_EXPORT State 0026 { 0027 public: 0028 /** Creates an initial state, ie. what should be used for the first line 0029 * in a document. 0030 */ 0031 State(); 0032 State(const State &other); 0033 ~State(); 0034 State &operator=(const State &rhs); 0035 0036 /** Compares two states for equality. 0037 * For two equal states and identical text input, AbstractHighlighter 0038 * guarantees to produce equal results. This can be used to only 0039 * re-highlight as many lines as necessary during editing. 0040 */ 0041 bool operator==(const State &other) const; 0042 /** Compares two states for inequality. 0043 * This is the opposite of operator==(). 0044 */ 0045 bool operator!=(const State &other) const; 0046 0047 /** 0048 * Returns whether or not indentation-based folding is enabled in this state. 0049 * When using a Definition with indentation-based folding, use 0050 * this method to check if indentation-based folding has been 0051 * suspended in the current line. 0052 * 0053 * @see Definition::indentationBasedFoldingEnabled() 0054 */ 0055 bool indentationBasedFoldingEnabled() const; 0056 0057 private: 0058 friend class StateData; 0059 QExplicitlySharedDataPointer<StateData> d; 0060 }; 0061 0062 } 0063 0064 QT_BEGIN_NAMESPACE 0065 Q_DECLARE_TYPEINFO(KSyntaxHighlighting::State, Q_MOVABLE_TYPE); 0066 QT_END_NAMESPACE 0067 0068 #endif // KSYNTAXHIGHLIGHTING_STATE_H