tui-world
⚠️ Work in Progress
A state and event management library for TUIs built with ratatui.
Core Concepts
- World - A container that holds application state
- Keybindings - Key binding registry with built-in help display
- Focus - Tracks which widget is active
- Pointer - Tracks widget areas and handles mouse click/drag/up events
Example
use KeyCode;
use *;
const GLOBAL_ID: WidgetId = WidgetId;
const WIDGET_ID: WidgetId = WidgetId;
// Store state in world
world.insert;
// Register keybindings
let kb = world.;
kb.bind;
// Check focus
if world..is_focused
// Register click handlers
world..on_click;
// Register widgets area in render function
world..set;
// Handle events with global + focused widget
let mut active = vec!;
if let Some = world..id
Key.handle;
Mouse.handle;
See examples/todo and examples/help.rs for complete examples.
License
MIT