mirror of
https://github.com/storytold/winit.git
synced 2026-11-21 03:50:41 +01:00
Input methods that correct the text around the cursor, such as Vietnamese engines and predictive keyboards, need the field's text (text-input-v3 `set_surrounding_text`) and a way to delete part of it (`delete_surrounding_text`). winit master added both with new core types and an `Ime::DeleteSurrounding` event; winit 0.30's `Ime` enum is exhaustive, so they come here as a Wayland extension instead: - `WindowExtWayland::set_ime_surrounding_text(text, cursor, anchor)` clamps the byte offsets to character boundaries and cuts text over the protocol's 4000 bytes around the cursor and selection. Enabling a text input sends it again with the purpose and cursor area, which enabling resets; disallowing IME forgets it. - A deletion goes out with the `Ime::Commit` of the same input method update, an empty one if the update has no commit. `WindowExtWayland::take_ime_delete_surrounding` returns it while that commit is handled, so the application deletes after removing the preedit and before inserting the text, in text-input-v3's order. Co-authored-by: DorotaC <43449960+dcz-self@users.noreply.github.com>