aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/util
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/util')
-rw-r--r--main/src/ui/util/helper.vala25
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/}
*