Module event

Module event 

Source
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§

polling

Structs§

Events
Buffered terminal event reader and parser.
KeyEvent
Represents a key event.
KeyEventState
Represents extra state about the key event.
KeyModifiers
Represents key modifiers (shift, control, alt, etc.).
KeyboardEnhancementFlags
Represents special flags that tell compatible terminals to add extra information to keyboard events.
MouseEvent
Represents a mouse event.

Enums§

Event
Represents an event.
KeyCode
Represents a key.
KeyEventKind
Represents a keyboard event kind.
MouseButton
Represents a mouse button.
MouseEventKind
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.