pub struct Composer { /* private fields */ }Expand description
Turns key transitions into characters, holding the state a layout needs.
Owns the dead-key latch, Caps Lock, Num Lock and the AltGr level, because all four are sequences rather than properties of a single event and none of them can be recovered from one keystroke in isolation.
Implementations§
Source§impl Composer
impl Composer
Sourcepub fn new(layout: &'static Layout) -> Self
pub fn new(layout: &'static Layout) -> Self
A composer for layout, with Num Lock on as a keyboard reports it after a
cold boot on most firmware.
Sourcepub fn set_layout(&mut self, layout: &'static Layout)
pub fn set_layout(&mut self, layout: &'static Layout)
Switches layout, abandoning any half-finished composition.
Sourcepub const fn pending_dead(&self) -> Option<char>
pub const fn pending_dead(&self) -> Option<char>
The mark waiting for a base character, if any.
Sourcepub fn feed(
&mut self,
code: KeyCode,
state: ElementState,
modifiers: Modifiers,
) -> Composed
pub fn feed( &mut self, code: KeyCode, state: ElementState, modifiers: Modifiers, ) -> Composed
Feeds one key transition and returns what it types.
modifiers is the state including this key, as the translator reports it.
Sourcepub fn output_for(&self, code: KeyCode, shift: bool) -> Output
pub fn output_for(&self, code: KeyCode, shift: bool) -> Output
What one position types right now, given whether Shift is held.
The composer’s own answer, including Caps Lock and the third level from its state — so an on-screen keyboard can letter a key with exactly what pressing it would produce. Caps Lock inverts shift for letters only, and asking here is how a keyboard gets that right without repeating the rule.