message-text: Make emoji-only messages bigger

This commit is contained in:
Kévin Commaille 2021-12-25 10:42:05 +01:00
parent cd92949d13
commit 15c2803c70
No known key found for this signature in database
GPG key ID: DD507DAE96E8245C
4 changed files with 27 additions and 0 deletions

1
Cargo.lock generated
View file

@ -1001,6 +1001,7 @@ dependencies = [
"once_cell",
"qrcode",
"rand 0.8.4",
"regex",
"secret-service",
"serde",
"serde_json",

View file

@ -34,6 +34,7 @@ gst = {version = "0.17", package = "gstreamer"}
gst_base = {version = "0.17", package = "gstreamer-base"}
gst_video = {version = "0.17", package = "gstreamer-video"}
image = {version = "0.23", default-features = false, features=["png"]}
regex = "1.5.4"
[dependencies.sourceview]
package = "sourceview5"

View file

@ -209,6 +209,10 @@ headerbar.flat {
margin-left: 46px;
}
.room-history .event-content .emoji {
font-size: 3em;
}
.room-history .event-content .thumbnail {
border-radius: 6px;
background-color: @light_3;

View file

@ -5,6 +5,8 @@ use html2pango::{
html_escape, markup_links,
};
use matrix_sdk::ruma::events::room::message::{FormattedBody, MessageFormat};
use once_cell::sync::Lazy;
use regex::Regex;
use sourceview::prelude::*;
use crate::session::{
@ -13,6 +15,21 @@ use crate::session::{
UserExt,
};
static EMOJI_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(
r"(?x)
^
[\p{White_Space}\p{Emoji_Component}]*
[\p{Emoji}--\p{Decimal_Number}]+
[\p{White_Space}\p{Emoji}\p{Emoji_Component}--\p{Decimal_Number}]*
$
# That string is made of at least one emoji, except digits, possibly more,
# possibly with modifiers, possibly with spaces, but nothing else
",
)
.unwrap()
});
mod imp {
use super::*;
use once_cell::sync::Lazy;
@ -199,6 +216,10 @@ impl MessageText {
child
};
if EMOJI_REGEX.is_match(text) {
child.add_css_class("emoji");
}
if use_markup {
child.set_markup(text);
} else {