1 // Copyright (C) 2015-2016 OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File : PyEditor_PyHighlighter.h
20 // Author : Maxim GLIBIN, Open CASCADE S.A.S. (maxim.glibin@opencascade.com)
23 #ifndef PYEDITOR_PYHIGHLIGHTER_H
24 #define PYEDITOR_PYHIGHLIGHTER_H
26 #include <QSyntaxHighlighter>
30 class PyEditor_PyHighlighter : public QSyntaxHighlighter
36 struct ParenthesisInfo
42 class TextBlockData : public QTextBlockUserData
47 QVector<ParenthesisInfo*> parentheses();
48 void insert( ParenthesisInfo* );
51 QVector<ParenthesisInfo*> myParentheses;
55 PyEditor_PyHighlighter( QTextDocument* = 0 );
58 QStringList keywords();
59 QStringList specialKeywords();
62 struct HighlightingRule
65 QTextCharFormat format;
68 QVector<HighlightingRule> highlightingRules;
70 enum Brackets { RoundBrackets, CurlyBrackets, SquareBrackets };
72 QRegExp tripleQuotesExpression;
73 QRegExp tripleSingleExpression;
74 QRegExp tripleDoubleExpression;
76 QTextCharFormat classFormat;
77 QTextCharFormat referenceClassFormat;
78 QTextCharFormat functionFormat;
79 QTextCharFormat keywordFormat;
80 QTextCharFormat specialFromat;
81 QTextCharFormat numberFormat;
82 QTextCharFormat singleLineCommentFormat;
83 QTextCharFormat multiLineCommentFormat;
84 QTextCharFormat quotationFormat;
86 void highlightBlock( const QString& );
87 void insertBracketsData( char, char, TextBlockData*, const QString& );
88 void insertBracketsData( Brackets, TextBlockData*, const QString& );
91 #endif // PYEDITOR_PYHIGHLIGHTER_H