00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SYNTAX_HIGHLIGHTER_HPP
00021 #define SYNTAX_HIGHLIGHTER_HPP
00022
00023 #include <QtCore/QHash>
00024 #include <QtCore/QString>
00025 #include <QtCore/QStringList>
00026 #include <QtGui/QTextBlock>
00027 #include <QtGui/QTextCharFormat>
00028
00029 class QTextDocument;
00030
00041 class SyntaxHighLighter
00042 : public QObject
00043 {
00044 Q_OBJECT
00045 public:
00046 SyntaxHighLighter(QObject* parent = 0);
00047
00048 ~SyntaxHighLighter();
00049
00050 void addToDocument(QTextDocument* doc);
00051 void addMapping(const QString& pattern,
00052 const QTextCharFormat &format);
00053
00054 private slots:
00055 void highlight(int from,
00056 int removed,
00057 int added);
00058
00059 private:
00060 void highlightBlock(QTextBlock block);
00061
00062 QHash<QString,QTextCharFormat> __mappings;
00063 };
00064
00065
00066 #endif // SYNTAX_HIGHLIGHTER_HPP