| 632 | } |
| 633 | |
| 634 | void 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 | } |
| 667 | bail: |
| 668 | *offsetColumn = columnIndex; |
| 669 | *offsetLine = lineIndex; |
| 670 | } |
| 671 | |
| 672 | void PiuCodeSearch(PiuCode* self, uint32_t size) |
| 673 | { |
no test coverage detected