2017-03-29 10:18:37 +00:00
|
|
|
#ifndef HIGHLIGHTER_H
|
|
|
|
#define HIGHLIGHTER_H
|
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2017-10-15 19:19:48 +00:00
|
|
|
|
|
|
|
#include <QSyntaxHighlighter>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QHash>
|
|
|
|
#include <QTextCharFormat>
|
2019-10-13 14:59:12 +00:00
|
|
|
#include <QRegularExpression>
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
class QTextDocument;
|
|
|
|
class MainWindow;
|
|
|
|
|
|
|
|
class Highlighter : public QSyntaxHighlighter
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-05-04 07:58:32 +00:00
|
|
|
Highlighter(QTextDocument *parent = nullptr);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void highlightBlock(const QString &text);
|
|
|
|
|
|
|
|
private:
|
2017-10-09 18:08:35 +00:00
|
|
|
CutterCore *core;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
struct HighlightingRule {
|
2019-10-13 14:59:12 +00:00
|
|
|
QRegularExpression pattern;
|
2017-03-29 10:18:37 +00:00
|
|
|
QTextCharFormat format;
|
|
|
|
};
|
|
|
|
QVector<HighlightingRule> highlightingRules;
|
|
|
|
|
2019-10-13 14:59:12 +00:00
|
|
|
QRegularExpression commentStartRegularExpression;
|
|
|
|
QRegularExpression commentEndRegularExpression;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
QTextCharFormat keywordFormat;
|
|
|
|
QTextCharFormat regFormat;
|
|
|
|
QTextCharFormat classFormat;
|
|
|
|
QTextCharFormat singleLineCommentFormat;
|
|
|
|
QTextCharFormat multiLineCommentFormat;
|
|
|
|
QTextCharFormat quotationFormat;
|
|
|
|
QTextCharFormat functionFormat;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // HIGHLIGHTER_H
|