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>
29 class PyEditor_Keywords;
31 class PyEditor_PyHighlighter : public QSyntaxHighlighter
37 struct ParenthesisInfo
43 class TextBlockData : public QTextBlockUserData
48 QVector<ParenthesisInfo*> parentheses();
49 void insert( ParenthesisInfo* );
52 QVector<ParenthesisInfo*> myParentheses;
56 PyEditor_PyHighlighter( QTextDocument*,
57 PyEditor_Keywords*, PyEditor_Keywords* );
60 void onKeywordsChanged();
63 void updateHighlight();
66 struct HighlightingRule
69 QTextCharFormat format;
72 QVector<HighlightingRule> highlightingRules;
74 enum Brackets { RoundBrackets, CurlyBrackets, SquareBrackets };
76 QRegExp tripleQuotesExpression;
77 QRegExp tripleSingleExpression;
78 QRegExp tripleDoubleExpression;
80 QTextCharFormat classFormat;
81 QTextCharFormat referenceClassFormat;
82 QTextCharFormat functionFormat;
83 QTextCharFormat numberFormat;
84 QTextCharFormat singleLineCommentFormat;
85 QTextCharFormat multiLineCommentFormat;
86 QTextCharFormat quotationFormat;
88 void highlightBlock( const QString& );
89 void insertBracketsData( char, char, TextBlockData*, const QString& );
90 void insertBracketsData( Brackets, TextBlockData*, const QString& );
93 PyEditor_Keywords* myStdKeywords;
94 PyEditor_Keywords* myUserKeywords;
97 #endif // PYEDITOR_PYHIGHLIGHTER_H