diff options
author | crupest <crupest@outlook.com> | 2021-10-26 16:32:13 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-10-26 16:32:13 +0800 |
commit | 9dec93315173999c4fb9ab5a0e57909eb5e7fd8b (patch) | |
tree | 042fff007fc3d0959146f131f425b9626448718e /src/ui/controls/TextHostControlService.cpp | |
parent | 397843cda9e4161d3e92d8797f8012f478ce64f0 (diff) | |
download | cru-9dec93315173999c4fb9ab5a0e57909eb5e7fd8b.tar.gz cru-9dec93315173999c4fb9ab5a0e57909eb5e7fd8b.tar.bz2 cru-9dec93315173999c4fb9ab5a0e57909eb5e7fd8b.zip |
...
Diffstat (limited to 'src/ui/controls/TextHostControlService.cpp')
-rw-r--r-- | src/ui/controls/TextHostControlService.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/ui/controls/TextHostControlService.cpp b/src/ui/controls/TextHostControlService.cpp index 2f096126..2233d1e6 100644 --- a/src/ui/controls/TextHostControlService.cpp +++ b/src/ui/controls/TextHostControlService.cpp @@ -68,14 +68,13 @@ void TextHostControlService::SetText(String text, bool stop_composition) { SyncTextRenderObject(); } -void TextHostControlService::InsertText(gsl::index position, - std::u16string_view text, +void TextHostControlService::InsertText(gsl::index position, StringView text, bool stop_composition) { if (!Utf16IsValidInsertPosition(this->text_, position)) { log::TagError(log_tag, u"Invalid text insert position."); return; } - this->text_.insert(this->text_.cbegin() + position, text.begin(), text.end()); + this->text_.insert(this->text_.cbegin() + position, text); if (stop_composition) { CancelComposition(); } @@ -224,7 +223,7 @@ void TextHostControlService::AbortSelection() { SetSelection(GetCaretPosition()); } -void TextHostControlService::ReplaceSelectedText(std::u16string_view text) { +void TextHostControlService::ReplaceSelectedText(StringView text) { DeleteSelectedText(); InsertText(GetSelection().GetStart(), text); SetSelection(GetSelection().GetStart() + text.size()); @@ -344,9 +343,7 @@ void TextHostControlService::GainFocusHandler( input_method_context->CompositionEndEvent()->AddHandler(sync); input_method_context_event_guard_ += input_method_context->TextEvent()->AddHandler( - [this](const std::u16string_view& text) { - this->ReplaceSelectedText(text); - }); + [this](StringView text) { this->ReplaceSelectedText(text); }); host::WindowHost* window_host = control_->GetWindowHost(); if (window_host) |