| 525 | } |
| 526 | |
| 527 | void TextBox::LoadText(const char* text){ |
| 528 | const char* text2 = text; |
| 529 | int lineCount = 1; |
| 530 | |
| 531 | contents.clear(); |
| 532 | |
| 533 | if(multiline){ |
| 534 | while(*text2){ |
| 535 | if(*text2 == '\n') lineCount++; |
| 536 | text2++; |
| 537 | } |
| 538 | |
| 539 | text2 = text; |
| 540 | for(int i = 0; i < lineCount; i++){ |
| 541 | const char* end = strchr(text2, '\n'); |
| 542 | if(end){ |
| 543 | size_t len = (uintptr_t)(end - text2); |
| 544 | if(len > strlen(text2)) break; |
| 545 | |
| 546 | contents.push_back(std::string(text2, len)); |
| 547 | |
| 548 | text2 = end + 1; |
| 549 | } else { |
| 550 | contents.push_back(std::string(text2)); |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | this->lineCount = contents.size(); |
| 555 | ResetScrollBar(); |
| 556 | } else { |
| 557 | contents.push_back(std::string(text2)); |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | void TextBox::OnMouseDown(vector2i_t mousePos){ |
| 562 | assert(contents.size() <= INT_MAX); |