From 6c09f661b83dd13a8403243c1441efa5c4900538 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Thu, 22 Aug 2019 13:47:41 +0200 Subject: 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 --- qtmips_gui/mainwindow.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'qtmips_gui/mainwindow.cpp') 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))); -- cgit v1.2.3