Salome HOME
8c17a5bc7810e7efb9545d837afc0b9ebe760b7a
[modules/shaper.git] / src / PyConsole / PyConsole_Editor.h
1
2 #ifndef PYCONSOLE_EDITOR_H
3 #define PYCONSOLE_EDITOR_H
4
5 #include "PyConsole.h"
6
7 #include <QTextEdit>
8
9 class PyConsole_Interp;
10 class PyInterp_Request;
11 class QEventLoop;
12
13 //PYCONSOLE_EXPORT
14 class PyConsole_Editor : public QTextEdit
15 {
16   Q_OBJECT;
17
18 public:
19   PyConsole_Editor( PyConsole_Interp* theInterp, QWidget *theParent = 0 );
20   ~PyConsole_Editor();
21   
22   virtual void   addText( const QString& str, const bool newBlock = false, const bool isError = false );
23   bool           isCommand( const QString& str ) const;
24
25   virtual void   exec( const QString& command );
26   void           execAndWait( const QString& command );
27
28   bool           isSync() const;
29   void           setIsSync( const bool );
30
31   bool           isSuppressOutput() const;
32   void           setIsSuppressOutput(const bool);
33
34   bool           isShowBanner() const;
35   void           setIsShowBanner( const bool );
36
37   virtual QSize  sizeHint() const;
38
39 public slots:
40     void           cut();
41     void           paste();
42     void           clear();
43     void           handleReturn();
44     void           onPyInterpChanged( PyConsole_Interp* );
45     //.void           dump();
46
47 protected:
48   virtual void   dropEvent( QDropEvent* event );
49   virtual void   mouseReleaseEvent( QMouseEvent* event );
50   virtual void   keyPressEvent ( QKeyEvent* event);
51   virtual void   customEvent( QEvent* event);
52
53   virtual PyInterp_Request* createRequest( const QString& );
54
55   /** Convenience function */
56   inline int promptSize() const { return myPrompt.size(); }
57
58   PyConsole_Interp* myInterp;           //!< python interpreter
59
60   QString           myCommandBuffer;    //!< python command buffer
61   QString           myCurrentCommand;   //!< currently being printed command
62   QString           myPrompt;           //!< current command line prompt
63   int               myCmdInHistory;     //!< current history command index
64   QStringList       myHistory;          //!< commands history buffer
65   QEventLoop*       myEventLoop;        //!< internal event loop
66   QString           myBanner;           //!< current banner
67   bool              myShowBanner;       //!< 'show banner' flag
68   QStringList       myQueue;            //!< python commands queue
69   bool              myIsSync;           //!< synchronous mode flag
70   bool              myIsSuppressOutput; //!< suppress output flag
71 };
72
73 #endif // PYCONSOLE_EDITOR_H