Commit bf0d310b authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Support code for monospace formatting

parent a8ac257a
Pipeline #132951 passed with stage
in 1 minute and 24 seconds
......@@ -3339,6 +3339,12 @@ dialog page <menuchoice><guimenu>Behavior</guimenu> <guimenuitem>Auto Replace</g
<imageobject><imagedata fileref="struck-out-text.png" format="PNG" /></imageobject>
</inlinemediaobject>
</para>
<para>Example: <userinput>This is my %Mmonospace%M text.</userinput></para>
<para>Output:
<inlinemediaobject>
<imageobject><imagedata fileref="monospace-text.png" format="PNG" /></imageobject>
</inlinemediaobject>
</para>
</answer>
</qandaentry>
......
......@@ -102,6 +102,7 @@ namespace Konversation
// line.replace(QRegExp("%?"),"\x15");
line.replace(QStringLiteral("%R"),QStringLiteral("\x16")); // replace %R with reverse char
line.replace(QStringLiteral("%U"),QStringLiteral("\x1f")); // replace %U with underline char
line.replace(QStringLiteral("%M"),QStringLiteral("\x11")); // replace %M with monospace char
line.replace(QStringLiteral("%\x01"),QStringLiteral("%")); // restore double %% as single %
return line;
......@@ -125,6 +126,7 @@ namespace Konversation
line.replace(QLatin1Char('\x1f'), QStringLiteral("%U")); // replace underline char with %U
// underline char send by mirc
line.replace(QLatin1Char('\x15'), QStringLiteral("%U")); // replace underline char with %U
line.replace(QLatin1Char('\x11'), QStringLiteral("%M")); // replace monospace char with %M
return line;
}
......
......@@ -19,7 +19,7 @@ namespace Konversation
{
static QRegularExpression ircMarkupsRegExp(QStringLiteral("[\\o{0000}-\\o{0037}]"));
static QRegularExpression colorRegExp(QStringLiteral("(\x03(([0-9]{1,2})(,([0-9]{1,2}))?)?|\x0f)|\x02|\x09|\x13|\x15|\x16|\x1d|\x1e|\x1f"));
static QRegularExpression colorRegExp(QStringLiteral("(\x03(([0-9]{1,2})(,([0-9]{1,2}))?)?|\x0f)|\x02|\x09|\x11|\x13|\x15|\x16|\x1d|\x1e|\x1f"));
static QRegularExpression urlPattern(QStringLiteral("\\b((?:(?:([a-z][\\w\\.-]+:/{1,3})|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|\\}\\]|[^\\s`!()\\[\\]{};:'\".,<>?%1%2%3%4%5%6])|[a-z0-9.\\-+_]+@[a-z0-9.\\-]+[.][a-z]{1,5}[^\\s/`!()\\[\\]{};:'\".,<>?%1%2%3%4%5%6]))").arg(QChar(0x00AB)).arg(QChar(0x00BB)).arg(QChar(0x201C)).arg(QChar(0x201D)).arg(QChar(0x2018)).arg(QChar(0x2019)));
......
......@@ -1431,6 +1431,11 @@ QString IRCView::ircTextToHtml(const QString& text, bool parseURL, const QString
pos += offset -1;
linkOffset += offset -1;
break;
case '\x11': //monospace
offset = defaultHtmlReplace(htmlText, &data, pos, QStringLiteral("tt"));
pos += offset -1;
linkOffset += offset -1;
break;
case '\x03': //color
{
QString fgColor, bgColor;
......@@ -1806,6 +1811,10 @@ QString IRCView::removeDuplicateCodes(const QString& codes, TextHtmlData* data,
defaultRemoveDuplicateHandling(data, QStringLiteral("s"));
++pos;
break;
case '\x11': //monospace
defaultRemoveDuplicateHandling(data, QStringLiteral("tt"));
++pos;
break;
case '\x0f': //reset to default
data->openHtmlTags.clear();
data->lastBgColor.clear();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment