Skip to main content

Module interaction

Module interaction 

Source
Expand description

Reusable keyboard-interaction helpers for A2UI TUI applications.

The gallery app (a2ui::gallery::app) was the first place a complete, validated event-dispatch pipeline was implemented. Several example programs duplicate that ~40-line dispatch+apply boilerplate (and a couple carry bugs where an EventResult is dropped). This module extracts the gallery’s semantics into small public functions so any app can replace its hand-rolled copy with a single call to handle_key (or the granular pieces).

The logic here mirrors gallery::app::GalleryApp’s dispatch_event_to_focused / process_event_result methods exactly — it does not introduce new behavior.

Functions§

apply_event_result
Apply an EventResult produced by a component to the processor’s state.
dispatch_to_focused
Dispatch an already-built InputEvent to the focused component and return whatever EventResult it produces.
handle_key
The one-call keyboard pipeline: map a KeyCode, dispatch it to the focused component, and apply the resulting EventResult.
map_key_code
Map a crossterm KeyCode to the framework-agnostic InputKey.