Salome HOME
Synchronize adm files
[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     : PyConsole_Interp(), _last_matches(0), _doc_str("")
43     {}
44
45   virtual ~PyConsole_EnhInterp() {}
46
47   const std::vector<QString>& getLastMatches() const { return _last_matches; }
48   const QString & getDocStr() const                  { return _doc_str; }
49
50   virtual int runDirCommand(const QString& dirArgument, const QString& startMatch);
51   virtual void clearCompletion();
52
53 protected:
54   /** Hard coded list of Python keywords */
55   static const std::vector<QString> PYTHON_KEYWORDS;
56
57   /** Last computed matches */
58   std::vector<QString> _last_matches;
59   /** Doc string of the first match - when only one match it will be displayed by the Editor*/
60   QString _doc_str;
61
62   virtual int runDirAndExtract(const QString& dirArgument, const QString & startMatch,
63       std::vector<QString> & result, bool discardSwig=true) const;
64
65 };
66
67 #endif /* PYCONSOLE_ENHINTERP_H_ */