Skip to main content

translate_ime

Function translate_ime 

Source
pub fn translate_ime(ime: Ime) -> Option<Event>
Expand description

Translates a winit Ime event into an Event.

Only Ime::Commit carries a complete, atomic block of text: the same shape as the crossterm backend’s Event::Paste (see its handling of crossterm::event::Event ::Paste in crates/crossterm/src/lib.rs), so a commit is mapped to Event::Paste rather than adding a new Event variant: Event is #[non_exhaustive], so a new variant would be backward-compatible for exhaustive-matching consumers (per issue #267), but there is no need for a new one when an existing variant already fits the shape of the data. Ime::Enabled, Ime::Preedit (in-progress composition, not yet committed), and Ime::Disabled have no existing-Event equivalent and are dropped: an app that wants live preedit rendering is out of scope for this landable-sized change (see issue #296). An empty commit (Ime::Commit(String::new())) is also dropped: winit can send an empty commit as part of clearing composition state, and forwarding it would deliver a spurious empty paste.