MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / processText

Function processText

source/core/StarText.cpp:46–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 }
45
46 bool processText(StringView text, TextCallback textFunc, CommandsCallback commandsFunc, bool includeCommandSides) {
47 std::string_view str = text.utf8();
48 while (true) {
49 size_t escape = str.find_first_of(AllEsc);
50 if (escape != NPos) {
51 escape = str.find_first_not_of(AllEsc, escape) - 1; // jump to the last ^
52
53 size_t end = str.find_first_of(EndEsc, escape);
54 if (end != NPos) {
55 if (escape && !textFunc(str.substr(0, escape)))
56 return false;
57 if (commandsFunc) {
58 StringView commands = includeCommandSides
59 ? str.substr(escape, end - escape + 1)
60 : str.substr(escape + 1, end - escape - 1);
61 if (!commands.empty() && !commandsFunc(commands))
62 return false;
63 }
64 str = str.substr(end + 1);
65 continue;
66 }
67 }
68
69 if (!str.empty())
70 return textFunc(str);
71
72 return true;
73 }
74 }
75
76 // The below two functions aren't used anymore, not bothering with StringView for them
77 String preprocessEscapeCodes(String const& s) {

Callers 2

stringWidthMethod · 0.85
doRenderLineMethod · 0.85

Calls 2

substrMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected