diff --git a/ui/text/text_utilities.cpp b/ui/text/text_utilities.cpp index dcc8d4f..5a2d468 100644 --- a/ui/text/text_utilities.cpp +++ b/ui/text/text_utilities.cpp @@ -46,6 +46,13 @@ TextWithEntities PlainLink(const QString &text) { return WithSingleEntity(text, EntityType::PlainLink); } +TextWithEntities Wrapped(TextWithEntities text, EntityType type) { + text.entities.insert( + text.entities.begin(), + { type, 0, int(text.text.size()), {} }); + return text; +} + TextWithEntities RichLangValue(const QString &text) { static const auto kStart = QRegularExpression("(\\*\\*|__)"); diff --git a/ui/text/text_utilities.h b/ui/text/text_utilities.h index 3ebe974..3b2eddf 100644 --- a/ui/text/text_utilities.h +++ b/ui/text/text_utilities.h @@ -31,6 +31,9 @@ inline constexpr auto Upper = details::ToUpperType{}; const QString &text, const QString &url = "internal:action"); [[nodiscard]] TextWithEntities PlainLink(const QString &text); +[[nodiscard]] TextWithEntities Wrapped( + TextWithEntities text, + EntityType type); [[nodiscard]] TextWithEntities RichLangValue(const QString &text); [[nodiscard]] inline TextWithEntities WithEntities(const QString &text) { return { text };