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