1
1

syntaxhighlighter.h 707 B

123456789101112131415161718192021222324252627282930313233
  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 keywordFormat;
  21. QTextCharFormat bankFormat;
  22. QTextCharFormat singleLineCommentFormat;
  23. QTextCharFormat multiLineCommentFormat;
  24. };
  25. #endif // SYNTAXHIGHLIGHTER_H