aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-10-26 16:32:13 +0800
committercrupest <crupest@outlook.com>2021-10-26 16:32:13 +0800
commit9dec93315173999c4fb9ab5a0e57909eb5e7fd8b (patch)
tree042fff007fc3d0959146f131f425b9626448718e /src/ui/controls
parent397843cda9e4161d3e92d8797f8012f478ce64f0 (diff)
downloadcru-9dec93315173999c4fb9ab5a0e57909eb5e7fd8b.tar.gz
cru-9dec93315173999c4fb9ab5a0e57909eb5e7fd8b.tar.bz2
cru-9dec93315173999c4fb9ab5a0e57909eb5e7fd8b.zip
...
Diffstat (limited to 'src/ui/controls')
-rw-r--r--src/ui/controls/TextBlock.cpp8
-rw-r--r--src/ui/controls/TextHostControlService.cpp11
2 files changed, 7 insertions, 12 deletions
diff --git a/src/ui/controls/TextBlock.cpp b/src/ui/controls/TextBlock.cpp
index 0724edcf..16fd5df6 100644
--- a/src/ui/controls/TextBlock.cpp
+++ b/src/ui/controls/TextBlock.cpp
@@ -10,7 +10,7 @@ using render::TextRenderObject;
TextBlock* TextBlock::Create() { return new TextBlock(); }
-TextBlock* TextBlock::Create(std::u16string text, bool selectable) {
+TextBlock* TextBlock::Create(String text, bool selectable) {
auto c = new TextBlock();
c->SetText(text);
c->SetSelectable(selectable);
@@ -38,11 +38,9 @@ render::RenderObject* TextBlock::GetRenderObject() const {
return text_render_object_.get();
}
-std::u16string TextBlock::GetText() const { return service_->GetText(); }
+String TextBlock::GetText() const { return service_->GetText(); }
-void TextBlock::SetText(std::u16string text) {
- service_->SetText(std::move(text));
-}
+void TextBlock::SetText(String text) { service_->SetText(std::move(text)); }
bool TextBlock::IsSelectable() const { return service_->IsEnabled(); }
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)