| 984 | } |
| 985 | |
| 986 | void PiuCode_colorize(xsMachine *the) |
| 987 | { |
| 988 | PiuCode* self = PIU(Code, xsThis); |
| 989 | xsStringValue string = PiuToString((*self)->string); |
| 990 | PiuTextBuffer* runs = (*self)->runs; |
| 991 | PiuCodeRun run = (PiuCodeRun)((uint8_t*)(*runs) + sizeof(PiuTextBufferRecord)); |
| 992 | PiuCodeRun limit = (PiuCodeRun)((uint8_t*)(*runs) + (*runs)->current); |
| 993 | int32_t start = 0, offset, unicodeOffset = 0, utf8Offset = 0; |
| 994 | int16_t color; |
| 995 | xsIntegerValue c = xsToInteger(xsGet(xsArg(0), xsID_length)), i; |
| 996 | for (i = 0; i < c; i++) { |
| 997 | xsResult = xsGetAt(xsArg(0), xsInteger(i)); |
| 998 | offset = xsToInteger(xsGet(xsResult, xsID_offset)); |
| 999 | utf8Offset += fxUnicodeToUTF8Offset(string + utf8Offset, offset - unicodeOffset); |
| 1000 | unicodeOffset = offset; |
| 1001 | color = (int16_t)xsToInteger(xsGet(xsResult, xsID_color)); |
| 1002 | while (run < limit) { |
| 1003 | if ((start == utf8Offset) && (run->kind == piuCodeColorKind)) { |
| 1004 | run->color = color; |
| 1005 | break; |
| 1006 | } |
| 1007 | start += run->count; |
| 1008 | run++; |
| 1009 | } |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | void PiuCode_find(xsMachine *the) |
| 1014 | { |
nothing calls this directly
no test coverage detected