aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/util
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2024-07-29 13:16:54 +0200
committerfiaxh <git@lightrise.org>2024-07-29 13:16:54 +0200
commitb0ff90a14a5d127e17f2371f87e7bb659de3a68f (patch)
treea4b44a2837f94bef433adc318eb9a738425a494f /main/src/ui/util
parentceb921a0148f7fdc2a9df3e6b85143bf8c26c341 (diff)
downloaddino-b0ff90a14a5d127e17f2371f87e7bb659de3a68f.tar.gz
dino-b0ff90a14a5d127e17f2371f87e7bb659de3a68f.zip
Add initial message markup (XEP-0394) support
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/}
*