| 1 | #pragma once |
| 2 | |
| 3 | // QCodeEditor |
| 4 | #include <QStyleSyntaxHighlighter> // Required for inheritance |
| 5 | #include <QHighlightRule> |
| 6 | #include <QHighlightBlockRule> |
| 7 | |
| 8 | // Qt |
| 9 | #include <QRegularExpression> |
| 10 | #include <QVector> |
| 11 | |
| 12 | class QSyntaxStyle; |
| 13 | |
| 14 | /** |
| 15 | * @brief Class, that describes Glsl code |
| 16 | * highlighter. |
| 17 | */ |
| 18 | class QPythonHighlighter : public QStyleSyntaxHighlighter |
| 19 | { |
| 20 | Q_OBJECT |
| 21 | public: |
| 22 | |
| 23 | /** |
| 24 | * @brief Constructor. |
| 25 | * @param document Pointer to document. |
| 26 | */ |
| 27 | explicit QPythonHighlighter(QTextDocument* document=nullptr); |
| 28 | |
| 29 | protected: |
| 30 | void highlightBlock(const QString& text) override; |
| 31 | |
| 32 | private: |
| 33 | |
| 34 | QVector<QHighlightRule> m_highlightRules; |
| 35 | QVector<QHighlightBlockRule> m_highlightBlockRules; |
| 36 | |
| 37 | QRegularExpression m_includePattern; |
| 38 | QRegularExpression m_functionPattern; |
| 39 | QRegularExpression m_defTypePattern; |
| 40 | }; |
| 41 |