From c80cdc25b3b93f5b4166991a882fb55735f2d351 Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Sat, 11 Jul 2020 14:57:30 +0200 Subject: [PATCH] Adds support for \x0f formatting character in IRC. (#1794) The \x0f character unsets the current foreground and background colors as well as other formatting which is currently not interpreted by Chatterino --- src/messages/MessageElement.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/messages/MessageElement.cpp b/src/messages/MessageElement.cpp index e13f9b25..c1b88769 100644 --- a/src/messages/MessageElement.cpp +++ b/src/messages/MessageElement.cpp @@ -15,7 +15,7 @@ namespace chatterino { namespace { QRegularExpression IRC_COLOR_PARSE_REGEX( - "\u0003(\\d{1,2})?(,(\\d{1,2}))?", + "(\u0003(\\d{1,2})?(,(\\d{1,2}))?|\u000f)", QRegularExpression::UseUnicodePropertiesOption); } // namespace @@ -475,18 +475,23 @@ IrcTextElement::IrcTextElement(const QString &fullText, segments.emplace_back(seg); lastPos = match.capturedStart() + match.capturedLength(); } - if (!match.captured(1).isEmpty()) { - fg = match.captured(1).toInt(nullptr); + fg = -1; + bg = -1; + } + + if (!match.captured(2).isEmpty()) + { + fg = match.captured(2).toInt(nullptr); } else { fg = -1; } - if (!match.captured(3).isEmpty()) + if (!match.captured(4).isEmpty()) { - bg = match.captured(3).toInt(nullptr); + bg = match.captured(4).toInt(nullptr); } else if (fg == -1) {