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

Function PiuTextBuild

modules/piu/All/piuText.c:380–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380void PiuTextBuild(PiuText* self, xsIntegerValue depth, PiuTextKind delta)
381{
382 xsMachine *the = (*self)->the;
383 PiuStyle* style;
384 PiuTextLink* link;
385 if (xsTest(xsVar(depth))) {
386 if (xsIsInstanceOf(xsVar(depth), xsArrayPrototype)) {
387 xsIntegerValue i, c = xsToInteger(xsGet(xsVar(depth), xsID_length));
388 for (i = 0; i < c; i++) {
389 xsResult = xsGetAt(xsVar(depth) , xsInteger(i));
390 if (xsIsInstanceOf(xsResult, xsObjectPrototype)) {
391 depth++;
392 if (depth == piuTextDepth)
393 xsUnknownError("too deep");
394 xsVar(depth) = xsGet(xsResult, xsID_style);
395 if (xsTest(xsVar(depth)))
396 style = PIU(Style, xsVar(depth));
397 else
398 style = NULL;
399 xsVar(depth) = xsGet(xsResult, xsID_link);
400 if (xsTest(xsVar(depth)))
401 link = PIU(TextLink, xsVar(depth));
402 else
403 link = NULL;
404 PiuTextBeginNode(self, piuTextNodeBeginBlockKind + delta, style, link);
405 xsVar(depth) = xsGet(xsResult, xsID_spans);
406 PiuTextBuild(self, depth, 1);
407 PiuTextEndNode(self, piuTextNodeEndBlockKind + delta);
408 depth--;
409 }
410 else {
411 if (!delta)
412 PiuTextBeginNode(self, piuTextNodeBeginBlockKind, NULL, NULL);
413 PiuTextConcat(self, PiuString(xsResult));
414 if (!delta)
415 PiuTextEndNode(self, piuTextNodeEndBlockKind);
416 }
417 }
418 }
419 else {
420 if (!delta)
421 PiuTextBeginNode(self, piuTextNodeBeginBlockKind, NULL, NULL);
422 PiuTextConcat(self, PiuString(xsVar(depth)));
423 if (!delta)
424 PiuTextEndNode(self, piuTextNodeEndBlockKind);
425 }
426 }
427}
428
429void PiuTextCascade(void* it)
430{

Callers 2

PiuTextDictionaryFunction · 0.85
PiuText_set_blocksFunction · 0.85

Calls 3

PiuTextBeginNodeFunction · 0.85
PiuTextEndNodeFunction · 0.85
PiuTextConcatFunction · 0.85

Tested by

no test coverage detected