| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved. |
| 4 | ** |
| 5 | ** This file is part of the example classes of the Qt Toolkit. |
| 6 | ** |
| 7 | ** This file may be used under the terms of the GNU General Public |
| 8 | ** License version 2.0 as published by the Free Software Foundation |
| 9 | ** and appearing in the file LICENSE.GPL included in the packaging of |
| 10 | ** this file. Please review the following information to ensure GNU |
| 11 | ** General Public Licensing requirements will be met: |
| 12 | ** http://trolltech.com/products/qt/licenses/licensing/opensource/ |
| 13 | ** |
| 14 | ** If you are unsure which license is appropriate for your use, please |
| 15 | ** review the following information: |
| 16 | ** http://trolltech.com/products/qt/licenses/licensing/licensingoverview |
| 17 | ** or contact the sales department at [email protected]. |
| 18 | ** |
| 19 | ** In addition, as a special exception, Trolltech gives you certain |
| 20 | ** additional rights. These rights are described in the Trolltech GPL |
| 21 | ** Exception version 1.0, which can be found at |
| 22 | ** http://www.trolltech.com/products/qt/gplexception/ and in the file |
| 23 | ** GPL_EXCEPTION.txt in this package. |
| 24 | ** |
| 25 | ** In addition, as a special exception, Trolltech, as the sole copyright |
| 26 | ** holder for Qt Designer, grants users of the Qt/Eclipse Integration |
| 27 | ** plug-in the right for the Qt/Eclipse Integration to link to |
| 28 | ** functionality provided by Qt Designer and its related libraries. |
| 29 | ** |
| 30 | ** Trolltech reserves all rights not expressly granted herein. |
| 31 | ** |
| 32 | ** Trolltech ASA (c) 2007 |
| 33 | ** |
| 34 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
| 35 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 36 | ** |
| 37 | ****************************************************************************/ |
| 38 | |
| 39 | #ifndef HIGHLIGHTER_H |
| 40 | #define HIGHLIGHTER_H |
| 41 | |
| 42 | #include <QSyntaxHighlighter> |
| 43 | #include <QRegularExpression> |
| 44 | #include <QHash> |
| 45 | #include <QTextCharFormat> |
| 46 | #include "molecule.h" |
| 47 | class QTextDocument; |
| 48 | //! Highlighter changes the text style of the shelXle editor, output viewer and the list viewer \inherit QSyntaxHighlighter. |
| 49 | class Highlighter : public QSyntaxHighlighter{ |
| 50 | Q_OBJECT |
| 51 | |
| 52 | public: |
| 53 | Highlighter(QTextDocument *parent = 0); |
| 54 | Highlighter(QString FileName, QTextDocument *parent = 0); |
| 55 | // void setOutputStyle(); |
| 56 | bool outputStyle(){return outputstyle;} |
| 57 | // void setEditStyle(); |
| 58 | void highlightError(const QStringList fnd); |
| 59 | void loadHighlightPatterns(QString FileName); |
| 60 | public slots: |
| 61 | void highlightSearch(const QString &find); |
| 62 | void highlightDupl(const CEnvironment &dupls); |
| 63 | protected: |
| 64 | void highlightBlock(const QString &text); |
| 65 | |
| 66 | private: |
| 67 | bool outputstyle; |
| 68 | struct HighlightingRule { |
| 69 | QRegularExpression pattern; |
| 70 | QTextCharFormat format; |
| 71 | bool Comment; |
| 72 | inline bool operator == (const HighlightingRule &a){ |
| 73 | return (pattern.pattern()==a.pattern.pattern()); |
| 74 | } |
| 75 | }; |
| 76 | QList<HighlightingRule> highlightingRules, findRule; |
| 77 | QRegularExpression commentStartExpression; |
| 78 | QRegularExpression commentEndExpression; |
| 79 | |
| 80 | // QTextCharFormat keywordFormat; |
| 81 | // QTextCharFormat classFormat; |
| 82 | // QTextCharFormat numberFormat; |
| 83 | //QTextCharFormat keybitsFormat; |
| 84 | // QTextCharFormat staredFormat; |
| 85 | // QTextCharFormat toolongFormat; |
| 86 | // QTextCharFormat singleLineCommentFormat; |
| 87 | QTextCharFormat multiLineCommentFormat; |
| 88 | // QTextCharFormat quotationFormat; |
| 89 | // QTextCharFormat cellFormat; |
| 90 | // QTextCharFormat includeFormat; |
| 91 | }; |
| 92 | |
| 93 | #endif |