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

Function PiuCodeOffsetToColumnLine

modules/piu/PC/Code/piuCode.c:634–670  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632}
633
634void PiuCodeOffsetToColumnLine(PiuCode* self, int32_t offset, int32_t* offsetColumn, int32_t* offsetLine)
635{
636 xsMachine* the = (*self)->the;
637 xsStringValue string = PiuToString((*self)->string);
638 PiuTextBuffer* runs = (*self)->runs;
639 PiuCodeRun run = (PiuCodeRun)((uint8_t*)(*runs) + sizeof(PiuTextBufferRecord));
640 int32_t lineIndex = 0;
641 int32_t columnIndex = 0;
642 while (*string) {
643 switch(run->kind) {
644 case piuCodeLineKind:
645 if (offset == 0)
646 goto bail;
647 lineIndex++;
648 columnIndex = 0;
649 break;
650 case piuCodeTabKind:
651 if (offset == 0)
652 goto bail;
653 columnIndex += run->color;
654 break;
655 default:
656 if (offset < run->count) {
657 columnIndex += fxUTF8ToUnicodeOffset(string, offset);
658 goto bail;
659 }
660 columnIndex += fxUTF8ToUnicodeOffset(string, run->count);
661 break;
662 }
663 offset -= run->count;
664 string += run->count;
665 run++;
666 }
667bail:
668 *offsetColumn = columnIndex;
669 *offsetLine = lineIndex;
670}
671
672void PiuCodeSearch(PiuCode* self, uint32_t size)
673{

Callers 3

PiuCodeSearchFunction · 0.85
PiuCodeSelectFunction · 0.85
PiuCode_locateFunction · 0.85

Calls 1

fxUTF8ToUnicodeOffsetFunction · 0.85

Tested by

no test coverage detected