#[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
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<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Event, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Event, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Event
impl Serialize for Event
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.