MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / PiuTextAdvance

Function PiuTextAdvance

modules/piu/All/piuText.c:313–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313PiuTextKind PiuTextAdvance(xsMachine* the, xsSlot* string, PiuTextOffset offset, PiuTextOffset limit, PiuTextOffset *nextOffset)
314{
315 PiuTextOffset length = 0;
316 PiuTextKind kind = piuTextWord;
317 if (offset == limit)
318 kind = piuTextEnd;
319 else {
320 xsIntegerValue c;
321 xsStringValue p = xsToString(*string) + offset;
322 xsStringValue q = fxUTF8Decode(p, &c);
323 length = (PiuTextOffset)(q - p);
324 if ((c == C_EOF) || (c == 0))
325 kind = piuTextEnd;
326 if (length == 1) {
327 if (c == '\n')
328 kind = piuTextReturn;
329 else if (c == '\t')
330 kind = piuTextSpace;
331 else if (c == ' ')
332 kind = piuTextSpace;
333 }
334 else {
335 if (c == 0xA0)
336 kind = piuTextSpace;
337 else if ((0x4E00 <= c) && (c <= 0x9FFF))
338 kind = piuTextWordBreak;
339 }
340 }
341 *nextOffset = offset + length;
342 return kind;
343}
344
345void PiuTextBegin(PiuText* self)
346{

Callers 3

PiuTextDrawFunction · 0.85
PiuTextFormatFunction · 0.85
PiuTextHitFunction · 0.85

Calls 1

fxUTF8DecodeFunction · 0.85

Tested by

no test coverage detected