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_Editor.h
20 // Author : Maxim GLIBIN, Open CASCADE S.A.S. (maxim.glibin@opencascade.com)
23 #ifndef PYEDITOR_EDITOR_H
24 #define PYEDITOR_EDITOR_H
27 #include "PyEditor_Settings.h"
29 #include <QPlainTextEdit>
31 class PyEditor_PyHighlighter;
33 class PYEDITOR_EXPORT PyEditor_Editor : public QPlainTextEdit
38 PyEditor_Editor( QWidget* = 0 );
39 virtual ~PyEditor_Editor();
41 void setSettings( const PyEditor_Settings& );
42 const PyEditor_Settings& settings() const;
46 void deleteSelected();
47 void append( const QString& );
48 void setText( const QString& text );
51 virtual void keyPressEvent( QKeyEvent* );
52 virtual void resizeEvent( QResizeEvent* );
53 virtual void paintEvent( QPaintEvent* );
56 void updateHighlightCurrentLine();
57 void matchParentheses();
59 void updateLineNumberAreaWidth( int );
60 void updateLineNumberArea( const QRect&, int );
63 bool matchLeftParenthesis( const QTextBlock&, int, int );
64 bool matchRightParenthesis( const QTextBlock&, int, int );
65 void createParenthesisSelection( int );
66 bool isLeftBrackets( QChar );
67 bool isRightBrackets( QChar );
68 void lineNumberAreaPaintEvent( QPaintEvent* );
69 int lineNumberAreaWidth();
71 void handleHome( bool );
73 void tabIndentation( bool );
74 void indentSelection( bool );
76 int findFirstNonSpace( const QString& );
78 QWidget* myLineNumberArea;
79 PyEditor_PyHighlighter* mySyntaxHighlighter;
80 PyEditor_Settings mySettings;
82 friend class PyEditor_LineNumberArea;
85 #endif // PYEDITOR_EDITOR_H