Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / PyConsole / PyConsole_EnhInterp.h
1
2
3 #ifndef PYCONSOLE_ENHINTERP_H_
4 #define PYCONSOLE_ENHINTERP_H_
5
6 #include "PyConsole.h"
7
8 #include <Python.h>
9 #include "PyConsole_Interp.h"
10
11 #include <vector>
12 #include <QString>
13
14 /**
15  * Enhanced Python interpreter used for auto-completion.
16  * This extends PyConsole_Interp with an API wrapping the Python dir() command nicely.
17  */
18 //PYCONSOLE_EXPORT
19 class PyConsole_EnhInterp: public PyConsole_Interp
20 {
21 public:
22   PyConsole_EnhInterp()
23     : PyConsole_Interp(), _last_matches(0), _doc_str("")
24     {}
25
26   virtual ~PyConsole_EnhInterp() {}
27
28   const std::vector<QString>& getLastMatches() const { return _last_matches; }
29   const QString & getDocStr() const                  { return _doc_str; }
30
31   virtual int runDirCommand(const QString& dirArgument, const QString& startMatch);
32   virtual void clearCompletion();
33
34 protected:
35   /** Hard coded list of Python keywords */
36   static const std::vector<QString> PYTHON_KEYWORDS;
37
38   /** Last computed matches */
39   std::vector<QString> _last_matches;
40   /** Doc string of the first match - when only one match it will be displayed by the Editor*/
41   QString _doc_str;
42
43   virtual int runDirAndExtract(const QString& dirArgument, const QString & startMatch,
44       std::vector<QString> & result, bool discardSwig=true) const;
45
46 };
47
48 #endif /* PYCONSOLE_ENHINTERP_H_ */