summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/debugger/qt/windowqt.h
blob: 8085f9a63bf16cbb19ae3c4ac1b7805b4cf72cc5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#ifndef MAME_DEBUGGER_QT_WINDOWQT_H
#define MAME_DEBUGGER_QT_WINDOWQT_H

#include "../xmlconfig.h"

#include "debugger.h"

#include <QtWidgets/QMainWindow>

#include <deque>
#include <memory>


namespace osd::debugger::qt {

//============================================================
//  The Qt debugger module interface
//============================================================
class DebuggerQt : public QObject
{
	Q_OBJECT

public:
	virtual ~DebuggerQt() { }

	virtual running_machine &machine() const = 0;

	void hideAll() { emit hideAllWindows(); }

signals:
	void exitDebugger();
	void hideAllWindows();
	void showAllWindows();
	void saveConfiguration(util::xml::data_node &parentnode);
};


//============================================================
//  The Qt window that everyone derives from.
//============================================================
class WindowQt : public QMainWindow
{
	Q_OBJECT

public:
	virtual ~WindowQt();

	virtual void restoreConfiguration(util::xml::data_node const &node);

protected slots:
	void debugActOpenMemory();
	void debugActOpenDasm();
	void debugActOpenLog();
	void debugActOpenPoints();
	void debugActOpenDevices();
	void debugActRun();
	void debugActRunAndHide();
	void debugActRunToNextCpu();
	void debugActRunNextInt();
	void debugActRunNextVBlank();
	void debugActStepInto();
	void debugActStepOver();
	void debugActStepOut();
	void debugActSoftReset();
	void debugActHardReset();
	virtual void debugActClose();
	void debugActQuit();
	virtual void debuggerExit();

private slots:
	void saveConfiguration(util::xml::data_node &parentnode);

protected:
	WindowQt(DebuggerQt &debugger, QWidget *parent = nullptr);

	virtual void saveConfigurationToNode(util::xml::data_node &node);

	DebuggerQt &m_debugger;
	running_machine &m_machine;
};


//============================================================
//  Command history helper
//============================================================
class CommandHistory
{
public:
	CommandHistory();
	~CommandHistory();

	void add(QString const &entry);
	QString const *previous(QString const &current);
	QString const *next(QString const &current);
	void edit();
	void reset();
	void clear();

	void restoreConfigurationFromNode(util::xml::data_node const &node);
	void saveConfigurationToNode(util::xml::data_node &node);

private:
	static inline constexpr unsigned CAPACITY = 100U;

	std::deque<QString> m_history;
	std::unique_ptr<QString> m_current;
	int m_position;
};

} // namespace osd::debugger::qt

#endif // MAME_DEBUGGER_QT_WINDOWQT_H