| 311 | } |
| 312 | |
| 313 | PiuTextKind 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 | |
| 345 | void PiuTextBegin(PiuText* self) |
| 346 | { |
no test coverage detected