Skip to content

Commit 61efe3d

Browse files
Added accelerator for reinitialising regs; improved console window behaviour, made more strings translatable
1 parent fd8e526 commit 61efe3d

File tree

11 files changed

+760
-289
lines changed

11 files changed

+760
-289
lines changed

CPU/spim.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ char get_console_char ();
233233
void put_console_char (char c);
234234
void read_input (char *str, int n);
235235
void run_error (char *fmt, ...);
236-
void write_output (port, char *fmt, ...);
236+
void write_output (port, const char *fmt, ...);
237237

238238

239239
/* Exported variables: */

QtSpim/QtSpim.pro

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ SOURCES += main.cpp\
6565
../CPU/spim-utils.c\
6666
../CPU/string-stream.c\
6767
../CPU/sym-tbl.c\
68-
../CPU/syscall.c\
69-
spim_support.c
68+
../CPU/syscall.c \
69+
spim_support.c
7070

7171

7272
HEADERS += spimview.h\

QtSpim/QtSpim.pro.user

-259
This file was deleted.

QtSpim/console.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Console::Console(QWidget *parent)
3737
: QPlainTextEdit(parent)
3838
{
3939
setWindowTitle(tr("Console"));
40-
resize(800, 600);
40+
setWindowFlags(Qt::Tool);
41+
resize(400, 300);
4142

4243
setUndoRedoEnabled(false);
4344
appendPlainText(QString(""));

QtSpim/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
5858
message_out.i = 1;
5959
console_out.i = 2;
6060

61-
win.SpimConsole->show();
61+
//win.SpimConsole->show();
6262
win.show();
6363

6464
QStringList fileNames = parseCommandLine(a.arguments());

QtSpim/menu.cpp

+19-18
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ void SpimView::file_LoadFile()
7474
else
7575
{
7676
file = QFileDialog::getOpenFileName(this,
77-
"Open Assembly Code",
77+
tr("Open Assembly Code"),
7878
st_recentFiles[0],
79-
"Assembly (*.a *.s *.asm);;Text files (*.txt)");
79+
tr("Assembly (*.a *.s *.asm);;Text files (*.txt)"));
8080
}
8181
if (!file.isNull())
8282
{
@@ -125,9 +125,9 @@ void SpimView::file_SaveLogFile()
125125
slf->setupUi(saveLogFileDialog);
126126

127127
QFileDialog* fb = new QFileDialog(0,
128-
"Save To Log File",
128+
tr("Save To Log File"),
129129
"",
130-
"Text files (*.txt);; All (*)");
130+
tr("Text files (*.txt);; All (*)"));
131131
QObject::connect(slf->saveFileToolButton, SIGNAL(clicked()), fb, SLOT(exec()));
132132
QObject::connect(fb, SIGNAL(fileSelected(QString)), slf->SaveLineEdit, SLOT(setText(QString)));
133133
}
@@ -182,7 +182,7 @@ void SpimView::file_Print()
182182
{
183183
QPrinter printer;
184184
QPrintDialog printDialog(&printer, this);
185-
printDialog.setWindowTitle("Print Windows");
185+
printDialog.setWindowTitle(tr("Print Windows"));
186186

187187
if (printDialog.exec() == QDialog::Accepted)
188188
{
@@ -229,6 +229,7 @@ void SpimView::file_Exit()
229229
void SpimView::sim_ClearRegisters()
230230
{
231231
initialize_registers();
232+
PC = TEXT_BOT; // !
232233

233234
DisplayIntRegisters();
234235
DisplayFPRegisters();
@@ -237,15 +238,15 @@ void SpimView::sim_ClearRegisters()
237238

238239
void SpimView::sim_ReinitializeSimulator()
239240
{
240-
write_output(message_out, "<hr>Memory and registers cleared\n\n");
241+
write_output(message_out, tr("<hr>Memory and registers cleared\n\n").toStdString().c_str());
241242
InitializeWorld();
242243
SpimConsole->Clear();
243244
initStack();
244245

245246
SetOutputColor("green");
246247
write_startup_message();
247248
write_output(message_out,
248-
"QtSPIM is linked to the Qt library, which is distributed under the GNU Lesser General Public License version 3 and version 2.1.\n");
249+
tr("QtSPIM is linked to the Qt library, which is distributed under the GNU Lesser General Public License version 3 and version 2.1.\n").toStdString().c_str());
249250
SetOutputColor("black");
250251

251252
CaptureIntRegisters();
@@ -369,19 +370,19 @@ void SpimView::updateStatus(PROGSTATE status)
369370
break;
370371

371372
case STOPPED:
372-
Window->statusBar()->showMessage("Stopped");
373+
Window->statusBar()->showMessage(tr("Stopped"));
373374
break;
374375

375376
case PAUSED:
376-
Window->statusBar()->showMessage("Paused");
377+
Window->statusBar()->showMessage(tr("Paused"));
377378
break;
378379

379380
case RUNNING:
380-
Window->statusBar()->showMessage("Running");
381+
Window->statusBar()->showMessage(tr("Running"));
381382
break;
382383

383384
case SINGLESTEP:
384-
Window->statusBar()->showMessage("Single Step");
385+
Window->statusBar()->showMessage(tr("Single Step"));
385386
break;
386387

387388
default:
@@ -413,7 +414,7 @@ void SpimView::executeProgram(mem_addr pc, int steps, bool display, bool contBkp
413414
connect(bpd->singleStepPushButton, SIGNAL(clicked()), this, SLOT(singleStepBreakpoint()));
414415
connect(bpd->abortPushButton, SIGNAL(clicked()), this, SLOT(abortBreakpoint()));
415416
}
416-
bpd->label->setText("Execution stopped at breakpoint at " + QString("0x") + formatAddress(PC));
417+
bpd->label->setText(tr("Execution stopped at breakpoint at ") + QString("0x") + formatAddress(PC));
417418
breakpointDialog->show();
418419
}
419420
else if (!continuable)
@@ -480,9 +481,9 @@ void SpimView::sim_Settings()
480481
sd.loadExceptionHandlerCheckBox->setChecked(st_loadExceptionHandler);
481482
sd.exceptionHandlerLineEdit->setText(st_exceptionHandlerFileName);
482483
QFileDialog exceptionFileDialog(0,
483-
"Open Exception File",
484+
tr("Open Exception File"),
484485
st_exceptionHandlerFileName,
485-
"Assembly (*.a *.s *.asm);;Text files (*.txt)");
486+
tr("Assembly (*.a *.s *.asm);;Text files (*.txt)"));
486487
QObject::connect(sd.exceptionHandlerToolButton, SIGNAL(clicked()), &exceptionFileDialog, SLOT(exec()));
487488
QObject::connect(&exceptionFileDialog, SIGNAL(fileSelected(QString)),
488489
sd.exceptionHandlerLineEdit, SLOT(setText(QString)));
@@ -851,20 +852,20 @@ void SpimView::help_AboutSPIM()
851852
{
852853
QMessageBox box(QMessageBox::NoIcon,
853854
tr("About QtSpim"),
854-
QString("<span style='font-size: 16pt;'>"
855+
QString(tr("<span style='font-size: 16pt;'>"
855856
"<center><strong>QtSpim</strong></center>"
856857
"<center><img src=':/icons/qtspim.png'>"
857-
"<span style='font-size: 10pt;'>")
858+
"<span style='font-size: 10pt;'>"))
858859
+ QString("<p>") + QString(SPIM_VERSION) + QString("</p>")
859-
+ QString ("<p>SPIM is a simulator of the MIPS R3000 processor.</p>"
860+
+ QString (tr("<p>SPIM is a simulator of the MIPS R3000 processor.</p>"
860861
"<p>Copyright (c) 1990-2015, James R. Larus ([email protected]).</p>"
861862
"<p>SPIM is distributed under a BSD license.</p>"
862863
"<p>For more information, source code, and binaries:</p>"
863864
"<p><a href='https://sourceforge.net/projects/spimsimulator/'>https://sourceforge.net/projects/spimsimulator/</a></p>"
864865
"<p>QtSPIM is linked to the Qt library, which is distributed under the GNU Lesser General Public License version 3 and GNU Lesser General Public License version 2.1.</p>"
865866
"<p><a href='http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html'>GNU Lesser General Public License, version 2.1</a></p>"
866867
"<p><a href='http://www.gnu.org/licenses/lgpl-3.0.html'>GNU Lesser General Public License, version 3</a></p>"
867-
"</span>"),
868+
"</span>")),
868869
QMessageBox::Ok);
869870
box.exec();
870871
}

QtSpim/spim_support.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ char get_console_char()
124124
void put_console_char(char c)
125125
{
126126
Window->SpimConsole->WriteOutput(QString(c));
127-
Window->SpimConsole->raise();
127+
if (!Window->SpimConsole->isVisible())
128+
write_output(message_out,QObject::tr("Writing to console. To view the console, go to Window > Console.").toStdString().c_str());
129+
//Window->SpimConsole->raise();
128130
}
129131

130132

@@ -151,7 +153,7 @@ void read_input(char *str, int str_size)
151153
}
152154

