Skip to main content

Event

Enum Event 

Source
#[non_exhaustive]
pub enum Event { Key(KeyEvent), Mouse(MouseEvent), Resize(u16, u16), Close, ThemeChanged(SystemTheme), Paste(String), FocusGained, FocusLost, Custom(u64), }
Expand description

Terminal input event.

Does not derive Eq/Hash: MouseEvent does not (its MouseEventKind::Scroll variant’s f32 fields implement neither).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Key(KeyEvent)

Keyboard event.

§

Mouse(MouseEvent)

Mouse event.

§

Resize(u16, u16)

Terminal window resized to the given (cols, rows).

When this event comes from Terminal::poll (or the other Terminal methods that route through it), the grid has already been resized to these dimensions by the time the event reaches your code; the payload is there so the app can react, for example recomputing layout or redrawing. A consumer driving Input::poll_event directly on a raw backend gets no such guarantee and must resize the grid itself.

§

Close

Window closed.

§

ThemeChanged(SystemTheme)

The system’s light/dark color-scheme preference changed, or was determined for the first time at startup.

Only backends with a real source of truth for this emit it: the windowed (winit) backend, on both native and wasm (winit’s web target derives it from the browser’s prefers-color-scheme media query, including live updates). Character-mode backends (crossterm) have no equivalent free API (see the windowed backend’s own docs for why) and never emit this; an app that wants a default should pick one itself rather than waiting for an event that may never arrive.

§

Paste(String)

Pasted text, delivered as a single event rather than individual key presses.

Not emitted by all backends: see each backend’s own docs for whether and how it sources this. Content is forwarded verbatim from the source, including embedded newlines; the receiving app is responsible for any filtering it needs.

§

FocusGained

The terminal or application window gained input focus.

This reflects OS/terminal-level focus, not in-app widget focus (see retroglyph-ui’ focus ring for that).

§

FocusLost

The terminal or application window lost input focus.

This reflects OS/terminal-level focus, not in-app widget focus (see retroglyph-ui’ focus ring for that).

§

Custom(u64)

An application-defined event injected from outside the normal input source (e.g. a network, audio, or timer thread), carrying an opaque tag the app assigns its own meaning to.

Only emitted by backends with a real cross-thread injection point: the windowed (winit) backend’s EventProxy (retroglyph_window::winit::EventProxy::send_event), which forwards the u64 unchanged. The payload is a plain u64 rather than an arbitrary boxed value: it keeps Event cheaply Clone/PartialEq (a Box<dyn Any> could not derive either) and needs no generic parameter threaded through every crate that names Event. Treat it as a correlation id: look up the real payload in whatever shared state or channel the sending thread already placed it in.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

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 Event

Source§

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

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

impl PartialEq for Event

Source§

fn eq(&self, other: &Event) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq 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 UnsafeUnpin 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.