#[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.