Skip to content

joshprk/vtui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

249 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[vtui]

A simple terminal UI framework.

Crates.io Version

About · Usage
Documentation

About

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.

Usage

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);
}

About

A simple terminal UI framework

Resources

License

Stars

Watchers

Forks

Packages

No packages published