aboutsummaryrefslogtreecommitdiff
path: root/demos/input_method/main.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-07-05 23:06:02 +0800
committercrupest <crupest@outlook.com>2020-07-05 23:06:02 +0800
commit5c805e494425a88da1813902b1ad8a1ab351e30d (patch)
treebe3cfd96dcac19db3e256d610d48b5083c489a6c /demos/input_method/main.cpp
parentbbec59718bf8a824583869126762013112f8e568 (diff)
downloadcru-5c805e494425a88da1813902b1ad8a1ab351e30d.tar.gz
cru-5c805e494425a88da1813902b1ad8a1ab351e30d.tar.bz2
cru-5c805e494425a88da1813902b1ad8a1ab351e30d.zip
...
Diffstat (limited to 'demos/input_method/main.cpp')
-rw-r--r--demos/input_method/main.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/demos/input_method/main.cpp b/demos/input_method/main.cpp
index b109f5e7..215eba16 100644
--- a/demos/input_method/main.cpp
+++ b/demos/input_method/main.cpp
@@ -31,19 +31,19 @@ int main() {
auto target_clause_brush = graph_factory->CreateSolidColorBrush();
target_clause_brush->SetColor(colors::blue);
- std::shared_ptr<IFont> font = graph_factory->CreateFont("等线", 30);
+ std::shared_ptr<IFont> font = graph_factory->CreateFont(u"等线", 30);
float window_width = 10000;
auto prompt_text_layout =
graph_factory->CreateTextLayout(font,
- "Alt+F1: Enable IME\n"
- "Alt+F2: Disable IME\n"
- "Alt+F3: Complete composition.\n"
- "Alt+F4: Cancel composition.");
+ u"Alt+F1: Enable IME\n"
+ u"Alt+F2: Disable IME\n"
+ u"Alt+F3: Complete composition.\n"
+ u"Alt+F4: Cancel composition.");
std::optional<CompositionText> optional_composition_text;
- std::string committed_text;
+ std::u16string committed_text;
window->ResizeEvent()->AddHandler(
[&prompt_text_layout, &window_width](const Size& size) {
@@ -60,9 +60,9 @@ int main() {
const auto anchor_y = prompt_text_layout->GetTextBounds().height;
auto text_layout = graph_factory->CreateTextLayout(
- font,
- committed_text +
- (optional_composition_text ? optional_composition_text->text : ""));
+ font, committed_text + (optional_composition_text
+ ? optional_composition_text->text
+ : u""));
text_layout->SetMaxWidth(window_width);
if (optional_composition_text) {
@@ -123,7 +123,7 @@ int main() {
});
input_method_context->TextEvent()->AddHandler(
- [window, &committed_text](const std::string_view& c) {
+ [window, &committed_text](const std::u16string_view& c) {
committed_text += c;
window->RequestRepaint();
});