From bd8306bd33d1b77844d47614c9daea7d3d1ec14a Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Mon, 5 May 2025 06:38:46 -0700 Subject: [PATCH] Strip color escape codes in Debug Log window (#5915) --- cockatrice/src/dialogs/dlg_view_log.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/dialogs/dlg_view_log.cpp b/cockatrice/src/dialogs/dlg_view_log.cpp index dc569c92c..7b4e8c617 100644 --- a/cockatrice/src/dialogs/dlg_view_log.cpp +++ b/cockatrice/src/dialogs/dlg_view_log.cpp @@ -4,6 +4,7 @@ #include "../utility/logger.h" #include +#include #include 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 */)