From 4cb728d09d1250a31cf295024c389ec5d0ca1c8e Mon Sep 17 00:00:00 2001 From: RickyRister Date: Mon, 5 May 2025 00:01:18 -0700 Subject: [PATCH] Strip color escape codes in Debug Log window --- 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 */)