tageditor/gui/javascripthighlighter.h

40 lines
950 B
C
Raw Normal View History

2015-04-22 19:33:53 +02:00
#ifndef JAVASCRIPTHIGHLIGHTER_H
#define JAVASCRIPTHIGHLIGHTER_H
#include <QRegularExpression>
2015-04-22 19:33:53 +02:00
#include <QSyntaxHighlighter>
namespace QtGui {
2018-03-07 01:18:01 +01:00
class JavaScriptHighlighter : public QSyntaxHighlighter {
2015-04-22 19:33:53 +02:00
Q_OBJECT
public:
JavaScriptHighlighter(QTextDocument *parent = nullptr);
protected:
void highlightBlock(const QString &text) override;
2015-04-22 19:33:53 +02:00
private:
2018-03-07 01:18:01 +01:00
struct HighlightingRule {
QRegularExpression pattern;
2015-04-22 19:33:53 +02:00
QTextCharFormat format;
};
QVector<HighlightingRule> m_highlightingRules;
QRegularExpression m_commentStartExpression;
QRegularExpression m_commentEndExpression;
2015-04-22 19:33:53 +02:00
QTextCharFormat m_keywordFormat;
QTextCharFormat m_classFormat;
QTextCharFormat m_singleLineCommentFormat;
QTextCharFormat m_multiLineCommentFormat;
QTextCharFormat m_stringFormat;
QTextCharFormat m_regexFormat;
2015-04-22 19:33:53 +02:00
QTextCharFormat m_functionFormat;
};
2018-03-07 01:18:01 +01:00
} // namespace QtGui
2015-04-22 19:33:53 +02:00
#endif // JAVASCRIPTHIGHLIGHTER_H