weavetui_core
weavetui_core is the foundational library for the weavetui Text User Interface (TUI) framework. It provides the essential building blocks, traits, and utilities that enable the creation of robust and interactive terminal applications.
✨ Features
- Component Traits (
Component,ComponentAccessor): Defines the fundamental interfaces for all UI components, enabling modular and reusable TUI development.Componenthandles rendering and event processing, whileComponentAccessormanages component properties like name, area, active state, and children. - Event Handling System: Provides a robust and standardized mechanism for processing various input events (keyboard, mouse, paste) and internal events (tick, render), ensuring smooth and responsive user interactions. It leverages
EventandActionenums for clear communication. - TUI Primitives & Utilities: Offers core types and functions for low-level terminal interaction, including managing terminal state, drawing elements with
ratatui, and handling raw input/output through theTuiutility. - Action Dispatch & Management: Facilitates inter-component communication and application-wide state changes through a clear
Actiondispatching system, managed by theAppandComponentManager. - Keybinding System: Integrates a flexible keybinding system (
KeyBindingsandkb!macro) to easily map complex key sequences to specific actions. - Theming Support: Includes
ThemeandThemeManagerfor defining and applying consistent visual styles (colors, styles) across components.
🚀 Getting Started
This crate is primarily designed to be a dependency for weavetui applications and other weavetui-related crates, especially when defining custom components or extending core functionalities. To use it in your project, add the following to your Cargo.toml:
[]
= "0.1.1" # Replace with the latest version or a path/git dependency for development
📚 Usage and Examples
weavetui_core provides the fundamental traits and utilities that define how components behave and interact within the weavetui framework. While you typically implement these traits using the weavetui_derive macro, understanding them is crucial for advanced customization and direct interaction with the core functionalities.
Key components and concepts include:
ComponentandComponentAccessortraits: The contracts for all UI elements.EventandActionenums: Define the types of input and commands processed by the application.KeyBindingsandkb!macro: For declarative and flexible key event mapping.ThemeandThemeManager: For managing application-wide styling.Tui: The low-level terminal interface manager.
Here's a simplified example demonstrating the core Component and ComponentAccessor traits, along with basic event handling and drawing:
use ;
use ;
use BTreeMap;
use UnboundedSender;
// A simple component implementing the core traits
// In a real application, you would instantiate and manage this component
// within a `weavetui` application's `App` and `ComponentManager`.
For more comprehensive and runnable examples, please refer to the examples directory in the main weavetui repository, which showcases how weavetui_core is utilized in a full application context.
🤝 Contributing
We welcome contributions to weavetui_core! Please refer to the main weavetui project's CONTRIBUTING.md for detailed guidelines on how to get involved, report issues, and submit pull requests.
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.