1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of Qt Designer. This header
10// file may change from version to version without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef CSSHIGHLIGHTER_H
16#define CSSHIGHLIGHTER_H
17
18#include <QtGui/qsyntaxhighlighter.h>
19#include <QtGui/qcolor.h>
20#include "shared_global_p.h"
21
22QT_BEGIN_NAMESPACE
23
24namespace qdesigner_internal {
25
26struct CssHighlightColors
27{
28 QColor selector;
29 QColor property;
30 QColor value;
31 QColor pseudo1;
32 QColor pseudo2;
33 QColor quote;
34 QColor comment;
35};
36
37class QDESIGNER_SHARED_EXPORT CssHighlighter : public QSyntaxHighlighter
38{
39 Q_OBJECT
40public:
41 explicit CssHighlighter(const CssHighlightColors &colors,
42 QTextDocument *document);
43
44protected:
45 void highlightBlock(const QString&) override;
46 void highlight(const QString&, int, int, int/*State*/);
47
48private:
49 enum State { Selector, Property, Value, Pseudo, Pseudo1, Pseudo2, Quote,
50 MaybeComment, Comment, MaybeCommentEnd };
51
52 const CssHighlightColors m_colors;
53};
54
55} // namespace qdesigner_internal
56
57QT_END_NAMESPACE
58
59#endif // CSSHIGHLIGHTER_H
60

source code of qttools/src/designer/src/lib/shared/csshighlighter_p.h