Advertisement
Guest User

Untitled

a guest
Feb 9th, 2021
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include <QSyntaxHighlighter>
  4. #include <QTextCharFormat>
  5. #include <QTextDocument>
  6. #include <QColor>
  7.  
  8. class SyntaxPartisaner : public QSyntaxHighlighter
  9. {
  10. Q_OBJECT
  11. public:
  12. SyntaxPartisaner(QTextDocument *parent,QColor keywordColor,
  13. QColor classColor,QColor singleCommentColor,QColor multiCommentColor,
  14. QColor quotationColor,QColor funcColor);
  15. SyntaxPartisaner(QTextDocument *parent);
  16. virtual ~SyntaxPartisaner() override;
  17. protected:
  18. virtual void highlightBlock(const QString &text) override;
  19.  
  20. private:
  21. struct HighlightingRule
  22. {
  23. QRegExp pattern;
  24. QTextCharFormat format;
  25. };
  26. QVector<HighlightingRule> highlightingRules;
  27.  
  28. QRegExp commentStartExpression;
  29. QRegExp commentEndExpression;
  30.  
  31. QTextCharFormat keywordFormat;
  32. QTextCharFormat classFormat;
  33. QTextCharFormat singleLineKey;
  34. QTextCharFormat singleLineValue;
  35. QTextCharFormat singleLineCommentFormat;
  36. QTextCharFormat multiLineCommentFormat;
  37. QTextCharFormat quotationFormat;
  38. QTextCharFormat functionFormat;
  39. };
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement