1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Adrien Bruneton (CEA/DEN)
20 // Created on: 4 avr. 2013
22 #ifndef PYCONSOLE_ENHEDITOR_H_
23 #define PYCONSOLE_ENHEDITOR_H_
25 #include "PyConsole.h"
26 #include "PyConsole_Editor.h"
32 * Enhanced Python editor handling tab completion.
34 class PYCONSOLE_EXPORT PyConsole_EnhEditor: public PyConsole_Editor
39 PyConsole_EnhEditor(PyConsole_Interp* interp, QWidget* parent = 0);
40 virtual ~PyConsole_EnhEditor() {}
44 * Signal emitted by the editor widget when the doc string should be updated.
45 * @param doc a HTML block with the formatted doc string.
46 * TODO: for now this signal is left uncaught.
48 void updateDoc(QString doc);
51 /** List of separators identifying the last parsable token for completion */
52 static const std::vector<QString> SEPARATORS;
54 /** Maximum number of completions shown at once */
55 static const int MAX_COMPLETIONS = 70;
57 /** Are we in completion mode */
60 /** String on which the dir() comamnd is executed */
61 QString _compl_before_point;
62 /** String on which the results of the dir() are matched */
63 QString _compl_after_point;
65 /** Cursor position when <TAB> is hit */
68 /** Are we currently pasting several lines */
69 bool _multi_line_paste;
71 /** Queue of lines being pasted */
72 std::queue<QString> _multi_line_content;
75 virtual void keyPressEvent ( QKeyEvent* event);
76 virtual void customEvent( QEvent* event);
77 virtual void mousePressEvent( QMouseEvent* event );
78 virtual void insertFromMimeData(const QMimeData * source);
80 virtual PyInterp_Request* createTabRequest( const QString& input );
81 virtual void handleTab();
82 virtual void handleBackTab();
83 virtual void clearCompletion();
84 virtual void formatCompletion(const QStringList& matches, QString& result) const;
85 virtual QString formatDocHTML(const QString & doc) const;
87 virtual void multilinePaste(const QString & s);
88 virtual void multiLineProcessNextLine();
91 void extractCommon(const QStringList& matches, QString& result) const;
95 #endif /* PYCONSOLE_ENHEDITOR_H_ */