1
1

syntaxhighlighter.h 747 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef SYNTAXHIGHLIGHTER_H
  2. #define SYNTAXHIGHLIGHTER_H
  3. #include <QSyntaxHighlighter>
  4. class SyntaxHighlighter : public QSyntaxHighlighter
  5. {
  6. Q_OBJECT
  7. public:
  8. SyntaxHighlighter(QTextDocument *parent = 0);
  9. protected:
  10. void highlightBlock(const QString &text) Q_DECL_OVERRIDE;
  11. private:
  12. struct HighlightingRule
  13. {
  14. QRegExp pattern;
  15. QTextCharFormat format;
  16. };
  17. QVector<HighlightingRule> highlightingRules;
  18. QRegExp commentStartExpression;
  19. QRegExp commentEndExpression;
  20. QTextCharFormat instructionFormat;
  21. QTextCharFormat variableFormat;
  22. QTextCharFormat bankFormat;
  23. QTextCharFormat singleLineCommentFormat;
  24. QTextCharFormat multiLineCommentFormat;
  25. };
  26. #endif // SYNTAXHIGHLIGHTER_H