| 838 | } |
| 839 | |
| 840 | void TextEditor::insertTextAtCaret(const String& insert_text) { |
| 841 | undone_history_.clear(); |
| 842 | String text = translateDeadKeyText(insert_text); |
| 843 | if (dead_key_entry_ != DeadKey::None && text == insert_text) |
| 844 | selection_position_ = caret_position_; |
| 845 | |
| 846 | dead_key_entry_ = DeadKey::None; |
| 847 | if (!filtered_characters_.empty()) |
| 848 | text = text.removeCharacters(filtered_characters_); |
| 849 | text = text.removeEmojiVariations(); |
| 850 | |
| 851 | if (action_state_ != kInserting) |
| 852 | addUndoPosition(); |
| 853 | action_state_ = kInserting; |
| 854 | |
| 855 | String before = text_.text().substring(0, selectionStart()); |
| 856 | String after = text_.text().substring(selectionEnd()); |
| 857 | int max_text = text.length(); |
| 858 | if (max_characters_) |
| 859 | max_text = std::max(0, std::min<int>(max_text, max_characters_ - before.length() - after.length())); |
| 860 | |
| 861 | String trimmed = text.substring(0, max_text); |
| 862 | text_.setText(before + trimmed + after); |
| 863 | setLineBreaks(); |
| 864 | caret_position_ = before.length() + max_text; |
| 865 | selection_position_ = caret_position_; |
| 866 | makeCaretVisible(); |
| 867 | |
| 868 | on_text_change_.callback(); |
| 869 | redraw(); |
| 870 | } |
| 871 | |
| 872 | void TextEditor::setNumberEntry() { |
| 873 | setMultiLine(false); |
nothing calls this directly
no test coverage detected