From 803a2f20bd44475fc7f1fb6dffa37fb8413c870c Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Sat, 31 Jul 2021 20:39:13 -0500 Subject: [PATCH] /me now formats /me properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /me waves arms in the air like a maniac /me knocks over a nearby cup of coffee /me gasps when the coffee spills onto the adjacent laptop /me cries out “Fore! Wait, four! Wait, fire!” when the laptop bursts into flames /me burns to a crisp --- application/Conversation.cpp | 6 +++++- application/views/ConversationView.cpp | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/application/Conversation.cpp b/application/Conversation.cpp index f23979c..9dfa90b 100644 --- a/application/Conversation.cpp +++ b/application/Conversation.cpp @@ -166,11 +166,15 @@ Conversation::ImMessage(BMessage* msg) BString args = CommandArgs(body); ChatCommand* cmd = _GetServer()->CommandById(name, fLooper->GetInstance()); - if (cmd == NULL) { + if (cmd == NULL && name != "me") { _WarnUser(BString(B_TRANSLATE("That isn't a valid command. " "Try /help for a list."))); break; } + else { + fMessenger.SendMessage(msg); + break; + } BString error(""); if (cmd->Parse(args, &error, this) == false) diff --git a/application/views/ConversationView.cpp b/application/views/ConversationView.cpp index d33d92b..f0693a2 100644 --- a/application/views/ConversationView.cpp +++ b/application/views/ConversationView.cpp @@ -82,6 +82,7 @@ ConversationView::AttachedToWindow() } NotifyInteger(INT_WINDOW_FOCUSED, 0); fSendView->MakeFocus(true); + fSendView->Invalidate(); } @@ -433,6 +434,14 @@ ConversationView::_AppendMessage(BMessage* msg) continue; } + if (body.StartsWith("/me ")) { + BString meMsg = "** "; + meMsg << sender_name.String() << " "; + meMsg << body.RemoveFirst("/me "); + fReceiveView->AppendGeneric(meMsg.String()); + continue; + } + fReceiveView->AppendMessage(sender_name.String(), body.String(), userColor, (time_t)timeInt); }