1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : PyConsole_Editor.h
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 #ifndef PYCONSOLE_EDITOR_H
26 #define PYCONSOLE_EDITOR_H
28 #include "PyConsole.h"
33 class PyConsole_Interp;
34 class PyInterp_Request;
37 class PYCONSOLE_EXPORT PyConsole_Editor : public QTextEdit
42 PyConsole_Editor( PyConsole_Interp*, QWidget* = 0 );
45 PyConsole_Interp* getInterp() const;
47 virtual void addText( const QString&, const bool = false, const bool = false );
48 bool isCommand( const QString& ) const;
50 virtual void exec( const QString& );
51 void execAndWait( const QString& );
54 void setIsSync( const bool );
56 bool isSuppressOutput() const;
57 void setIsSuppressOutput( const bool );
59 bool isShowBanner() const;
60 void setIsShowBanner( const bool );
62 void setAutoCompletion( bool );
63 bool autoCompletion() const;
65 bool isLogging() const;
67 virtual QSize sizeHint() const;
69 bool startLog( const QString& );
70 bool dump( const QString& );
73 void updateDoc( const QString& );
84 virtual void dropEvent( QDropEvent* );
85 virtual void mousePressEvent( QMouseEvent* );
86 virtual void mouseReleaseEvent( QMouseEvent* );
87 virtual void keyPressEvent ( QKeyEvent* );
88 virtual void customEvent( QEvent* );
90 virtual void insertFromMimeData( const QMimeData* );
92 void putLog( const QString& );
94 virtual QString getDumpFileName();
95 virtual QString getLogFileName();
98 void multilinePaste( const QString& );
99 void multiLineProcessNextLine();
103 void handleBackTab();
104 void clearCompletion();
105 QString formatCompletion( const QStringList& ) const;
106 QString formatDocHTML( const QString& ) const;
107 QString extractCommon( const QStringList& ) const;
109 PyInterp_Request* createCmdRequest( const QString& );
110 PyInterp_Request* createTabRequest( const QString& );
112 QString banner() const;
113 inline int promptSize() const { return myPrompt.size(); }
115 PyConsole_Interp* myInterp; //!< python interpreter
116 QString myCommandBuffer; //!< python command buffer
117 QString myCurrentCommand; //!< currently being printed command
118 QString myPrompt; //!< current command line prompt
119 int myCmdInHistory; //!< current history command index
120 QString myLogFile; //!< current output log
121 QStringList myHistory; //!< commands history buffer
122 QEventLoop* myEventLoop; //!< internal event loop
123 bool myShowBanner; //!< 'show banner' flag
124 QStringList myQueue; //!< python commands queue
125 bool myIsSync; //!< synchronous mode flag
126 bool myIsSuppressOutput; //!< suppress output flag
127 bool myMultiLinePaste; //!< true when pasting several lines
128 QQueue<QString> myMultiLineContent; //!< queue of lines being pasted
129 bool myAutoCompletion; //!< auto-completion mode flag
130 bool myTabMode; //!< flag that is \c true when editor performs completion
131 QString myComplBeforePoint; //!< string on which the dir() command is executed
132 QString myComplAfterPoint; //!< string on which the results of the dir() are matched
133 int myComplCursorPos; //!< cursor position when <TAB> is hit
137 #endif // PYCONSOLE_EDITOR_H