]> SALOME platform Git repositories - modules/gui.git/blob - src/PyConsole/PyConsole_EnhInterp.h
Salome HOME
Merge branch 'master' into V7_5_BR
[modules/gui.git] / src / PyConsole / PyConsole_EnhInterp.h
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Adrien Bruneton (CEA/DEN)
20 // Created on: 4 avr. 2013
21
22
23 #ifndef PYCONSOLE_ENHINTERP_H_
24 #define PYCONSOLE_ENHINTERP_H_
25
26 #include "PyConsole.h"
27
28 #include <Python.h>
29 #include "PyConsole_Interp.h"
30
31 #include <vector>
32 #include <QString>
33
34 /**
35  * Enhanced Python interpreter used for auto-completion.
36  * This extends PyConsole_Interp with an API wrapping the Python dir() command nicely.
37  */
38 class PYCONSOLE_EXPORT PyConsole_EnhInterp: public PyConsole_Interp
39 {
40 public:
41   PyConsole_EnhInterp();
42   virtual ~PyConsole_EnhInterp();
43
44   virtual QStringList getLastMatches() const;
45   virtual QString getDocStr() const;
46
47   virtual int runDirCommand(const QString& dirArgument, const QString& startMatch);
48   virtual void clearCompletion();
49
50 protected:
51   /** Hard coded list of Python keywords */
52   static const std::vector<QString> PYTHON_KEYWORDS;
53
54   /** Last computed matches */
55   QStringList _last_matches;
56   /** Doc string of the first match - when only one match it will be displayed by the Editor*/
57   QString _doc_str;
58
59   virtual int runDirAndExtract(const QString& dirArgument, const QString& startMatch,
60                                QStringList& result, bool discardSwig=true) const;
61 };
62
63 #endif /* PYCONSOLE_ENHINTERP_H_ */