Back to index

salome-gui  6.5.0
PyConsole_Editor.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
00024 // File   : PyConsole_Editor.h
00025 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00026 //
00027 #ifndef PYCONSOLE_EDITOR_H
00028 #define PYCONSOLE_EDITOR_H
00029 
00030 #include "PyConsole.h"
00031 
00032 #include <QTextEdit>
00033 
00034 class PyConsole_Interp;
00035 class PyInterp_Request;
00036 class QEventLoop;
00037 
00038 class PYCONSOLE_EXPORT PyConsole_Editor : public QTextEdit
00039 {
00040   Q_OBJECT;
00041 
00042 public:
00043   PyConsole_Editor( PyConsole_Interp* theInterp, QWidget *theParent = 0 );
00044   ~PyConsole_Editor();
00045   
00046   virtual void   addText( const QString& str, const bool newBlock = false ); 
00047   bool           isCommand( const QString& str ) const;
00048 
00049   virtual void   exec( const QString& command );
00050   void           execAndWait( const QString& command );
00051 
00052   bool           isSync() const;
00053   void           setIsSync( const bool );
00054 
00055   bool           isSuppressOutput() const;
00056   void           setIsSuppressOutput(const bool);
00057 
00058   bool           isShowBanner() const;
00059   void           setIsShowBanner( const bool );
00060 
00061   virtual QSize  sizeHint() const;
00062 
00063 protected:
00064   virtual void   dropEvent( QDropEvent* event );
00065   virtual void   mouseReleaseEvent( QMouseEvent* event );
00066   virtual void   keyPressEvent ( QKeyEvent* event);
00067   virtual void   customEvent( QEvent* event);
00068 
00069   virtual PyInterp_Request* createRequest( const QString& );
00070 
00071 public slots:
00072   void           cut();
00073   void           paste();
00074   void           clear();
00075   void           handleReturn();
00076   void           onPyInterpChanged( PyConsole_Interp* );
00077   void           dump();
00078   
00079 private:
00080   PyConsole_Interp* myInterp;           
00081 
00082   QString           myCommandBuffer;    
00083   QString           myCurrentCommand;   
00084   QString           myPrompt;           
00085   int               myCmdInHistory;     
00086   QStringList       myHistory;          
00087   QEventLoop*       myEventLoop;        
00088   QString           myBanner;           
00089   bool              myShowBanner;       
00090   QStringList       myQueue;            
00091   bool              myIsSync;           
00092   bool              myIsSuppressOutput; 
00093 };
00094 
00095 #endif // PYCONSOLE_EDITOR_H