Expand description
§weavetui
A simple TUI framework for building elegant and responsive terminal applications.
weavetui is built on top of ratatui and tokio, providing a component-based
architecture that simplifies the development of complex TUIs.
§Features
- Component-Based: Build your UI from reusable components.
- Declarative Macros: Use the
#[component]macro to reduce boilerplate. - Async Event Handling: Powered by
tokiofor non-blocking event processing. - Keybinding System: A simple and flexible keybinding system.
§Getting Started
To get started, add weavetui to your Cargo.toml:
[dependencies]
weavetui = "0.1.0"Then, create a simple application:
use weavetui::prelude::*;
#[component(default)]
struct MyComponent;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut app = App::new([("<q>", "app:quit")], vec![Box::new(MyComponent::default())]);
app.run().await?;
Ok(())
}Modules§
- app
- Application module for
weavetui. - event
- This module defines the
EventandActionenums, which are central to the application’s event-driven architecture.Eventrepresents raw input from the terminal or internal application occurrences, whileActionrepresents a processed command that can be dispatched and handled by components. - keyboard
- This module provides utilities for handling keyboard input, including parsing key event strings into
KeyEventsequences and managing keybindings for the application. It allows for flexible definition and lookup of actions based on user input. - prelude
- A prelude for
weavetuiapplications. - tui
- This module provides the
Tuistruct, which is responsible for managing the terminal user interface. It handles initialization, event polling, rendering, and cleanup of the terminal, acting as the bridge between the application logic and thecrossterm/ratatuibackend.
Macros§
- components
- Creates a vector of components from a list of component instances.
- kb
- Creates an array of keybindings.
Traits§
- Component
- The main trait for all UI components in the
weavetuiframework. - Component
Accessor - A trait that provides access to the basic properties of a component.
Attribute Macros§
- component
- Implements the
weavetui_core::Componentandweavetui_core::ComponentAccessortraits for a struct, turning it into aweavetuicomponent.