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;
36 class PYEDITOR_EXPORT PyEditor_Editor : public QPlainTextEdit
41 typedef enum { None, Auto, Manual, Always } CompletionPolicy;
44 PyEditor_Editor( QWidget* = 0 );
45 virtual ~PyEditor_Editor();
47 void setSettings( const PyEditor_Settings& );
48 const PyEditor_Settings& settings() const;
51 QStringList keywords() const;
52 void appendKeywords( const QStringList&, int, const QColor& = QColor() );
53 void removeKeywords( const QStringList& );
55 CompletionPolicy completionPolicy() const;
56 void setCompletionPolicy( const CompletionPolicy& );
59 void deleteSelected();
60 void append( const QString& );
61 void setText( const QString& text );
64 virtual void keyPressEvent( QKeyEvent* );
65 virtual void resizeEvent( QResizeEvent* );
66 virtual void paintEvent( QPaintEvent* );
67 virtual void contextMenuEvent( QContextMenuEvent* );
69 PyEditor_Keywords* userKeywords() const;
70 PyEditor_Keywords* standardKeywords() const;
73 void updateHighlightCurrentLine();
74 void matchParentheses();
76 void updateLineNumberAreaWidth( int );
77 void updateLineNumberArea( const QRect&, int );
80 void customizeMenu( QMenu* );
83 bool matchLeftParenthesis( const QTextBlock&, int, int );
84 bool matchRightParenthesis( const QTextBlock&, int, int );
85 void createParenthesisSelection( int );
86 bool isLeftBrackets( QChar );
87 bool isRightBrackets( QChar );
88 void lineNumberAreaPaintEvent( QPaintEvent* );
89 int lineNumberAreaWidth();
91 void handleHome( bool );
93 void tabIndentation( bool );
94 void indentSelection( bool );
96 int findFirstNonSpace( const QString& );
98 QWidget* myLineNumberArea;
99 PyEditor_PyHighlighter* mySyntaxHighlighter;
100 PyEditor_Completer* myCompleter;
101 PyEditor_Settings mySettings;
103 PyEditor_Keywords* myStdKeywords;
104 PyEditor_Keywords* myUserKeywords;
106 CompletionPolicy myCompletionPolicy;
108 friend class PyEditor_LineNumberArea;
111 #endif // PYEDITOR_EDITOR_H