Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/Application/vtkpost/ecmaconsole.h
3203 views
1
/*****************************************************************************
2
* *
3
* Elmer, A Finite Element Software for Multiphysical Problems *
4
* *
5
* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *
6
* *
7
* This program is free software; you can redistribute it and/or *
8
* modify it under the terms of the GNU General Public License *
9
* as published by the Free Software Foundation; either version 2 *
10
* of the License, or (at your option) any later version. *
11
* *
12
* This program is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU General Public License *
18
* along with this program (in file fem/GPL-2); if not, write to the *
19
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
20
* Boston, MA 02110-1301, USA. *
21
* *
22
*****************************************************************************/
23
24
/*****************************************************************************
25
* *
26
* ElmerGUI ecmaconsole *
27
* *
28
* Modified from the PythonQt console by Florian Link / MeVis Research *
29
* *
30
*****************************************************************************
31
* *
32
* Authors: Mikko Lyly, Juha Ruokolainen and Peter Råback *
33
* Email: [email protected] *
34
* Web: http://www.csc.fi/elmer *
35
* Address: CSC - IT Center for Science Ltd. *
36
* Keilaranta 14 *
37
* 02101 Espoo, Finland *
38
* *
39
* Original Date: 15 Mar 2008 *
40
* *
41
*****************************************************************************/
42
43
#ifndef ECMACONSOLE_H
44
#define ECMACONSOLE_H
45
46
#include <QTextEdit>
47
#include <QString>
48
#include <QStringList>
49
#include <QHash>
50
51
#if WITH_QT6
52
#include <QJSValue>
53
#endif
54
55
class QWidget;
56
class QKeyEvent;
57
class QMouseEvent;
58
class QMetaObject;
59
class QCompleter;
60
61
class EcmaConsole : public QTextEdit
62
{
63
Q_OBJECT
64
65
public:
66
EcmaConsole(QWidget* parent = 0);
67
~EcmaConsole();
68
void clearHistory();
69
void addNames(QString, const QMetaObject*);
70
void initCompleter();
71
72
#if WITH_QT6
73
template<class... A> QJSValue print(A... args);
74
#endif
75
76
public slots:
77
void keyPressEvent(QKeyEvent*);
78
void mousePressEvent(QMouseEvent*);
79
void mouseReleaseEvent(QMouseEvent*);
80
void mouseDoubleClickEvent(QMouseEvent*);
81
void insertCompletion(const QString&);
82
83
signals:
84
void cmd(QString);
85
86
private:
87
QString prompt;
88
int getPromptPos();
89
void execLine();
90
void scanHistory();
91
void handleTabCompletion();
92
int historyPtr;
93
QStringList history;
94
QHash<QString, QStringList> names;
95
QCompleter* completer;
96
};
97
98
#endif
99
100