Crate weavetui

Crate weavetui 

Source
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 tokio for 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 Event and Action enums, which are central to the application’s event-driven architecture. Event represents raw input from the terminal or internal application occurrences, while Action represents 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 KeyEvent sequences and managing keybindings for the application. It allows for flexible definition and lookup of actions based on user input.
prelude
A prelude for weavetui applications.
tui
This module provides the Tui struct, 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 the crossterm/ratatui backend.

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 weavetui framework.
ComponentAccessor
A trait that provides access to the basic properties of a component.

Attribute Macros§

component
Implements the weavetui_core::Component and weavetui_core::ComponentAccessor traits for a struct, turning it into a weavetui component.