153155

154-
void write_output (port fp, char *fmt, ...)
156+
void write_output (port fp, const char *fmt, ...)
155157
{
156158
va_list args;
157159
va_start (args, fmt);
@@ -167,6 +169,8 @@ void write_output (port fp, char *fmt, ...)
167169
else if (fp.i == console_out.i)
168170
{
169171
Window->SpimConsole->WriteOutput(QString(buf));
170-
Window->SpimConsole->raise();
172+
if (!Window->SpimConsole->isVisible())
173+
write_output(message_out,QObject::tr("Writing to console. To view the console, go to Window > Console.").toStdString().c_str());
174+
//Window->SpimConsole->raise();
171175
}
172176
}

QtSpim/spimview.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ SpimView::SpimView(QWidget *parent) :
5151
// Open windows
5252
//
5353
ui->setupUi(this);
54-
SpimConsole = new Console(0);
54+
SpimConsole = new Console(this);
5555

5656
stdExceptionHandler = QString("<<SPIM Exception Handler>>");
5757

@@ -76,7 +76,7 @@ SpimView::SpimView(QWidget *parent) :
7676

7777
// Create a console
7878
//
79-
ui->action_Win_Console->setChecked(true);
79+
ui->action_Win_Console->setChecked(0);
8080

8181
programStatus = IDLE;
8282
}

QtSpim/spimview.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Q_OBJECT
141141
bool st_showUserStackSegment;
142142
bool st_showKernelDataSegment;
143143
int st_dataSegmentDisplayBase;
144-
int st_numberOfWordsPerLine;
144+
unsigned int st_numberOfWordsPerLine;
145145

146146
//
147147
// End of state

QtSpim/spimview.ui

+4-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@
278278
<normaloff>:/icons/ClearRegs.png</normaloff>:/icons/ClearRegs.png</iconset>
279279
</property>
280280
<property name="text">
281-
<string>&amp;Clear Registers</string>
281+
<string>&amp;Reinitialize Registers</string>
282+
</property>
283+
<property name="shortcut">
284+
<string>F7</string>
282285
</property>
283286
</action>
284287
<action name="action_Sim_Reinitialize">

0 commit comments

Comments
 (0)