#[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).
This event does not resize anything on its own: the receiving app must call
Terminal::resize with these dimensions to resize the
terminal’s own grid buffers. A windowed backend’s own reported
Output::size may already reflect the new dimensions
by the time this event is polled, but that does not substitute for resizing the grid.
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-widgets’ 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-widgets’ 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/Eq/Hash (a Box<dyn Any> could not derive
any of those) 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.