ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
PythonRepl.h
Go to the documentation of this file.
1
// ----------------------------------------------------------------------------
2
// - CloudViewer: www.cloudViewer.org -
3
// ----------------------------------------------------------------------------
4
// Copyright (c) 2018-2024 www.cloudViewer.org
5
// SPDX-License-Identifier: MIT
6
// ----------------------------------------------------------------------------
7
8
#pragma once
9
10
#include <QMainWindow>
11
12
#include <string>
13
14
#include "
PythonInterpreter.h
"
15
16
class
PythonInterpreter
;
17
class
Ui_PythonREPL;
18
class
QPlainTextEdit;
19
20
class
PythonRepl
;
21
23
class
History
final
24
{
25
public
:
26
explicit
History
() =
default
;
27
28
void
add
(QString &&cmd);
29
30
size_t
size
()
const
;
31
32
bool
empty
()
const
;
33
34
const
QString &
older
();
35
36
const
QString &
newer
();
37
38
private
:
39
QVector<QString> m_commands;
40
QVector<QString>::const_reverse_iterator m_current;
41
};
42
44
class
KeyPressEater
final :
public
QObject
45
{
46
Q_OBJECT
47
public
:
48
explicit
KeyPressEater
(
PythonRepl
*repl, QObject *parent =
nullptr
);
49
50
protected
:
51
bool
eventFilter
(QObject *obj, QEvent *
event
)
override
;
52
53
private
:
54
PythonRepl
*m_repl{
nullptr
};
55
};
56
58
class
PythonRepl
final :
public
QMainWindow
59
{
60
friend
KeyPressEater
;
61
Q_OBJECT
62
63
public
:
64
explicit
PythonRepl
(
PythonInterpreter
*interpreter, QMainWindow *parent =
nullptr
);
65
66
void
executeCode
(
const
QString &pythonCode);
67
68
PythonRepl
(
const
PythonRepl
&) =
delete
;
69
PythonRepl
(
PythonRepl
&&) =
delete
;
70
PythonRepl
&
operator=
(
const
PythonRepl
&) =
delete
;
71
PythonRepl
&
operator=
(
PythonRepl
&&) =
delete
;
72
~PythonRepl
() noexcept override;
73
74
protected:
75
QPlainTextEdit *
codeEdit
();
76
QListWidget *
outputDisplay
();
77
78
void
reset
();
79
void
importNeededPackages
();
80
void
setupUI
();
81
82
private:
83
History
m_history{};
84
std::string m_buf;
85
Ui_PythonREPL *m_ui{
nullptr
};
86
PythonInterpreter
*m_interpreter{
nullptr
};
87
PythonInterpreter::State
m_state;
88
};
event
MouseEvent event
Definition:
BitmapWindowSystem.cpp:61
PythonInterpreter.h
History
Simple history system for the REPL.
Definition:
PythonRepl.h:24
History::empty
bool empty() const
Definition:
PythonRepl.cpp:263
History::newer
const QString & newer()
Definition:
PythonRepl.cpp:244
History::older
const QString & older()
Definition:
PythonRepl.cpp:233
History::size
size_t size() const
Definition:
PythonRepl.cpp:268
History::History
History()=default
History::add
void add(QString &&cmd)
Definition:
PythonRepl.cpp:227
KeyPressEater
Class used by the REPL to handle key presses.
Definition:
PythonRepl.h:45
KeyPressEater::KeyPressEater
KeyPressEater(PythonRepl *repl, QObject *parent=nullptr)
Definition:
PythonRepl.cpp:135
KeyPressEater::eventFilter
bool eventFilter(QObject *obj, QEvent *event) override
Definition:
PythonRepl.cpp:33
PythonInterpreter
Definition:
PythonInterpreter.h:33
PythonRepl
Homemade REPL (Read Print Eval Loop)
Definition:
PythonRepl.h:59
PythonRepl::operator=
PythonRepl & operator=(PythonRepl &&)=delete
PythonRepl::operator=
PythonRepl & operator=(const PythonRepl &)=delete
PythonRepl::PythonRepl
PythonRepl(PythonInterpreter *interpreter, QMainWindow *parent=nullptr)
Definition:
PythonRepl.cpp:137
PythonRepl::importNeededPackages
void importNeededPackages()
Definition:
PythonRepl.cpp:190
PythonRepl::PythonRepl
PythonRepl(PythonRepl &&)=delete
PythonRepl::outputDisplay
QListWidget * outputDisplay()
Definition:
PythonRepl.cpp:156
PythonRepl::setupUI
void setupUI()
Definition:
PythonRepl.cpp:161
PythonRepl::codeEdit
QPlainTextEdit * codeEdit()
Definition:
PythonRepl.cpp:151
PythonRepl::PythonRepl
PythonRepl(const PythonRepl &)=delete
PythonRepl::reset
void reset()
Definition:
PythonRepl.cpp:183
PythonRepl::~PythonRepl
~PythonRepl() noexcept override
Definition:
PythonRepl.cpp:146
PythonRepl::executeCode
void executeCode(const QString &pythonCode)
Definition:
PythonRepl.cpp:197
PythonInterpreter::State
Variable state.
Definition:
PythonInterpreter.h:39
plugins
core
Standard
qPythonRuntime
src
PythonRepl.h
Generated on Wed Jan 28 2026 09:01:08 for ACloudViewer by
1.9.1