---------------------------------------------------------------------------------
| 448 | |
| 449 | //--------------------------------------------------------------------------------- |
| 450 | ssize_t con_write(struct _reent *r,void *fd,const char *ptr, size_t len) { |
| 451 | //--------------------------------------------------------------------------------- |
| 452 | |
| 453 | char chr; |
| 454 | |
| 455 | int i, count = 0; |
| 456 | char *tmp = (char*)ptr; |
| 457 | |
| 458 | if(!tmp) return -1; |
| 459 | |
| 460 | i = 0; |
| 461 | |
| 462 | while(i<len) { |
| 463 | |
| 464 | chr = *(tmp++); |
| 465 | i++; count++; |
| 466 | switch (escapeSeq.state) |
| 467 | { |
| 468 | case ESC_NONE: |
| 469 | if (chr == 0x1b) |
| 470 | escapeSeq.state = ESC_START; |
| 471 | else |
| 472 | consolePrintChar(chr); |
| 473 | break; |
| 474 | case ESC_START: |
| 475 | if (chr == '[') |
| 476 | { |
| 477 | escapeSeq.state = ESC_BUILDING_UNKNOWN; |
| 478 | escapeSeq.hasArg = false; |
| 479 | memset(escapeSeq.args, 0, sizeof(escapeSeq.args)); |
| 480 | escapeSeq.color.bg = currentConsole->bg; |
| 481 | escapeSeq.color.fg = currentConsole->fg; |
| 482 | escapeSeq.color.flags = currentConsole->flags; |
| 483 | escapeSeq.argIdx = 0; |
| 484 | } |
| 485 | else |
| 486 | { |
| 487 | consolePrintChar(0x1b); |
| 488 | consolePrintChar(chr); |
| 489 | escapeSeq.state = ESC_NONE; |
| 490 | } |
| 491 | break; |
| 492 | case ESC_BUILDING_UNKNOWN: |
| 493 | switch (chr) |
| 494 | { |
| 495 | case '0': |
| 496 | case '1': |
| 497 | case '2': |
| 498 | case '3': |
| 499 | case '4': |
| 500 | case '5': |
| 501 | case '6': |
| 502 | case '7': |
| 503 | case '8': |
| 504 | case '9': |
| 505 | escapeSeq.hasArg = true; |
| 506 | escapeSeq.args[escapeSeq.argIdx] = escapeSeq.args[escapeSeq.argIdx] * 10 + (chr - '0'); |
| 507 | break; |
nothing calls this directly
no test coverage detected