summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2021-03-28 18:23:50 +0000
committerGitHub <noreply@github.com>2021-03-28 18:23:50 +0000
commit326f48d87fda89171b3dbe0923bc08671ded281b (patch)
tree57e7f4b1f3cfeb699a4b75dd0634f0cc9d71fc04 /src/timeline
parentMerge pull request #539 from anjanik012/fix_build (diff)
parentrun formatter (diff)
downloadnheko-326f48d87fda89171b3dbe0923bc08671ded281b.tar.xz
Merge pull request #535 from LordMZTE/feature/rainbow
add /rainbow command
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/InputBar.cpp9
-rw-r--r--src/timeline/InputBar.h4
2 files changed, 9 insertions, 4 deletions
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp

index b45827f6..53296efd 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp
@@ -13,6 +13,7 @@ #include <QStandardPaths> #include <QUrl> +#include <QRegularExpression> #include <mtx/responses/common.hpp> #include <mtx/responses/media.hpp> @@ -203,7 +204,7 @@ InputBar::send() auto wasEdit = !room->edit().isEmpty(); if (text().startsWith('/')) { - int command_end = text().indexOf(' '); + int command_end = text().indexOf(QRegularExpression("\\s")); if (command_end == -1) command_end = text().size(); auto name = text().mid(1, command_end - 1); @@ -255,7 +256,7 @@ InputBar::openFileSelection() } void -InputBar::message(QString msg, MarkdownOverride useMarkdown) +InputBar::message(QString msg, MarkdownOverride useMarkdown, bool rainbowify) { mtx::events::msg::Text text = {}; text.body = msg.trimmed().toStdString(); @@ -263,7 +264,7 @@ InputBar::message(QString msg, MarkdownOverride useMarkdown) if ((ChatPage::instance()->userSettings()->markdown() && useMarkdown == MarkdownOverride::NOT_SPECIFIED) || useMarkdown == MarkdownOverride::ON) { - text.formatted_body = utils::markdownToHtml(msg).toStdString(); + text.formatted_body = utils::markdownToHtml(msg, rainbowify).toStdString(); // Remove markdown links by completer text.body = msg.trimmed().replace(conf::strings::matrixToMarkdownLink, "\\1").toStdString(); @@ -526,6 +527,8 @@ InputBar::command(QString command, QString args) message(args, MarkdownOverride::ON); } else if (command == "plain") { message(args, MarkdownOverride::OFF); + } else if (command == "rainbow") { + message(args, MarkdownOverride::ON, true); } } diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h
index acd9e22c..f7a60488 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h
@@ -53,7 +53,9 @@ public slots: void updateState(int selectionStart, int selectionEnd, int cursorPosition, QString text); void openFileSelection(); bool uploading() const { return uploading_; } - void message(QString body, MarkdownOverride useMarkdown = MarkdownOverride::NOT_SPECIFIED); + void message(QString body, + MarkdownOverride useMarkdown = MarkdownOverride::NOT_SPECIFIED, + bool rainbowify = false); private slots: void startTyping();