Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

gui/StelScriptSyntaxHighlighter.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2009 Matthew Gates
00004  *
00005  * Derived from the QT syntax highlighter example under the GNU GPL.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 
00038 protected:
00039     void highlightBlock(const QString &text);
00040 
00041 private:
00042     struct HighlightingRule
00043     {
00044         QRegExp pattern;
00045         QTextCharFormat format;
00046     };
00047     QVector<HighlightingRule> highlightingRules;
00048 
00049     QTextCharFormat keywordFormat;
00050     QTextCharFormat moduleFormat;
00051     QTextCharFormat singleLineCommentFormat;
00052     QTextCharFormat quotationFormat;
00053     QTextCharFormat functionFormat;
00054 };
00055 
00056 #endif // _STELSCRIPTSYNTAXHIGHLIGHTER_HPP_
00057 

Generated on Mon Mar 22 09:55:38 2010 for Stellarium by  doxygen 1.5.5