#[non_exhaustive]pub enum Event {
Key(KeyEvent),
Mouse(MouseEvent),
Resize(u32, u32),
Paste(String),
FocusGained,
FocusLost,
}Expand description
A terminal input event.
Produced each frame by the run loop and passed to your UI closure via
crate::Context. Use the helper methods on Context (e.g., key(),
key_code()) rather than matching on this type directly.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Key(KeyEvent)
A keyboard event.
Mouse(MouseEvent)
A mouse event (requires mouse: true in crate::RunConfig).
Resize(u32, u32)
The terminal was resized to the given (columns, rows).
Paste(String)
Pasted text (bracketed paste). May contain newlines.
FocusGained
The terminal window gained focus.
FocusLost
The terminal window lost focus. Used to clear hover state.
Implementations§
Source§impl Event
impl Event
Sourcepub fn key_mod(code: KeyCode, modifiers: KeyModifiers) -> Self
pub fn key_mod(code: KeyCode, modifiers: KeyModifiers) -> Self
Create a key press event with custom modifiers.
Sourcepub fn mouse_click(x: u32, y: u32) -> Self
pub fn mouse_click(x: u32, y: u32) -> Self
Create a left mouse click event at (x, y).
Sourcepub fn mouse_move(x: u32, y: u32) -> Self
pub fn mouse_move(x: u32, y: u32) -> Self
Create a mouse move event at the given position.
Sourcepub fn scroll_down(x: u32, y: u32) -> Self
pub fn scroll_down(x: u32, y: u32) -> Self
Create a scroll down event at the given position.
Sourcepub fn key_release(c: char) -> Self
pub fn key_release(c: char) -> Self
Create a key release event for a character.
Sourcepub fn as_mouse(&self) -> Option<&MouseEvent>
pub fn as_mouse(&self) -> Option<&MouseEvent>
Returns the mouse event data if this is a Mouse variant.