mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-20 13:46:06 +00:00
Enable colors for ConsoleWidget (#823)
This commit is contained in:
parent
e16cd22082
commit
3347104cf1
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QShortcut>
|
||||
#include <QStringListModel>
|
||||
#include <QTimer>
|
||||
#include <iostream>
|
||||
#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<CommandTask>(new CommandTask(command));
|
||||
QString cmd_line = "<br>[" + RAddressString(Core()->getOffset()) + "]> " + command + "<br>";
|
||||
commandTask = QSharedPointer<CommandTask>(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;
|
||||
|
Loading…
Reference in New Issue
Block a user