Skip to main content

KeyQueue

Struct KeyQueue 

Source
pub struct KeyQueue { /* private fields */ }
Expand description

Key presses in emulated time: active keys are down in the machine; pending presses (or letters, expanded when their turn comes) wait for a fast-typed predecessor to be released first.

Implementations§

Source§

impl KeyQueue

Source

pub fn new(model: Model) -> Self

An empty queue for model’s keys and typing rules.

Source

pub fn has_key(&self, name: &str) -> bool

Whether the model has a key called name (its drawn layout).

Source

pub fn busy(&self) -> bool

Keys are down or presses are queued: the run must keep its slices short and pump.

Source

pub fn held(&self) -> bool

A key the user pressed is down and not yet released: its hold must run at 1x, or a tap at a higher speed reads as a long hold (the 42S shows NULL after about a second).

Source

pub fn press(&mut self, name: &str) -> bool

Queue a press of name (held until KeyQueue::release); false if the model has no such key.

Source

pub fn press_shifted(&mut self, name: &str, shift: &str) -> bool

Queue a press of name held until KeyQueue::release, after a tap of shift key shift unless that shift is on when the press’s turn comes: decided then, not now, so a shift still queued or one a queued key will use up counts. False if the model has no such key or shift is not one of its shift keys.

Source

pub fn type_letter(&mut self, ch: char) -> bool

Queue ch typed through the calculator’s alpha mode; false if the model has no key for it.

Source

pub fn type_keys(&mut self, names: &[&str])

Queue full presses of names, one after the other (unknown names are skipped).

Source

pub fn release(&mut self, name: &str)

Release the newest press of name that the user still holds.

Source

pub fn release_held(&mut self)

Release every held key once it has been down long enough (the window lost the focus).

Source

pub fn clear(&mut self)

Drop the queue and forget every key; the machine’s keys stay as they are (Emulator::release_keys releases both).

Source

pub fn down(&self) -> Vec<&'static str>

The keys down now, for the view.

Source

pub fn presses_started(&self) -> u64

Presses the machine took since the queue was made (each key of a typed letter counts, alpha too).

Source

pub fn take_errors(&mut self) -> Vec<Error>

Errors collected since the last call.

Source

pub fn pump(&mut self, kb: &mut impl Keyboard)

Release keys held long enough, then start queued presses.

Trait Implementations§

Source§

impl Clone for KeyQueue

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KeyQueue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.