diff options
author | eerielili <lionel@les-miquelots.net> | 2024-08-25 13:32:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-25 13:32:38 +0000 |
commit | 45755727db79a2935376d24e7bde7eadb0f2f7ca (patch) | |
tree | 73715da99c9d980079df6f2d561822364655e04d /main/src/ui/util/helper.vala | |
parent | 62cdea3a5e701c04f3a7fd9d6b5f48e28fef1f72 (diff) | |
parent | 51252f74c94c17d56aa75534652bdc5d43a504cb (diff) | |
download | dino-45755727db79a2935376d24e7bde7eadb0f2f7ca.tar.gz dino-45755727db79a2935376d24e7bde7eadb0f2f7ca.zip |
Merge branch 'master' into add-yourselfadd-yourself
Diffstat (limited to 'main/src/ui/util/helper.vala')
-rw-r--r-- | main/src/ui/util/helper.vala | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index 63288fc2..45b96b94 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -297,6 +297,31 @@ public static string parse_add_markup_theme(string s_, string? highlight_word, b return s; } + // Modifies `markups`. + public string remove_fallbacks_adjust_markups(string text, bool contains_quote, Gee.List<Xep.FallbackIndication.Fallback> fallbacks, Gee.List<Xep.MessageMarkup.Span> markups) { + string processed_text = text; + + foreach (var fallback in fallbacks) { + if (fallback.ns_uri == Xep.Replies.NS_URI && contains_quote) { + foreach (var fallback_location in fallback.locations) { + processed_text = processed_text[0:processed_text.index_of_nth_char(fallback_location.from_char)] + + processed_text[processed_text.index_of_nth_char(fallback_location.to_char):processed_text.length]; + + int length = fallback_location.to_char - fallback_location.from_char; + foreach (Xep.MessageMarkup.Span span in markups) { + if (span.start_char > fallback_location.to_char) { + span.start_char -= length; + } + if (span.end_char > fallback_location.to_char) { + span.end_char -= length; + } + } + } + } + } + return processed_text; + } + /** * This is a heuristic to count emojis in a string {@link http://example.com/} * |