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