-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
135 lines (112 loc) · 2.26 KB
/
Copy pathmainwindow.cpp
File metadata and controls
135 lines (112 loc) · 2.26 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QStringList>
#include <QDebug>
MainWindow::
MainWindow (QWidget *parent)
: QMainWindow (parent)
, ui {new Ui::MainWindow}
, compiler{ new HCompiler() }
, stdTerm{ new UTerm(this) }
{
ui->setupUi (this);
connect(compiler
, qOverload<QString>
(&HCompiler::compiled)
, this, &MainWindow::srcCompiled);
connect(stdTerm
, &UTerm::sigFinishedExec
, this, &MainWindow::stdTermFinished);
connect(stdTerm
, &UTerm::sigOutputAvailable
, this, &MainWindow::stdOutputAvailable);
connect(compiler
, qOverload<QString>
(&HCompiler::linked)
, this, &MainWindow::finishedLinking);
}
MainWindow::
~MainWindow () { delete ui; }
void MainWindow::
on_openButton_pressed()
{
compiler->readSrc();
ui->srcEdit->setText(
compiler->getSrcString()
);
qDebug() << compiler->getSrcString();
}
void MainWindow::
on_cButton_pressed()
{
compiler->writeSrc( ui->srcEdit->toPlainText() );
compiler->compile();
}
void MainWindow::
srcCompiled(QString assembly)
{
ui->asmBrowser->setText(assembly);
}
void MainWindow::
on_pushButton_pressed()
{
compiler->writeSrc( ui->srcEdit->toPlainText() );
}
void MainWindow::on_runButton_pressed()
{
compiler->terminate();
ui->stdIn->clear();
stdTerm->clearStdOut();
compiler->link();
}
void MainWindow::
fillStdOutBrowser()
{
QString out{ stdTerm->getStdOut() };
qDebug() << out;
ui->stdOut->setText(out);
}
void MainWindow::
finishedLinking(QString execPath)
{
currentTask = fillStdOut;
QStringList ARGS{ ui->stdIn->text()
.split(' ') };
ui->stdIn->clear();
ui->stdOut->clear();
stdTerm->exec(execPath, ARGS);
}
void MainWindow::
stdTermFinished()
{
switch(currentTask)
{
case(fillStdOut):
{
fillStdOutBrowser();
break;
}
case(clearStdOut):
{
ui->stdOut->clear();
break;
}
}
}
void MainWindow::
stdOutputAvailable()
{
QString out{ stdTerm->getStdOut() };
ui->stdOut->append( out );
}
void MainWindow::on_stdIn_returnPressed()
{
QString in{ ui->stdIn->text() };
stdTerm->write( in );
ui->stdIn->clear();
}
void MainWindow::on_tButton_pressed()
{
stdTerm->terminate();
ui->stdOut->append("\nProcess Terminated\n");
}