| @@ -515,45 +515,48 @@ void drawTextBox(uint16_t textBoxID) · 514 unmodified lines |
| 515 | if (t->textPtr == NULL) | 515 | if (t->textPtr == NULL) |
| 516 | return; | 516 | return; |
| 517 | | 517 | |
| 518 | // draw text mark background | 518 | // draw text mark background (if this is the textbox we last interacted with) |
| 519 | if (textIsMarked()) | 519 | if (mouse.lastEditBox == textBoxID) |
| 520 | { | 520 | { |
| 521 | hideSprite(SPRITE_TEXT_CURSOR); | 521 | if (textIsMarked()) |
| | 522 | { |
| | 523 | hideSprite(SPRITE_TEXT_CURSOR); |
| 522 | | 524 | |
| 523 | int32_t start = getTextMarkStart(); | 525 | int32_t start = getTextMarkStart(); |
| 524 | int32_t end = getTextMarkEnd(); | 526 | int32_t end = getTextMarkEnd(); |
| 525 | | 527 | |
| 526 | assert(start < t->maxChars && end <= t->maxChars); | 528 | assert(start < t->maxChars && end <= t->maxChars); |
| 527 | | 529 | |
| 528 | // find pixel start/length from markX1 and markX2 | 530 | // find pixel start/length from markX1 and markX2 |
| 529 | | 531 | |
| 530 | int32_t x1 = 0; | 532 | int32_t x1 = 0; |
| 531 | int32_t x2 = 0; | 533 | int32_t x2 = 0; |
| 532 | | 534 | |
| 533 | for (int32_t i = 0; i < end; i++) | 535 | for (int32_t i = 0; i < end; i++) |
| 534 | { | 536 | { |
| 535 | const char ch = t->textPtr[i]; | 537 | const char ch = t->textPtr[i]; |
| 536 | if (ch == '\0') | 538 | if (ch == '\0') |
| 537 | break; | 539 | break; |
| 538 | | 540 | |
| 539 | cw = charWidth(ch); | 541 | cw = charWidth(ch); |
| 540 | if (i < start) | 542 | if (i < start) |
| 541 | x1 += cw; | 543 | x1 += cw; |
| 542 | | 544 | |
| 543 | x2 += cw; | 545 | x2 += cw; |
| 544 | } | 546 | } |
| 545 | | 547 | |
| 546 | // render text mark background | 548 | // render text mark background |
| 547 | if (x1 != x2) | 549 | if (x1 != x2) |
| 548 | { | 550 | { |
| 549 | start = x1; | 551 | start = x1; |
| 550 | const int32_t length = x2 - x1; | 552 | const int32_t length = x2 - x1; |
| 551 | | 553 | |
| 552 | assert(start+length <= t->renderBufW); | 554 | assert(start+length <= t->renderBufW); |
| 553 | | 555 | |
| 554 | uint8_t *ptr32 = &t->renderBuf[start]; | 556 | uint8_t *ptr32 = &t->renderBuf[start]; |
| 555 | for (uint16_t y = 0; y < t->renderBufH; y++, ptr32 += t->renderBufW) | 557 | for (uint16_t y = 0; y < t->renderBufH; y++, ptr32 += t->renderBufW) |
| 556 | memset(ptr32, PAL_TEXTMRK, length); | 558 | memset(ptr32, PAL_TEXTMRK, length); |
| | 559 | } |
| 557 | } | 560 | } |
| 558 | } | 561 | } |
| 559 | | 562 | |