40 lines
831 B
C
40 lines
831 B
C
|
#ifndef JAVASCRIPTHIGHLIGHTER_H
|
||
|
#define JAVASCRIPTHIGHLIGHTER_H
|
||
|
|
||
|
#include <QSyntaxHighlighter>
|
||
|
|
||
|
namespace QtGui {
|
||
|
|
||
|
class JavaScriptHighlighter : public QSyntaxHighlighter
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
JavaScriptHighlighter(QTextDocument *parent = nullptr);
|
||
|
|
||
|
protected:
|
||
|
void highlightBlock(const QString &text);
|
||
|
|
||
|
private:
|
||
|
struct HighlightingRule
|
||
|
{
|
||
|
QRegExp pattern;
|
||
|
QTextCharFormat format;
|
||
|
};
|
||
|
QVector<HighlightingRule> m_highlightingRules;
|
||
|
|
||
|
QRegExp m_commentStartExpression;
|
||
|
QRegExp m_commentEndExpression;
|
||
|
|
||
|
QTextCharFormat m_keywordFormat;
|
||
|
QTextCharFormat m_classFormat;
|
||
|
QTextCharFormat m_singleLineCommentFormat;
|
||
|
QTextCharFormat m_multiLineCommentFormat;
|
||
|
QTextCharFormat m_quotationFormat;
|
||
|
QTextCharFormat m_functionFormat;
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif // JAVASCRIPTHIGHLIGHTER_H
|