Strip color escape codes in Debug Log window (#5915)

This commit is contained in:
RickyRister 2025-05-05 06:38:46 -07:00 committed by GitHub
parent 69107f79e3
commit bd8306bd33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,7 @@
#include "../utility/logger.h"
#include <QPlainTextEdit>
#include <QRegularExpression>
#include <QVBoxLayout>
DlgViewLog::DlgViewLog(QWidget *parent) : QDialog(parent)
@ -44,7 +45,12 @@ void DlgViewLog::loadInitialLogBuffer()
void DlgViewLog::logEntryAdded(QString message)
{
logArea->appendPlainText(message);
static auto colorEscapeCodePattern = QRegularExpression("\033\\[\\d+m");
QString sanitizedMessage = message;
sanitizedMessage.replace(colorEscapeCodePattern, "");
logArea->appendPlainText(sanitizedMessage);
}
void DlgViewLog::closeEvent(QCloseEvent * /* event */)