Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core/StarText.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-04-23 13:27:57 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-04-23 13:27:57 +1000
commitdd677772382c3f63a5f2d331c6227e135e01db3c (patch)
tree90c9f3728c64438c5127d1b9699430eaf004c903 /source/core/StarText.cpp
parentc24fc5aeaf0e94bc6148c6d1bfd7a5643affc808 (diff)
Fix text after an unclosed ^ tag not wrapping
Diffstat (limited to 'source/core/StarText.cpp')
-rw-r--r--source/core/StarText.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/source/core/StarText.cpp b/source/core/StarText.cpp
index 86c9f25..d507fd4 100644
--- a/source/core/StarText.cpp
+++ b/source/core/StarText.cpp
@@ -31,21 +31,20 @@ TextStyle& TextStyle::loadJson(Json const& config) {
}
namespace Text {
+ std::string const AllEsc = strf("{:c}{:c}", CmdEsc, StartEsc);
+ std::string const AllEscEnd = strf("{:c}{:c}{:c}", CmdEsc, StartEsc, EndEsc);
+
static auto stripEscapeRegex = std::regex(strf("\\{:c}[^;]*{:c}", CmdEsc, EndEsc));
String stripEscapeCodes(String const& s) {
return std::regex_replace(s.utf8(), stripEscapeRegex, "");
}
- static std::string escapeChars = strf("{:c}{:c}", CmdEsc, StartEsc);
-
bool processText(StringView text, TextCallback textFunc, CommandsCallback commandsFunc, bool includeCommandSides) {
- std::string_view escChars(escapeChars);
-
std::string_view str = text.utf8();
while (true) {
- size_t escape = str.find_first_of(escChars);
+ size_t escape = str.find_first_of(AllEsc);
if (escape != NPos) {
- escape = str.find_first_not_of(escChars, escape) - 1; // jump to the last ^
+ escape = str.find_first_not_of(AllEsc, escape) - 1; // jump to the last ^
size_t end = str.find_first_of(EndEsc, escape);
if (end != NPos) {