Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Basic TUI library in Rust
I've built a basic TUI (text user interface) library in Rust: https://github.com/pjdur/tui.
The library currently supports the following widget types:
It includes event handling for sliders and checkboxes (buttons aren't supported yet), allowing you to respond to user interactions.
Here's a simple example application built with it:
use tui::*;
fn main() -> std::io::Result<()> {
let mut ui = UI::new();
ui.add(WidgetType::Label(Label::new("Choose your ice cream flavours:")));
ui.add(WidgetType::Checkbox(Checkbox::new("Vanilla")));
ui.add(WidgetType::Checkbox(Checkbox::new("Chocolate")));
ui.add(WidgetType::Checkbox(Checkbox::new("Strawberry")));
ui.add(WidgetType::Checkbox(Checkbox::new("Mint")));
ui.add(WidgetType::Checkbox(Checkbox::new("Cookie Dough")));
ui.add(WidgetType::Label(Label::new("Press TAB to switch, SPACE to toggle, ESC to finish")));
let result = run_ui(ui)?;
println!("\nYour ice cream will include:");
for ingredient in result {
println!("- {}", ingredient);
}
Ok(())
}
Feedback or suggestions are welcome.
1 post - 1 participant
🏷️ Rust_feed