cutter/src/common/Highlighter.h

45 lines
898 B
C
Raw Normal View History

#ifndef HIGHLIGHTER_H
#define HIGHLIGHTER_H
2018-03-04 17:42:02 +00:00
#include "Cutter.h"
#include <QSyntaxHighlighter>
#include <QHash>
#include <QTextCharFormat>
class QTextDocument;
class MainWindow;
class Highlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
Highlighter(QTextDocument *parent = nullptr);
protected:
void highlightBlock(const QString &text);
private:
2017-10-09 18:08:35 +00:00
CutterCore *core;
2018-03-21 20:32:32 +00:00
struct HighlightingRule {
QRegExp pattern;
QTextCharFormat format;
};
QVector<HighlightingRule> highlightingRules;
QRegExp commentStartExpression;
QRegExp commentEndExpression;
QTextCharFormat keywordFormat;
QTextCharFormat regFormat;
QTextCharFormat classFormat;
QTextCharFormat singleLineCommentFormat;
QTextCharFormat multiLineCommentFormat;
QTextCharFormat quotationFormat;
QTextCharFormat functionFormat;
};
#endif // HIGHLIGHTER_H