OSDN Git Service

184afbdddcfb61e03bb8caacd40b21115e88e45c
[csp-qt/common_source_project-fm7.git] / source / src / qt / debugger / qt_debugger.cpp
1 /*
2         Skelton for retropc emulator
3
4         Author : K.Ohta <whatisthis.sowhat _at_ gmail.com>
5         Date   : 2015.04.09 -
6         History: 09 Apr, 2015 : Initial from Takeda.Toshiya's w32_debugger.cpp.
7         [ debugger console ]
8 */
9
10 #include <stdio.h>
11 #include <string.h>
12
13 //#include <unistd.h>
14 #include <fcntl.h>
15 #include <QObject>
16 #include <QMetaObject>
17
18 //#include "res/resource.h"
19 #include "../../emu.h"
20 #include "../../vm/device.h"
21 #include "../../vm/debugger.h"
22 #include "../../vm/vm.h"
23 #include "../../fileio.h"
24 #include "qt_debugger.h"
25 #include "osd.h"
26
27
28 #ifdef USE_DEBUGGER
29
30 void CSP_Debugger::put_string(QString s)
31 {
32         text->insertPlainText(s);
33         text->moveCursor(QTextCursor::End);
34 }
35
36 void CSP_Debugger::cmd_clear()
37 {
38         text_command->clear();
39         text->moveCursor(QTextCursor::End);
40 }
41
42 void CSP_Debugger::doExit(void)
43 {
44         //p_emu->close_debugger();
45         emit sig_finished();
46 }
47
48 void CSP_Debugger::stop_polling()
49 {
50         //poll_stop = true;
51 }
52
53 void CSP_Debugger::call_debugger(void)
54 {
55         emit sig_call_debugger(text_command->text());
56 }
57
58 void CSP_Debugger::run(void)
59 {
60         connect(text_command, SIGNAL(editingFinished()), this, SLOT(call_debugger()));
61         connect(this, SIGNAL(sig_call_debugger(QString)), p_osd, SLOT(do_write_inputdata(QString)), Qt::DirectConnection);
62         
63         connect(p_osd, SIGNAL(sig_debugger_finished()), this, SLOT(doExit()));
64         connect(this, SIGNAL(sig_finished()), p_osd, SLOT(do_close_debugger_thread()));
65         connect(this, SIGNAL(destroyed()), this, SLOT(doExit()));
66         connect(parent_object, SIGNAL(quit_debugger_thread()), this, SLOT(close()));
67         connect(this, SIGNAL(sig_finished()), this, SLOT(close()));
68         
69         //emit sig_start_debugger();
70 }
71
72 void CSP_Debugger::closeEvent(QCloseEvent *event)
73 {
74         doExit();
75 }
76
77 CSP_Debugger::CSP_Debugger(QWidget *parent, OSD *osd) : QWidget(parent, Qt::Window)
78 {
79         widget = this;
80         p_osd = osd;
81         
82         parent_object = parent;
83         text = new QTextEdit(this);
84         text->setReadOnly(true);
85         text->setLineWrapMode(QTextEdit::WidgetWidth);
86         //text->setCenterOnScroll(true);
87
88         text_command = new QLineEdit(this);
89         text_command->setEchoMode(QLineEdit::Normal);
90         text_command->setMaxLength(1024);
91         text_command->setReadOnly(false);
92         text_command->setEnabled(true);
93         text_command->clear();
94         
95         VBoxWindow = new QVBoxLayout;
96
97         VBoxWindow->addWidget(text);
98         VBoxWindow->addWidget(text_command);
99         this->setLayout(VBoxWindow);
100         this->resize(640, 500);
101 }
102
103
104 CSP_Debugger::~CSP_Debugger()
105 {
106         
107 }
108    
109
110
111 #endif
112