MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / flattenLine

Function flattenLine

3ds/source/ScriptRequestOverlays.cpp:52–69  ·  view source on GitHub ↗

List rows are single-line, but script-supplied strings can carry newlines (3DS SMDH long titles store the two-line marquee form as "line1\nline2"). C2D_DrawText honours those breaks and wraps the row mid-screen, so collapse any CR/LF run to a single space before the row is measured and drawn.

Source from the content-addressed store, hash-verified

50 // C2D_DrawText honours those breaks and wraps the row mid-screen, so collapse
51 // any CR/LF run to a single space before the row is measured and drawn.
52 std::string flattenLine(const std::string& s)
53 {
54 std::string out;
55 out.reserve(s.size());
56 bool pendingSpace = false;
57 for (char c : s) {
58 if (c == '\n' || c == '\r') {
59 pendingSpace = !out.empty();
60 continue;
61 }
62 if (pendingSpace) {
63 out.push_back(' ');
64 pendingSpace = false;
65 }
66 out.push_back(c);
67 }
68 return out;
69 }
70}
71
72/* ---- shared tile chrome ------------------------------------------------- */

Callers 1

drawRowMethod · 0.85

Calls 3

sizeMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected