00001 00009 #ifndef HIGHLIGHTER_H 00010 #define HIGHLIGHTER_H 00011 00012 #include <QSyntaxHighlighter> 00013 00014 #include <QHash> 00015 #include <QTextCharFormat> 00016 00017 class QTextDocument; 00018 00019 00024 class Highlighter : public QSyntaxHighlighter 00025 { 00026 Q_OBJECT 00027 00028 public: 00030 Highlighter(QTextDocument *parent = 0); 00031 00032 protected: 00034 void highlightBlock(const QString &text); 00035 00036 private: 00038 struct HighlightingRule 00039 { 00041 QRegExp pattern; 00043 QTextCharFormat format; 00044 }; 00046 QVector<HighlightingRule> highlightingRules; 00048 QRegExp commentStartExpression; 00050 QRegExp commentEndExpression; 00052 QTextCharFormat keywordFormat; 00054 QTextCharFormat singleLineCommentFormat; 00056 QTextCharFormat multiLineCommentFormat; 00058 QTextCharFormat quotationFormat; 00059 }; 00060 #endif