diff --git a/src/common/CommandTask.cpp b/src/common/CommandTask.cpp index 579eb4da..2f19a2f0 100644 --- a/src/common/CommandTask.cpp +++ b/src/common/CommandTask.cpp @@ -1,13 +1,16 @@ #include "CommandTask.h" +#include "TempConfig.h" -CommandTask::CommandTask(const QString &cmd) - : cmd(cmd) +CommandTask::CommandTask(const QString &cmd, ColorMode colorMode, bool outFormatHtml) + : cmd(cmd), colorMode(colorMode), outFormatHtml(outFormatHtml) { } -void CommandTask::runTask() -{ +void CommandTask::runTask() { + TempConfig tempConfig; + tempConfig.set("scr.color", colorMode); + tempConfig.set("scr.html", outFormatHtml); auto res = Core()->cmdTask(cmd); emit finished(res); } diff --git a/src/common/CommandTask.h b/src/common/CommandTask.h index bc38a5bc..827dcc73 100644 --- a/src/common/CommandTask.h +++ b/src/common/CommandTask.h @@ -10,7 +10,9 @@ class CommandTask : public AsyncTask Q_OBJECT public: - CommandTask(const QString &cmd); + enum ColorMode {DISABLED=COLOR_MODE_DISABLED, MODE_16=COLOR_MODE_16, MODE_256=COLOR_MODE_256, MODE_16M=COLOR_MODE_16M}; + + CommandTask(const QString &cmd, ColorMode colorMode=ColorMode::DISABLED, bool outFormatHtml=false); QString getTitle() override { return tr("Running Command"); } @@ -22,6 +24,8 @@ protected: private: QString cmd; + ColorMode colorMode; + bool outFormatHtml; }; #endif //COMMANDTASK_H diff --git a/src/widgets/ConsoleWidget.cpp b/src/widgets/ConsoleWidget.cpp index 845df584..0fb9968b 100644 --- a/src/widgets/ConsoleWidget.cpp +++ b/src/widgets/ConsoleWidget.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "Cutter.h" #include "ConsoleWidget.h" #include "ui_ConsoleWidget.h" @@ -173,14 +174,15 @@ void ConsoleWidget::executeCommand(const QString &command) ui->outputTextEdit->appendPlainText("Executing the command..."); }); - QString cmd_line = "[" + RAddressString(Core()->getOffset()) + "]> " + command + "\n"; - commandTask = QSharedPointer(new CommandTask(command)); + QString cmd_line = "
[" + RAddressString(Core()->getOffset()) + "]> " + command + "
"; + commandTask = QSharedPointer(new CommandTask(command, CommandTask::ColorMode::MODE_256, true)); connect(commandTask.data(), &CommandTask::finished, this, [this, cmd_line, command, originalLines] (const QString & result) { + if (originalLines < ui->outputTextEdit->blockCount()) { removeLastLine(); } - ui->outputTextEdit->appendPlainText(cmd_line + result); + ui->outputTextEdit->appendHtml(cmd_line + result); scrollOutputToEnd(); historyAdd(command); commandTask = nullptr;