Enum Event

Source
pub enum Event {
    KeyPress {
        modifiers: Modifiers,
        key: KeyInput,
        is_repeat: bool,
    },
    KeyRelease {
        modifiers: Modifiers,
        key: KeyInput,
    },
    Mouse {
        device_id: u16,
        modifiers: Modifiers,
        buttons: mmask_t,
        x: u32,
        y: u32,
    },
    PasteBegin,
    PasteEnd,
    Resize {
        width: u32,
        height: u32,
    },
}
Expand description

A single event generated by a terminal. Simple text input, whether arriving via a pipe, a paste command, or typing, will be represented with KeyPress events. These events are inherently lossy and have different levels of support on different terminals. Depending on the use case, certain modifier keys may just never be recorded, key repeats will be indistinguishable from orignal presses, pastes may not be bracketed, and key releases may never be registered, among other failures.

Variants§

§

KeyPress

A single typing action by the user, input from stdin. Except between PasteBegin and PasteEnd events, these typically will not be control characters, as those are heuristically decoded into modifier keys combined with printable characters.

Fields

§modifiers: Modifiers
§is_repeat: bool

Whether this keypress comes from holding down a key

§

KeyRelease

This is kept as a separate event from KeyPress as it usually does not want to be handled in the same way and is supported by very few terminals, making it easy to miss in testing.

Fields

§modifiers: Modifiers
§

Mouse

A motion or click of a mouse button. Modifiers typically are only be available on button state changes, not mouse motion.

Fields

§device_id: u16
§modifiers: Modifiers
§buttons: mmask_t
§

PasteBegin

An indication that the following events occur purely as result of the user pasting from some unknown location that should be conservatively considered malicious. Applications should filter out control commands that happen during a paste, only considering the input as raw, unescaped text.

§

PasteEnd

The marker indicating a return to normal user interaction.

§

Resize

The window has been resized and the application may want to rerender to fit the new sizee.

Fields

§width: u32
§height: u32

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Copy for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.