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
This commit is contained in:
Mm2PL 2020-07-11 14:57:30 +02:00 committed by GitHub
parent 682caf6b69
commit c80cdc25b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,7 +15,7 @@ namespace chatterino {
namespace { namespace {
QRegularExpression IRC_COLOR_PARSE_REGEX( QRegularExpression IRC_COLOR_PARSE_REGEX(
"\u0003(\\d{1,2})?(,(\\d{1,2}))?", "(\u0003(\\d{1,2})?(,(\\d{1,2}))?|\u000f)",
QRegularExpression::UseUnicodePropertiesOption); QRegularExpression::UseUnicodePropertiesOption);
} // namespace } // namespace
@ -475,18 +475,23 @@ IrcTextElement::IrcTextElement(const QString &fullText,
segments.emplace_back(seg); segments.emplace_back(seg);
lastPos = match.capturedStart() + match.capturedLength(); lastPos = match.capturedStart() + match.capturedLength();
} }
if (!match.captured(1).isEmpty()) 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 else
{ {
fg = -1; 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) else if (fg == -1)
{ {