vtui is a framework for modern terminal applications.
It provides basic building blocks that often come up as boilerplate, from a high-performance runtime to complex UI features like scrolling.
An overview of the features is provided in this blog post.
use ratatui::style::Style;
use vtui::{events::*, input::*, prelude::*};
#[component]
fn App(c: Component) -> Node {
let mut clicks = c.state(0);
c.draw(move |canvas| {
let text = format!("Clicks: {}", *clicks.read());
canvas.text(0, 0, text, Style::default());
});
c.listen::<MouseDown>(move |event| {
if event.button == MouseButton::Left {
clicks.set(|c| *c += 1);
}
});
c.listen::<KeyPress>(|event| {
if event.key == KeyCode::Char('q') {
event.request_shutdown();
}
});
c.compose(|_| {})
}
fn main() {
vtui::launch(App);
}