Crates.io | rustubble |
lib.rs | rustubble |
version | 0.1.4 |
source | src |
created_at | 2024-04-24 19:25:22.470257 |
updated_at | 2024-08-31 20:19:33.850874 |
description | A brief description of what your crate does. |
homepage | |
repository | https://github.com/warpy-ai/rustubble |
max_upload_size | |
id | 1219430 |
size | 3,474,316 |
Beautifull components for your terminal.
This project aims to provide a set of components that can be used in your terminal applications.
The TextInput
component is a versatile and customizable input field designed for terminal-based applications using Rust. It supports Unicode, dynamic input handling, and comes with a variety of customization options to enhance user interaction.
A text area field, akin to an in HTML. Allows for input that spans multiple lines. Supports unicode, pasting, vertical scrolling when the value exceeds the width and height of the element, and many customization options.
The Spinner Component provides an easy-to-use and customizable loading animation for CLI applications written in Rust, utilizing the Crossterm library to handle terminal output. This component allows for a dynamic visual display during long-running operations.
You can customize the spinner style and message at initialization. Here's how you can specify a different spinner style:
let spinner = Spinner::new("Dots2", "Loading resources...");
Available styles include Dots
, Dots2
, Dots3
, etc. Refer to the spinner_data.rs
file for a complete list of available styles and their configurations.
The spinner styles are predefined in a lazy_static
block within the spinner_data.rs
file. Each style is represented by a unique key and includes an array of frames and an interval timing in milliseconds.
Here’s an excerpt from the spinner styles definition:
lazy_static! {
static ref SPINNERS: HashMap<String, SpinnerData> = {
hashmap! {
"Dots".into() => SpinnerData {
frames: vec!["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"],
interval: 80
},
// Additional spinner styles...
}
};
}
The Table
component allows you to create a table in your terminal application using Rust. The component provides a flexible and customizable way to display data in a table format.
You can set the padding, the number of visible lines and the scroll offset of the table. Here's an example of how you can customize the table:
let mut table = Table::new(headers, data, 0, 3, 7);
You can set the position of the table on the view when rendering:
let (x, y) = (5, 5);
handle_table(&mut table, x, y);
The ProgressBar
component is a versatile and customizable loading animation for CLI applications written in Rust. This component allows for a dynamic visual display during long-running operations.
The ViewPort
component allows you to create a viewport in your terminal application. The component provides a flexible and customizable way to display data in a String
view format
A simple component for counting down.
A simple component for counting up.
A list component, build with ratatui.
A menu list component, build with ratatui.
Contributions are welcome! If you have suggestions for improving the spinner or adding new styles, please open an issue or pull request on our GitHub repository.
This project is licensed under the Apache License - see the LICENSE file for details.