From 1a3df76068e8da58bd0892827422f52e339cbd51 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 9 Dec 2021 09:27:46 +0800 Subject: [PATCH] work save --- NEWS.md | 3 +++ RedPandaIDE/mainwindow.cpp | 30 +++++++++++++++++++----------- RedPandaIDE/utils.cpp | 25 +++++++++++++++++++++++++ RedPandaIDE/utils.h | 3 +++ tools/ConsolePauser/main.cpp | 2 +- 5 files changed, 51 insertions(+), 12 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6d0e10db..57a89647 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,9 @@ Version 0.11.0 For Dev-C++ 7 Beta - enhancement: use token list instead of single string to do code completion ( intial version) - fix: language options in the project wizard don't work - fix: "ake as default language" option in the project wizard doesn't work + - fix: typo errors in settings dialog + - enhancement: console pauser clears STDIN buffer before show "press any key to continue..." + - fix: path in macros should use system's path separator Version 0.10.4 For Dev-C++ 7 Beta - fix: can't correctly undo/redo indent diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index f7f4c372..6c8ece9f 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1803,18 +1803,26 @@ void MainWindow::updateTools() QAction* action = new QAction(item->title,ui->menuTools); connect(action, &QAction::triggered, [item] (){ - if (item->pauseAfterExit - && programHasConsole(parseMacros(item->program))) { - executeFile( - includeTrailingPathDelimiter(pSettings->dirs().app())+"ConsolePauser.exe", - " 0 \""+parseMacros(item->program)+"\" "+parseMacros(item->parameters), - parseMacros(item->workingDirectory)); + QString program = parseMacros(item->program); + QString workDir = parseMacros(item->workingDirectory); + if (program == "del") { + QString current = QDir::currentPath(); + QDir::setCurrent(workDir); + qDebug()<<(program+" "+parseMacros(item->parameters)); + system((program+" "+parseMacros(item->parameters)).toLocal8Bit()); + QDir::setCurrent(current); } else { - executeFile( - parseMacros(item->program), - parseMacros(item->parameters), - parseMacros(item->workingDirectory)); - + if (item->pauseAfterExit) { + executeFile( + includeTrailingPathDelimiter(pSettings->dirs().app())+"ConsolePauser.exe", + " 0 \""+localizePath(program)+"\" "+parseMacros(item->parameters), + workDir); + } else { + executeFile( + program, + parseMacros(item->parameters), + workDir); + } } }); ui->menuTools->addAction(action); diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index 6e4ec89d..79df5d8e 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -22,6 +22,7 @@ #include "editor.h" #include "project.h" #include "version.h" +#include "compiler/executablerunner.h" const QByteArray GuessTextEncoding(const QByteArray& text){ bool allAscii; @@ -826,6 +827,30 @@ QString parseMacros(const QString &s) return result; } +void executeFile(const QString &fileName, const QString ¶ms, const QString &workingDir) +{ + qDebug()<connect(runner, &QThread::finished, + [runner](){ + qDebug()<<"finished"; + runner->deleteLater(); + }); + runner->connect(runner, &Runner::runErrorOccurred, + [](const QString& s){ + qDebug()<<"error occured"; + qDebug()<setStartConsole(true); + runner->start(); +} + void stringToFile(const QString &str, const QString &fileName) { QFile file(fileName); diff --git a/RedPandaIDE/utils.h b/RedPandaIDE/utils.h index 7eb0d070..bff61f39 100644 --- a/RedPandaIDE/utils.h +++ b/RedPandaIDE/utils.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "SimpleIni.h" using SimpleIni = CSimpleIniA; @@ -121,6 +122,8 @@ QByteArray runAndGetOutput(const QString& cmd, const QString& workingDir, const const QByteArray& inputContent = QByteArray(), bool inheritEnvironment = false); +void executeFile(const QString& fileName, const QString& params, const QString& workingDir); + bool isNonPrintableAsciiChar(char ch); bool fileExists(const QString& file); diff --git a/tools/ConsolePauser/main.cpp b/tools/ConsolePauser/main.cpp index a1d1e536..b554b53d 100644 --- a/tools/ConsolePauser/main.cpp +++ b/tools/ConsolePauser/main.cpp @@ -87,7 +87,7 @@ string GetCommand(int argc,char** argv,bool &reInp,bool &pauseAfterExit) { // result += string(argv[i]); // } */ - // Quote the first argument in case the path name contains spaces + // Quote the argument in case the path name contains spaces result += string("\"") + string(argv[i]) + string("\""); // Add a space except for the last argument