33 lines
732 B
C
33 lines
732 B
C
|
#pragma once
|
|||
|
|
|||
|
#include <QSyntaxHighlighter>
|
|||
|
#include <QRegularExpression>
|
|||
|
|
|||
|
class Highlighter : public QSyntaxHighlighter
|
|||
|
{
|
|||
|
Q_OBJECT
|
|||
|
|
|||
|
public:
|
|||
|
Highlighter(QTextDocument* parent = 0);
|
|||
|
|
|||
|
protected:
|
|||
|
void highlightBlock(const QString& text) override;
|
|||
|
|
|||
|
private:
|
|||
|
struct HighlightingRule
|
|||
|
{
|
|||
|
QRegularExpression pattern;
|
|||
|
QTextCharFormat format;
|
|||
|
};
|
|||
|
QVector<HighlightingRule> highlightingRules;
|
|||
|
QRegularExpression commentStartExpression;
|
|||
|
QRegularExpression commentEndExpression;
|
|||
|
QTextCharFormat keywordFormat;
|
|||
|
QTextCharFormat preprocessorFormat;
|
|||
|
QTextCharFormat classFormat;
|
|||
|
QTextCharFormat singleLineCommentFormat;
|
|||
|
QTextCharFormat multiLineCommentFormat;
|
|||
|
QTextCharFormat quotationFormat;
|
|||
|
QTextCharFormat functionFormat;
|
|||
|
};
|