| 811 | } |
| 812 | |
| 813 | void TextEdit::Del() |
| 814 | { |
| 815 | if (undo_info.first_erase) |
| 816 | { |
| 817 | undo_info.first_erase = false; |
| 818 | undo_info.undo_text = GetText(); |
| 819 | } |
| 820 | |
| 821 | if (GetSelectionLength() != 0) |
| 822 | { |
| 823 | DeleteSelectedText(); |
| 824 | ClearSelection(); |
| 825 | Update(); |
| 826 | } |
| 827 | else |
| 828 | { |
| 829 | if (cursor_pos.x < (int)lines[cursor_pos.y].text.size()) |
| 830 | { |
| 831 | UTF8Reader utf8_reader(lines[cursor_pos.y].text.data(), lines[cursor_pos.y].text.length()); |
| 832 | utf8_reader.set_position(cursor_pos.x); |
| 833 | int length = utf8_reader.char_length(); |
| 834 | lines[cursor_pos.y].text.erase(cursor_pos.x, length); |
| 835 | lines[cursor_pos.y].invalidated = true; |
| 836 | Update(); |
| 837 | } |
| 838 | else if (cursor_pos.y + 1 < lines.size()) |
| 839 | { |
| 840 | selection_start = ivec2(lines[cursor_pos.y].text.length(), cursor_pos.y); |
| 841 | selection_length = 1; |
| 842 | DeleteSelectedText(); |
| 843 | } |
| 844 | } |
| 845 | MoveVerticalScroll(); |
| 846 | } |
| 847 | |
| 848 | void TextEdit::OnTimerExpired() |
| 849 | { |
nothing calls this directly
no test coverage detected