cutter/src/utils/SyntaxHighlighter.h
2018-03-21 21:33:40 +01:00

34 lines
696 B
C++

#pragma once
#include <QSyntaxHighlighter>
#include <QVector>
#include <QTextDocument>
#include <QRegularExpression>
#include <QTextCharFormat>
class SyntaxHighlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
SyntaxHighlighter(QTextDocument *parent = nullptr);
virtual ~SyntaxHighlighter() = default;
protected:
void highlightBlock(const QString &text) override;
private:
struct HighlightingRule {
QRegularExpression pattern;
QTextCharFormat format;
};
QVector<HighlightingRule> highlightingRules;
QRegularExpression commentStartExpression;
QRegularExpression commentEndExpression;
QTextCharFormat multiLineCommentFormat;
};