mirror of
https://github.com/rizinorg/cutter.git
synced 2024-11-26 22:31:08 +00:00
Temporary fix for command output to console widget.
* partially revert #3193 - printing the terminal escape sequences directly to text widget causes more issues than the tab problem it tried to fix * move the conversation to html from command task to the console widget * add hack converting tab to multiple spaces
This commit is contained in:
parent
fe85af2560
commit
7256fbb00e
@ -2,8 +2,7 @@
|
||||
#include "CommandTask.h"
|
||||
#include "TempConfig.h"
|
||||
|
||||
CommandTask::CommandTask(const QString &cmd, ColorMode colorMode, bool outFormatHtml)
|
||||
: cmd(cmd), colorMode(colorMode), outFormatHtml(outFormatHtml)
|
||||
CommandTask::CommandTask(const QString &cmd, ColorMode colorMode) : cmd(cmd), colorMode(colorMode)
|
||||
{
|
||||
}
|
||||
|
||||
@ -12,8 +11,5 @@ void CommandTask::runTask()
|
||||
TempConfig tempConfig;
|
||||
tempConfig.set("scr.color", colorMode);
|
||||
auto res = Core()->cmdTask(cmd);
|
||||
if (outFormatHtml) {
|
||||
res = CutterCore::ansiEscapeToHtml(res);
|
||||
}
|
||||
emit finished(res);
|
||||
}
|
||||
|
@ -17,8 +17,7 @@ public:
|
||||
MODE_16M = COLOR_MODE_16M
|
||||
};
|
||||
|
||||
CommandTask(const QString &cmd, ColorMode colorMode = ColorMode::DISABLED,
|
||||
bool outFormatHtml = false);
|
||||
CommandTask(const QString &cmd, ColorMode colorMode = ColorMode::DISABLED);
|
||||
|
||||
QString getTitle() override { return tr("Running Command"); }
|
||||
|
||||
@ -31,7 +30,6 @@ protected:
|
||||
private:
|
||||
QString cmd;
|
||||
ColorMode colorMode;
|
||||
bool outFormatHtml;
|
||||
};
|
||||
|
||||
#endif // COMMANDTASK_H
|
||||
|
@ -4451,11 +4451,13 @@ bool CutterCore::setColor(const QString &key, const QString &color)
|
||||
QString CutterCore::ansiEscapeToHtml(const QString &text)
|
||||
{
|
||||
int len;
|
||||
char *html = rz_cons_html_filter(text.toUtf8().constData(), &len);
|
||||
QString r = text;
|
||||
r.replace("\t", " ");
|
||||
char *html = rz_cons_html_filter(r.toUtf8().constData(), &len);
|
||||
if (!html) {
|
||||
return {};
|
||||
}
|
||||
QString r = QString::fromUtf8(html, len);
|
||||
r = QString::fromUtf8(html, len);
|
||||
rz_mem_free(html);
|
||||
return r;
|
||||
}
|
||||
|
@ -228,11 +228,11 @@ void ConsoleWidget::executeCommand(const QString &command)
|
||||
addOutput(cmd_line);
|
||||
|
||||
RVA oldOffset = Core()->getOffset();
|
||||
commandTask = QSharedPointer<CommandTask>(
|
||||
new CommandTask(command, CommandTask::ColorMode::MODE_256, false));
|
||||
commandTask =
|
||||
QSharedPointer<CommandTask>(new CommandTask(command, CommandTask::ColorMode::MODE_16M));
|
||||
connect(commandTask.data(), &CommandTask::finished, this,
|
||||
[this, cmd_line, command, oldOffset](const QString &result) {
|
||||
ui->outputTextEdit->appendPlainText(result);
|
||||
ui->outputTextEdit->appendHtml(CutterCore::ansiEscapeToHtml(result));
|
||||
scrollOutputToEnd();
|
||||
historyAdd(command);
|
||||
commandTask.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user