winit: Both `_selected_range` and `_replacement_range` parameters are ignored in NSTextInputClient implementation.
Description
TypeAlias “ICB” = “Inline Composition Buffer” = “Inline PreEdit”
Both _selected_range and _replacement_range parameters are ignored in NSTextInputClient implementation. This causes an issue that these parameters sent from IME to IMKTextInput APIs are completely neglected:
These parameters are crucial for some IMEs utilizing nested inline composition buffers (i.e. nested preedits). E.g. The Traditional Chinese Zhuyin IME shipped in macOS. In-ICB cursor is of vital necessity for these IMEs.
Note: These parameters are UTF16 ranges. Apple introduced these APIs in macOS 10.5 Leopard. See the IMKTextInput API header for more intelligence: https://github.com/phracker/MacOSX-SDKs/blob/041600eda65c6a668f66cb7d56b7d1da3e8bcc93/MacOSX10.5.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/IMKInputSession.h#L74-L85
I was about to send a PR to fix this issue. However, I have to figure out one thing:
In src/events.rs, search pub enum Ime and find Preedit(String, Option<(usize, usize)>),. I have doubts about this property: Are these cursor positions supposed to be utf8 or utf16? This has to be figured out prior to patching this issue.
macOS version
ProductName: macOS
ProductVersion: 14.4.1
BuildVersion: 23E224
Winit version
Master Branch 44aabddd
About this issue
- Original URL
- State: open
- Created 3 months ago
- Comments: 16 (7 by maintainers)
Yeah, selected range matches the
start/endcursor APIs we have pretty much, as what I can say, so shouldn’t be that hard, I guess.Yeah, so you need an API to indicate such range, and then
deletesend new text, that’s pretty much how it’s on Wayland. So this API could be left untouched for awhile until we have a separateWindow::set_ime_surrounding_textor similar APIs. Though, I won’t stop you from drafting one.Ah, I think I got what you mean. I’m pretty sure it works by indicating surrounding text around, so you can not really do that without adding a new API. Such API was discussed in the past, but that’s about it.
@ShikiSuen maybe you need a special key on macOS, but on linux I just have a binding to convert between 漢字 and kana. Though, I’m not sure there’s a way to trigger the convert just by starting selection, at least I’ve never seen how to.
It’s an offset into utf8’s byte string representation, because
Stringisutf8.Everything is utf8, it’s also documented like that.