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

Method wrapTextViews

source/rendering/StarTextPainter.cpp:230–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230List<StringView> TextPainter::wrapTextViews(StringView s, Maybe<unsigned> wrapWidth) {
231 List<StringView> views = {};
232 auto last = views.end();
233 unsigned curLine = 0;
234 TextPainter::WrapTextCallback textCallback = [&](StringView text, unsigned line) {
235 if (line == curLine && last != views.end() && last->end() == text.begin()) {
236 *last = StringView(last->utf8Ptr(), last->utf8Size() + text.utf8Size());
237 } else {
238 last = views.insert(views.end(), text);
239 curLine = line;
240 }
241 return true;
242 };
243
244 processWrapText(s, wrapWidth.ptr(), textCallback);
245
246 return views;
247}
248
249StringList TextPainter::wrapText(StringView s, Maybe<unsigned> wrapWidth) {
250 StringList result;

Callers

nothing calls this directly

Calls 7

StringViewClass · 0.85
endMethod · 0.45
beginMethod · 0.45
utf8PtrMethod · 0.45
utf8SizeMethod · 0.45
insertMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected