aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/mainwindow.cpp2
-rw-r--r--qtmips_gui/terminaldock.cpp17
-rw-r--r--qtmips_gui/terminaldock.h4
3 files changed, 23 insertions, 0 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 253ab03..01321cf 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -154,6 +154,8 @@ void MainWindow::create_core(const machine::MachineConfig &config) {
osemu::OsSyscallExceptionHandler *osemu_handler = new osemu::OsSyscallExceptionHandler;
machine->register_exception_handler(machine::EXCAUSE_SYSCALL, osemu_handler);
connect(osemu_handler, SIGNAL(char_written(int,uint)), terminal, SLOT(tx_byte(int,uint)));
+ connect(osemu_handler, SIGNAL(rx_byte_pool(int,uint&,bool&)),
+ terminal, SLOT(rx_byte_pool(int,uint&,bool&)));
#endif
// Connect machine signals and slots
diff --git a/qtmips_gui/terminaldock.cpp b/qtmips_gui/terminaldock.cpp
index 4b394a6..bb26952 100644
--- a/qtmips_gui/terminaldock.cpp
+++ b/qtmips_gui/terminaldock.cpp
@@ -49,6 +49,11 @@ TerminalDock::TerminalDock(QWidget *parent, QSettings *settings) : QDockWidget(p
terminal_text->setMinimumSize(30, 30);
layout_box->addWidget(terminal_text);
append_cursor = new QTextCursor(terminal_text->document());
+ layout_bottom_box = new QHBoxLayout();
+ layout_bottom_box->addWidget(new QLabel("Input:"));
+ input_edit = new QLineEdit();
+ layout_bottom_box->addWidget(input_edit);
+ layout_box->addLayout(layout_bottom_box);
setObjectName("Terminal");
setWindowTitle("Terminal");
@@ -62,6 +67,8 @@ void TerminalDock::setup(const machine::SerialPort *ser_port) {
if (ser_port == nullptr)
return;
connect(ser_port, SIGNAL(tx_byte(uint)), this, SLOT(tx_byte(uint)));
+ connect(ser_port, SIGNAL(rx_byte_pool(int,uint&,bool&)),
+ this, SLOT(rx_byte_pool(int,uint&,bool&)));
}
void TerminalDock::tx_byte(unsigned int data) {
@@ -76,3 +83,13 @@ void TerminalDock::tx_byte(int fd, unsigned int data)
(void)fd;
tx_byte(data);
}
+
+void TerminalDock::rx_byte_pool(int fd, unsigned int &data, bool &available) {
+ QString str = input_edit->text();
+ available = false;
+ if (str.count() > 0) {
+ data = str[0].toLatin1();
+ input_edit->setText(str.remove(0, 1));
+ available = true;
+ }
+}
diff --git a/qtmips_gui/terminaldock.h b/qtmips_gui/terminaldock.h
index 7154e81..27dc617 100644
--- a/qtmips_gui/terminaldock.h
+++ b/qtmips_gui/terminaldock.h
@@ -39,6 +39,7 @@
#include <QDockWidget>
#include <QLabel>
#include <QFormLayout>
+#include <QLineEdit>
#include <QTextEdit>
#include <QTextCursor>
#include "qtmipsmachine.h"
@@ -54,13 +55,16 @@ public:
public slots:
void tx_byte(unsigned int data);
void tx_byte(int fd, unsigned int data);
+ void rx_byte_pool(int fd, unsigned int &data, bool &available);
private:
QVBoxLayout *layout_box;
+ QHBoxLayout *layout_bottom_box;
QWidget *top_widget, *top_form;
QFormLayout *layout_top_form;
QTextEdit *terminal_text;
QTextCursor *append_cursor;
+ QLineEdit *input_edit;
};
#endif // TERMINALDOCK_H