Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsyntaxhighlighter.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSYNTAXHIGHLIGHTER_H
5#define QSYNTAXHIGHLIGHTER_H
6
7#include <QtGui/qtguiglobal.h>
8
9#ifndef QT_NO_SYNTAXHIGHLIGHTER
10
11#include <QtCore/qobject.h>
12#include <QtGui/qtextobject.h>
13
15
16
17class QTextDocument;
19class QTextCharFormat;
20class QFont;
21class QColor;
23
24class Q_GUI_EXPORT QSyntaxHighlighter : public QObject
25{
27 Q_DECLARE_PRIVATE(QSyntaxHighlighter)
28public:
29 explicit QSyntaxHighlighter(QObject *parent);
30 explicit QSyntaxHighlighter(QTextDocument *parent);
32
33 void setDocument(QTextDocument *doc);
34 QTextDocument *document() const;
35
36public Q_SLOTS:
37 void rehighlight();
38 void rehighlightBlock(const QTextBlock &block);
39
40protected:
41 virtual void highlightBlock(const QString &text) = 0;
42
43 void setFormat(int start, int count, const QTextCharFormat &format);
44 void setFormat(int start, int count, const QColor &color);
45 void setFormat(int start, int count, const QFont &font);
46 QTextCharFormat format(int pos) const;
47
48 int previousBlockState() const;
49 int currentBlockState() const;
50 void setCurrentBlockState(int newState);
51
52 void setCurrentBlockUserData(QTextBlockUserData *data);
53 QTextBlockUserData *currentBlockUserData() const;
54
55 QTextBlock currentBlock() const;
56
57private:
58 Q_DISABLE_COPY(QSyntaxHighlighter)
59 Q_PRIVATE_SLOT(d_func(), void _q_reformatBlocks(int from, int charsRemoved, int charsAdded))
60 Q_PRIVATE_SLOT(d_func(), void _q_delayedRehighlight())
61};
62
64
65#endif // QT_NO_SYNTAXHIGHLIGHTER
66
67#endif // QSYNTAXHIGHLIGHTER_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\reentrant
Definition qfont.h:22
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\reentrant \inmodule QtGui
virtual void highlightBlock(const QString &text)=0
Highlights the given text block.
\reentrant
\reentrant \inmodule QtGui
widget setFormat(format)
QString text
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint color
[2]
GLuint start
GLint GLsizei GLsizei GLenum format
#define Q_OBJECT
#define Q_SLOTS
#define Q_PRIVATE_SLOT(d, signature)