| 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 | #include <QMap> |
| 12 | |
| 13 | class QSyntaxStyle; |
| 14 | |
| 15 | /** |
| 16 | * @brief Class, that describes C++ code |
| 17 | * highlighter. |
| 18 | */ |
| 19 | class QLuaHighlighter : public QStyleSyntaxHighlighter |
| 20 | { |
| 21 | Q_OBJECT |
| 22 | public: |
| 23 | |
| 24 | /** |
| 25 | * @brief Constructor. |
| 26 | * @param document Pointer to document. |
| 27 | */ |
| 28 | explicit QLuaHighlighter(QTextDocument* document=nullptr); |
| 29 | |
| 30 | protected: |
| 31 | void highlightBlock(const QString& text) override; |
| 32 | |
| 33 | private: |
| 34 | QVector<QHighlightRule> m_highlightRules; |
| 35 | QVector<QHighlightBlockRule> m_highlightBlockRules; |
| 36 | |
| 37 | QRegularExpression m_requirePattern; |
| 38 | QRegularExpression m_functionPattern; |
| 39 | QRegularExpression m_defTypePattern; |
| 40 | }; |