]> SALOME platform Git repositories - modules/shaper.git/blob - src/PyConsole/PyConsole_EnhEditor.h
Salome HOME
Models for object browser created
[modules/shaper.git] / src / PyConsole / PyConsole_EnhEditor.h
1
2
3 #ifndef PYCONSOLE_ENHEDITOR_H_
4 #define PYCONSOLE_ENHEDITOR_H_
5
6 #include "PyConsole.h"
7
8 #include "PyConsole_Editor.h"
9 #include <QObject>
10 #include <queue>
11
12 class PyConsole_EnhInterp;
13
14 /**
15  * Enhanced Python editor handling tab completion.
16  */
17 //PYCONSOLE_EXPORT
18 class PyConsole_EnhEditor: public PyConsole_Editor
19 {
20   Q_OBJECT;
21
22 public:
23   PyConsole_EnhEditor(PyConsole_EnhInterp * interp, QWidget * parent=0);
24   virtual ~PyConsole_EnhEditor() {}
25
26 signals:
27   /**
28    * Signal emitted by the editor widget when the doc string should be updated.
29    * @param doc a HTML block with the formatted doc string.
30    * TODO: for now this signal is left uncaught.
31    */
32   void updateDoc(QString doc);
33
34 protected:
35   /** List of separators identifying the last parsable token for completion */
36   static const std::vector<QString> SEPARATORS;
37
38   /** Maximum number of completions shown at once */
39   static const int MAX_COMPLETIONS = 70;
40
41   /** Are we in completion mode */
42   bool _tab_mode;
43
44   /** String on which the dir() comamnd is executed */
45   QString _compl_before_point;
46   /** String on which the results of the dir() are matched */
47   QString _compl_after_point;
48
49   /** Cursor position when <TAB> is hit */
50   int _cursor_pos;
51
52   /** Are we currently pasting several lines */
53   bool _multi_line_paste;
54
55   /** Queue of lines being pasted */
56   std::queue<QString> _multi_line_content;
57
58   // Overrides:
59   virtual void   keyPressEvent ( QKeyEvent* event);
60   virtual void   customEvent( QEvent* event);
61   virtual void   mousePressEvent( QMouseEvent* event );
62   virtual void   insertFromMimeData(const QMimeData * source);
63
64   virtual PyInterp_Request* createTabRequest( const QString& input );
65   virtual void handleTab();
66   virtual void handleBackTab();
67   virtual void clearCompletion();
68   virtual void formatCompletion(const std::vector<QString> & matches, QString & result) const;
69   virtual QString formatDocHTML(const QString & doc) const;
70
71   virtual void multilinePaste(const QString & s);
72   virtual void multiLineProcessNextLine();
73
74 private:
75   void extractCommon(const std::vector<QString> & matches, QString & result) const;
76
77 };
78
79 #endif /* PYCONSOLE_ENHEDITOR_H_ */