diff options
author | crupest <crupest@outlook.com> | 2021-10-22 21:42:45 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-10-22 21:42:45 +0800 |
commit | 3e84cf013b31c52405a76b8e8778a5991d096290 (patch) | |
tree | 4d3b2d2ef5a9625c55f798d88281073e806ee83f /src/osx/gui/Window.mm | |
parent | ed640ca9e3c7482856a0248ea38adafc86a7d4c8 (diff) | |
download | cru-3e84cf013b31c52405a76b8e8778a5991d096290.tar.gz cru-3e84cf013b31c52405a76b8e8778a5991d096290.tar.bz2 cru-3e84cf013b31c52405a76b8e8778a5991d096290.zip |
...
Diffstat (limited to 'src/osx/gui/Window.mm')
-rw-r--r-- | src/osx/gui/Window.mm | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/osx/gui/Window.mm b/src/osx/gui/Window.mm index 1eb97b07..84cc1145 100644 --- a/src/osx/gui/Window.mm +++ b/src/osx/gui/Window.mm @@ -487,11 +487,13 @@ IInputMethodContext* OsxWindow::GetInputMethodContext() { return p_->input_metho s = CFAttributedStringGetString(as); } - cru::log::TagDebug( - u"CruView", - u"Received setMarkedText string: {}, selected range: ({}, {}), replacement range: ({}, {}).", - Convert(s), selectedRange.location, selectedRange.length, replacementRange.location, - replacementRange.length); + auto ss = Convert(s); + + cru::log::TagDebug(u"CruView", + u"Received setMarkedText string: {}, selected range: ({}, {}), " + u"replacement range: ({}, {}).", + ss, selectedRange.location, selectedRange.length, replacementRange.location, + replacementRange.length); if (_input_context_text == nil) { _input_context_text = [[NSMutableAttributedString alloc] init]; @@ -506,8 +508,10 @@ IInputMethodContext* OsxWindow::GetInputMethodContext() { return p_->input_metho cru::platform::gui::CompositionText composition_text; composition_text.text = Convert((CFStringRef)[_input_context_text string]); - composition_text.selection.position = replacementRange.location + selectedRange.location; - composition_text.selection.count = selectedRange.length; + composition_text.selection.position = ss.IndexFromCodePointToCodeUnit(selectedRange.location); + composition_text.selection.count = + ss.IndexFromCodePointToCodeUnit(selectedRange.location + selectedRange.length) - + composition_text.selection.position; _input_context_p->SetCompositionText(composition_text); _input_context_p->RaiseCompositionEvent(); } |