aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/mainwindow.cpp
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-08-22 13:47:41 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-08-22 13:47:41 +0200
commit6c09f661b83dd13a8403243c1441efa5c4900538 (patch)
treefe32eed92f284d08455461c02c158226d760ac4c /qtmips_gui/mainwindow.cpp
parenta385be02219abc1fd751908e559286dc1a370e12 (diff)
downloadqtmips-6c09f661b83dd13a8403243c1441efa5c4900538.tar.gz
qtmips-6c09f661b83dd13a8403243c1441efa5c4900538.tar.bz2
qtmips-6c09f661b83dd13a8403243c1441efa5c4900538.zip
In include, use content from editor if file is already open.
This allows to assemble from modified include files without need to save their content the first. Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui/mainwindow.cpp')
-rw-r--r--qtmips_gui/mainwindow.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index cbee3e5..09fe660 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -858,6 +858,19 @@ void MainWindow::message_selected(messagetype::Type type, QString file, int line
central_window->setCurrentWidget(editor);
}
+bool SimpleAsmWithEditorCheck::process_file(QString filename, QString *error_ptr) {
+ SrcEditor *editor = mainwindow->source_editor_for_file(filename, false);
+ if (editor == nullptr)
+ return Super::process_file(filename, error_ptr);
+ QTextDocument *doc = editor->document();
+ int ln = 1;
+ for ( QTextBlock block = doc->begin(); block.isValid(); block = block.next(), ln++) {
+ QString line = block.text();
+ process_line(line, filename, ln);
+ }
+ return !error_occured;
+}
+
void MainWindow::compile_source() {
bool error_occured = false;
if (current_srceditor == nullptr)
@@ -883,7 +896,7 @@ void MainWindow::compile_source() {
QTextDocument *doc = editor->document();
emit clear_messages();
- SimpleAsm sasm;
+ SimpleAsmWithEditorCheck sasm(this);
connect(&sasm, SIGNAL(report_message(messagetype::Type,QString,int,int,QString,QString)),
this, SIGNAL(report_message(messagetype::Type,QString,int,int,QString,QString)));