diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-11-07 14:36:13 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-11-07 14:36:13 +0100 |
commit | c2219fdf1f741a33f415124459de69054313de57 (patch) | |
tree | 0b89fd2f83cb97eec6f8361a4356b3f414124998 | |
parent | c65a57e884de51cade584e3f01c7c5627aa6ebd8 (diff) |
Unformat text for clipboard
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 3 | ||||
-rw-r--r-- | src/Text.cpp | 16 | ||||
-rw-r--r-- | src/plugins/ImageBoard.cpp | 2 | ||||
-rw-r--r-- | src/plugins/Page.cpp | 6 |
5 files changed, 15 insertions, 15 deletions
@@ -245,5 +245,4 @@ Downloading files should take into account the remove mime type if available. Fa Text images atlas. Do not render invalid unicode. Use matrix "from" with proper cache. -Text editing should take into consideration FORMATTED_TEXT_START/FORMATTED_TEXT_END. -Matrix edit message (happens even with matrix in master branch if it's to a reply) (by us, local) gets reverted back to the previous message when re-entering the room. Why?
\ No newline at end of file +Text editing should take into consideration FORMATTED_TEXT_START/FORMATTED_TEXT_END.
\ No newline at end of file diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index d72f465..1f5e775 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -6940,8 +6940,7 @@ namespace QuickMedia { if(event.key.control && event.key.code == mgl::Keyboard::C) { BodyItem *selected = tabs[selected_tab].body->get_selected(); if(selected) { - const std::string body_text_unformatted = Text::to_printable_string(selected->get_description()); - set_clipboard(body_text_unformatted); + set_clipboard(Text::to_printable_string(selected->get_description())); } } diff --git a/src/Text.cpp b/src/Text.cpp index ed972e0..6bc777d 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -772,13 +772,15 @@ namespace QuickMedia for(size_t i = 0; i < textElement.text.size();) { mgl::Color text_color = text_element_color; - if(url_range_index < url_ranges.size()) { - size_t string_offset = (textElement.text.data() + i) - str.data(); - if(string_offset >= url_ranges[url_range_index].start && string_offset < url_ranges[url_range_index].start + url_ranges[url_range_index].length) { - text_color = url_color; - text_color.a = text_element_color.a; - if(string_offset + 1 == url_ranges[url_range_index].start + url_ranges[url_range_index].length) - ++url_range_index; + if(!force_color) { + if(url_range_index < url_ranges.size()) { + size_t string_offset = (textElement.text.data() + i) - str.data(); + if(string_offset >= url_ranges[url_range_index].start && string_offset < url_ranges[url_range_index].start + url_ranges[url_range_index].length) { + text_color = url_color; + text_color.a = text_element_color.a; + if(string_offset + 1 == url_ranges[url_range_index].start + url_ranges[url_range_index].length) + ++url_range_index; + } } } diff --git a/src/plugins/ImageBoard.cpp b/src/plugins/ImageBoard.cpp index e1ee8fa..31e08ab 100644 --- a/src/plugins/ImageBoard.cpp +++ b/src/plugins/ImageBoard.cpp @@ -2,7 +2,7 @@ namespace QuickMedia { void ImageBoardThreadPage::copy_to_clipboard(const BodyItem *body_item) { - set_clipboard(body_item->get_title()); + set_clipboard(Text::to_printable_string(body_item->get_title())); } const std::string& ImageBoardThreadPage::get_pass_id() { diff --git a/src/plugins/Page.cpp b/src/plugins/Page.cpp index f5867e3..991f651 100644 --- a/src/plugins/Page.cpp +++ b/src/plugins/Page.cpp @@ -49,9 +49,9 @@ namespace QuickMedia { } void Page::copy_to_clipboard(const BodyItem *body_item) { - std::string title = body_item->get_title(); - std::string author = body_item->get_author(); - std::string description = body_item->get_description(); + std::string title = Text::to_printable_string(body_item->get_title()); + std::string author = Text::to_printable_string(body_item->get_author()); + std::string description = Text::to_printable_string(body_item->get_description()); std::string clipboard = std::move(title); |