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_Keywords;
32 class PyEditor_Completer;
33 class PyEditor_PyHighlighter;
35 class PYEDITOR_EXPORT PyEditor_Editor : public QPlainTextEdit
40 typedef enum { None, Auto, Manual, Always } CompletionPolicy;
43 PyEditor_Editor( QWidget* = 0 );
44 virtual ~PyEditor_Editor();
46 void setSettings( const PyEditor_Settings& );
47 const PyEditor_Settings& settings() const;
50 QStringList keywords() const;
51 void appendKeywords( const QStringList&, int, const QColor& = QColor() );
52 void removeKeywords( const QStringList& );
54 CompletionPolicy completionPolicy() const;
55 void setCompletionPolicy( const CompletionPolicy& );
58 void deleteSelected();
59 void append( const QString& );
60 void setText( const QString& text );
63 virtual void keyPressEvent( QKeyEvent* );
64 virtual void resizeEvent( QResizeEvent* );
65 virtual void paintEvent( QPaintEvent* );
67 PyEditor_Keywords* userKeywords() const;
68 PyEditor_Keywords* standardKeywords() const;
71 void updateHighlightCurrentLine();
72 void matchParentheses();
74 void updateLineNumberAreaWidth( int );
75 void updateLineNumberArea( const QRect&, int );
78 bool matchLeftParenthesis( const QTextBlock&, int, int );
79 bool matchRightParenthesis( const QTextBlock&, int, int );
80 void createParenthesisSelection( int );
81 bool isLeftBrackets( QChar );
82 bool isRightBrackets( QChar );
83 void lineNumberAreaPaintEvent( QPaintEvent* );
84 int lineNumberAreaWidth();
86 void handleHome( bool );
88 void tabIndentation( bool );
89 void indentSelection( bool );
91 int findFirstNonSpace( const QString& );
93 QWidget* myLineNumberArea;
94 PyEditor_PyHighlighter* mySyntaxHighlighter;
95 PyEditor_Completer* myCompleter;
96 PyEditor_Settings mySettings;
98 PyEditor_Keywords* myStdKeywords;
99 PyEditor_Keywords* myUserKeywords;
101 CompletionPolicy myCompletionPolicy;
103 friend class PyEditor_LineNumberArea;
106 #endif // PYEDITOR_EDITOR_H