2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

improved emoji text replaces

This commit is contained in:
John Preston
2015-05-12 18:01:49 +03:00
parent 47f673aa69
commit d92356ce28
6 changed files with 59 additions and 34 deletions

View File

@@ -239,31 +239,6 @@ const QChar *textSkipCommand(const QChar *from, const QChar *end, bool canLink)
return (result < end && *result == TextCommand) ? (result + 1) : from;
}
QString textEmojiString(EmojiPtr emoji) {
if ((emoji->code & 0xFFFF0000U) == 0xFFFF0000U) { // sequence
return emojiGetSequence(emoji->code & 0xFFFFU);
}
QString result;
result.reserve(emoji->len + (emoji->postfix ? 1 : 0));
if (!(emoji->code >> 16)) {
result.append(QChar(emoji->code & 0xFFFF));
} else {
result.append(QChar((emoji->code >> 16) & 0xFFFF));
result.append(QChar(emoji->code & 0xFFFF));
if (emoji->code2) {
result.append(QChar((emoji->code2 >> 16) & 0xFFFF));
result.append(QChar(emoji->code2 & 0xFFFF));
}
}
if (emoji->color && ((emoji->color & 0xFFFF0000U) != 0xFFFF0000U)) {
result.append(QChar((emoji->color >> 16) & 0xFFFF));
result.append(QChar(emoji->color & 0xFFFF));
}
if (emoji->postfix) result.append(QChar(emoji->postfix));
return result;
}
class TextParser {
public:
@@ -527,6 +502,10 @@ public:
for (int l = len - skipped - 1; l > 0; --l) {
_t->_text.push_back(*++ptr);
}
if (e->postfix && _t->_text.at(_t->_text.size() - 1).unicode() != e->postfix) {
_t->_text.push_back(e->postfix);
++len;
}
createBlock(-len);
emoji = e;