[network/konversation] /: Support code for monospace formatting
Friedrich W. H. Kossebau
null at kde.org
Fri Feb 4 07:30:09 GMT 2022
Git commit bf0d310b6769208262826b8f2d03ed061f70c5a9 by Friedrich W. H. Kossebau.
Committed on 04/02/2022 at 07:27.
Pushed by kossebau into branch 'master'.
Support code for monospace formatting
M +6 -0 doc/index.docbook
A +- -- doc/monospace-text.png
M +2 -0 src/common.cpp
M +1 -1 src/common.h
M +9 -0 src/viewer/ircview.cpp
https://invent.kde.org/network/konversation/commit/bf0d310b6769208262826b8f2d03ed061f70c5a9
diff --git a/doc/index.docbook b/doc/index.docbook
index e240a0fb..e2ba2e1e 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -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>
diff --git a/doc/monospace-text.png b/doc/monospace-text.png
new file mode 100644
index 00000000..d7d8adff
Binary files /dev/null and b/doc/monospace-text.png differ
diff --git a/src/common.cpp b/src/common.cpp
index fd2d3dc3..4ea3ec41 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -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;
}
diff --git a/src/common.h b/src/common.h
index f287a380..d136e190 100644
--- a/src/common.h
+++ b/src/common.h
@@ -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)));
diff --git a/src/viewer/ircview.cpp b/src/viewer/ircview.cpp
index 25a06a85..3814939b 100644
--- a/src/viewer/ircview.cpp
+++ b/src/viewer/ircview.cpp
@@ -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();
More information about the kde-doc-english
mailing list