Salome HOME
Merge branch 'master' of newgeom:newgeom
[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 class PYCONSOLE_EXPORT PyConsole_EnhInterp: public PyConsole_Interp
19 {
20 public:
21   PyConsole_EnhInterp()
22     : PyConsole_Interp(), _last_matches(0), _doc_str("")
23     {}
24
25   virtual ~PyConsole_EnhInterp() {}
26
27   const std::vector<QString>& getLastMatches() const { return _last_matches; }
28   const QString & getDocStr() const                  { return _doc_str; }
29
30   virtual int runDirCommand(const QString& dirArgument, const QString& startMatch);
31   virtual void clearCompletion();
32
33 protected:
34   /** Hard coded list of Python keywords */
35   static const std::vector<QString> PYTHON_KEYWORDS;
36
37   /** Last computed matches */
38   std::vector<QString> _last_matches;
39   /** Doc string of the first match - when only one match it will be displayed by the Editor*/
40   QString _doc_str;
41
42   virtual int runDirAndExtract(const QString& dirArgument, const QString & startMatch,
43       std::vector<QString> & result, bool discardSwig=true) const;
44
45 };
46
47 #endif /* PYCONSOLE_ENHINTERP_H_ */