Expand description
Terminal event polling and parsing.
Provides low-level access to terminal input events including keyboard, mouse, focus, and resize events.
§Polling
Use poll to wait for input with an optional timeout:
use extui::event::{poll, Polled};
use std::time::Duration;
let result = poll(&std::io::stdin(), Some(Duration::from_millis(100)))?;
if result == Polled::ReadReady {
// Input is available
}§Parsing
The Events struct buffers and parses input into Event values:
use extui::event::{Events, Event, KeyCode};
let mut events = Events::default();
events.read_from(&std::io::stdin())?;
while let Some(event) = events.next(true) {
match event {
Event::Key(key) => println!("Key: {:?}", key.code),
Event::Mouse(mouse) => println!("Mouse: {:?}", mouse.kind),
Event::Resized => println!("Terminal resized"),
_ => {}
}
}§Signal Handling
The polling submodule provides global waker initialization for handling
SIGWINCH (resize) and termination signals.
Modules§
Structs§
- Events
- Buffered terminal event reader and parser.
- KeyEvent
- Represents a key event.
- KeyEvent
State - Represents extra state about the key event.
- KeyModifiers
- Represents key modifiers (shift, control, alt, etc.).
- Keyboard
Enhancement Flags - Represents special flags that tell compatible terminals to add extra information to keyboard events.
- Mouse
Event - Represents a mouse event.
Enums§
- Event
- Represents an event.
- KeyCode
- Represents a key.
- KeyEvent
Kind - Represents a keyboard event kind.
- Mouse
Button - Represents a mouse button.
- Mouse
Event Kind - A mouse event kind.
- Polled
- Result of a polling operation.
Functions§
- poll
- Polls a file descriptor for read readiness using the global waker.
- poll_
with_ custom_ waker - Polls a file descriptor for read readiness with a custom waker.