00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _STELSCRIPTSYNTAXHIGHLIGHTER_HPP_
00023 #define _STELSCRIPTSYNTAXHIGHLIGHTER_HPP_
00024
00025 #include <QSyntaxHighlighter>
00026 #include <QHash>
00027 #include <QTextCharFormat>
00028
00029 class QTextDocument;
00030
00031 class StelScriptSyntaxHighlighter : public QSyntaxHighlighter
00032 {
00033 Q_OBJECT
00034
00035 public:
00036 StelScriptSyntaxHighlighter(QTextDocument* parent=0);
00037 void setFormats(void);
00038
00039 protected:
00040 void highlightBlock(const QString &text);
00041
00042 private:
00043 struct HighlightingRule
00044 {
00045 QRegExp pattern;
00046 QTextCharFormat* format;
00047 };
00048 QVector<HighlightingRule> highlightingRules;
00049
00050 QTextCharFormat keywordFormat;
00051 QTextCharFormat moduleFormat;
00052 QTextCharFormat commentFormat;
00053 QTextCharFormat constantFormat;
00054 QTextCharFormat functionFormat;
00055 };
00056
00057 #endif // _STELSCRIPTSYNTAXHIGHLIGHTER_HPP_
00058