Improve Ui::Text::String features.
This commit is contained in:
@@ -133,8 +133,8 @@ bool ValueParser::readTag() {
|
||||
_tagsUsed.insert(_currentTagIndex);
|
||||
|
||||
if (_currentTagReplacer.isEmpty()) {
|
||||
_currentTagReplacer = QString(4, TextCommand);
|
||||
_currentTagReplacer[1] = kTextCommandLangTag;
|
||||
_currentTagReplacer = QString(4, QChar(kTextCommand));
|
||||
_currentTagReplacer[1] = QChar(kTextCommandLangTag);
|
||||
}
|
||||
_currentTagReplacer[2] = QChar(0x0020 + _currentTagIndex);
|
||||
|
||||
@@ -168,8 +168,10 @@ QString PrepareTestValue(const QString ¤t, QChar filler) {
|
||||
auto result = QString(size + 1, filler);
|
||||
auto inCommand = false;
|
||||
for (auto i = 0; i != size; ++i) {
|
||||
auto ch = current[i];
|
||||
auto newInCommand = (ch.unicode() == TextCommand) ? (!inCommand) : inCommand;
|
||||
const auto ch = current[i];
|
||||
const auto newInCommand = (ch.unicode() == kTextCommand)
|
||||
? (!inCommand)
|
||||
: inCommand;
|
||||
if (inCommand || newInCommand || ch.isSpace()) {
|
||||
result[i + 1] = ch;
|
||||
}
|
||||
|
||||
@@ -868,8 +868,10 @@ auto ChoosePlural = ChoosePluralDefault;
|
||||
|
||||
int FindTagReplacementPosition(const QString &original, ushort tag) {
|
||||
for (auto s = original.constData(), ch = s, e = ch + original.size(); ch != e;) {
|
||||
if (*ch == TextCommand) {
|
||||
if (ch + kTagReplacementSize <= e && (ch + 1)->unicode() == kTextCommandLangTag && *(ch + 3) == TextCommand) {
|
||||
if (ch->unicode() == kTextCommand) {
|
||||
if (ch + kTagReplacementSize <= e
|
||||
&& (ch + 1)->unicode() == kTextCommandLangTag
|
||||
&& (ch + 3)->unicode() == kTextCommand) {
|
||||
if ((ch + 2)->unicode() == 0x0020 + tag) {
|
||||
return ch - s;
|
||||
} else {
|
||||
|
||||
@@ -11,11 +11,12 @@ enum lngtag_count : int;
|
||||
|
||||
namespace Lang {
|
||||
|
||||
inline constexpr auto kTextCommand = 0x10;
|
||||
inline constexpr auto kTextCommandLangTag = 0x20;
|
||||
constexpr auto kTagReplacementSize = 4;
|
||||
|
||||
[[nodiscard]] int FindTagReplacementPosition(
|
||||
const QString &original,
|
||||
const QString &original,
|
||||
ushort tag);
|
||||
|
||||
struct ShortenedCount {
|
||||
|
||||
Reference in New Issue
Block a user