From 99bee0e8d2c498f6dff94a87db7540687161f3f7 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 2 Oct 2020 19:08:25 +0200 Subject: Matrix: fix reply to multiline reply --- TODO | 7 ++++++- src/QuickMedia.cpp | 4 ++-- src/plugins/Matrix.cpp | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index b5b808e..8eb3412 100644 --- a/TODO +++ b/TODO @@ -74,4 +74,9 @@ Make text that mentions us red in matrix. Allow scrolling body item. A body item can be long and we wont be able to read all of it otherwise (such as a message on matrix). Pressing up/down should scroll such a large body item rather than moving to another one. Cleanup keybindings. Some require ctrl, some dont (4chan vs matrix for example). Add room topic beside room name in matrix (in messages tab). -Move rooms in matrix to previous page instead, then messages can be beside users, pinned messages, settings, etc and they would all be connected to that one room, then beside rooms tab there would be a global settings tab. \ No newline at end of file +Move rooms in matrix to previous page instead, then messages can be beside users, pinned messages, settings, etc and they would all be connected to that one room, then beside rooms tab there would be a global settings tab. +Add /me to matrix, emoji, reactions... +Set the icon of the window to be the icon of the plugin. Nice for KDE, GNOME, etc with titlebars. +Set a minimum wrap size for text. We dont want one line of text to fully fill the window vertically when the window size width is small. Its better to cut off the text and add eclipses. +Get the related message and show that (async) instead of what the reply says the original text is in body, for matrix replies. +Support matrix html (for replies and text styling, such as greentext). \ No newline at end of file diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 41c4cb1..29b2db9 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -4179,8 +4179,8 @@ namespace QuickMedia { std::string room_desc = current_room_body_data->body_item->get_description(); if(strncmp(room_desc.c_str(), "Unread: ", 8) == 0) room_desc = room_desc.substr(8); - if(room_desc.size() >= 26 && strncmp(room_desc.c_str() + room_desc.size() - 26, "\n** You were mentioned **", 26) == 0) - room_desc = room_desc.substr(0, room_desc.size() - 26); + if(room_desc.size() >= 25 && strncmp(room_desc.c_str() + room_desc.size() - 25, "\n** You were mentioned **", 25) == 0) + room_desc = room_desc.substr(0, room_desc.size() - 25); current_room_body_data->body_item->set_description(std::move(room_desc)); // TODO: Show a line like nheko instead for unread messages, or something else current_room_body_data->body_item->title_color = sf::Color::White; diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 585664a..b8f3742 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -904,6 +904,20 @@ namespace QuickMedia { return str; } + static std::string block_quote(const std::string &str) { + std::string result = "> "; + for(char c : str) { + if(c == '>') { + result += "\\>"; + } else if(c == '\n') { + result += "\n> "; + } else { + result += c; + } + } + return result; + } + static std::string create_body_for_message_reply(const RoomData *room_data, const Message *message, const std::string &body) { std::string related_to_body; switch(message->type) { @@ -927,7 +941,7 @@ namespace QuickMedia { related_to_body = "sent a file"; break; } - return "> <" + room_data->user_info[message->user_id].user_id + "> " + std::move(related_to_body) + "\n\n" + body; + return block_quote("<" + room_data->user_info[message->user_id].user_id + "> " + std::move(related_to_body)) + "\n\n" + body; } // TODO: Add formatted_body just like element does with