Skip to content

forattini-dev/tuiuiu.rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐦 Tuiuiu.rs

Terminal UI Framework — Rust Edition

Build beautiful, reactive terminal apps with blazing-fast performance.
Zero dependenciesSignal-basedFlexbox layoutNative speedMemory safe
50+ components. Pure Rust. No unsafe chaos. Maximum performance.

Crates.io Downloads Rust License Zero Deps

📖 JS Docs · 📦 API Spec · 🚀 Início Rápido · 🦀 Rust API · ⚡ Performance

* Only libc for raw terminal mode


📚 Referência oficial (JS)

tuiuiu.rs nasce da mesma linguagem conceitual de tuiuiu.js. Use estes links da origem como fonte principal da API:

🔗 Links rápidos da origem


Quick Start

# Cargo.toml
[dependencies]
tuiuiu = "0.1"
use tuiuiu::prelude::*;

fn main() {
    let app = render(counter);
    app.wait_until_exit();
}

fn counter() -> impl Component {
    let (count, set_count) = create_signal(0);

    use_input(move |key| match key {
        Key::Up => set_count.update(|c| *c += 1),
        Key::Down => set_count.update(|c| *c -= 1),
        Key::Escape => app::exit(),
        _ => {}
    });

    Box::new()
        .border(BorderStyle::Round)
        .padding(1)
        .children([
            Text::new("🐦 Tuiuiu Counter").color(Color::Cyan).bold(true),
            Text::new(move || format!("Count: {}", count.get())),
            Text::new("↑/↓: change • Esc: exit").color(Color::Gray).dim(true),
        ])
}
cargo run

What's Inside

Category Components
Core Signals, Flexbox layout, Focus management, Event system
Primitives Box, Text, Spacer, Newline, Fragment, Divider, Canvas
Atoms Button, TextInput, Switch, Slider, Spinner, ProgressBar
Molecules Select, MultiSelect, RadioGroup, Autocomplete, Table, Tabs, Tree, Calendar, CodeBlock, Markdown
Organisms Modal, CommandPalette, DataTable, FileManager, SplitPanel
Templates AppShell, Page, Header, StatusBar, VStack, HStack
Data Viz BarChart, LineChart, Sparkline, Heatmap, Gauge

Rust API

⚡ Signals

Fine-grained reactivity — only what changes gets updated.

use tuiuiu::prelude::*;

let (count, set_count) = create_signal(0);
let doubled = create_memo(move || count.get() * 2);

create_effect(move || {
    println!("Count: {}, Doubled: {}", count.get(), doubled.get());
});

set_count.set(5);  // → "Count: 5, Doubled: 10"

// Batch multiple updates
batch(|| {
    set_count.set(1);
    set_count.set(2);
    set_count.set(3);
}); // Only one render!

📦 Flexbox Layout

CSS Flexbox model for terminals.

Box::new()
    .flex_direction(FlexDirection::Row)
    .justify_content(JustifyContent::SpaceBetween)
    .align_items(AlignItems::Center)
    .gap(2)
    .padding(1)
    .border(BorderStyle::Round)
    .children([
        Text::new("Left").color(Color::Blue),
        Text::new("Center"),
        Text::new("Right").color(Color::Red),
    ])

🎨 Components

use tuiuiu::molecules::*;

// Select dropdown
Select::new()
    .items(["Option A", "Option B", "Option C"])
    .selected(0)
    .build()

// Table with columns
Table::new()
    .columns([
        Column::new("Name").width(20),
        Column::new("Age").width(10).align(Align::Right),
    ])
    .rows([
        vec!["Alice".into(), "30".into()],
        vec!["Bob".into(), "25".into()],
    ])
    .build()

// Tree view
Tree::new()
    .nodes([
        TreeNode::folder("src").expanded(true).children([
            TreeNode::file("main.rs"),
            TreeNode::file("lib.rs"),
        ]),
    ])
    .build()

// Calendar
Calendar::new()
    .date(2025, 1)
    .selected(24)
    .today(2025, 1, 24)
    .build()

// Charts
Sparkline::new().data([1.0, 4.0, 2.0, 8.0, 5.0]).build()
Gauge::new().value(75.0).max(100.0).label("CPU").build()

⌨️ Input Handling

// Keyboard
use_input(|key| match key {
    Key::Char('q') => app::exit(),
    Key::Up => { /* ... */ },
    Key::Enter => { /* ... */ },
    _ => {}
});

// With modifiers
use_hotkeys(|key, mods| {
    if mods.ctrl && key == Key::Char('c') {
        app::exit();
    }
});

// Mouse
use_mouse(|event| match event.kind {
    MouseEventKind::Click(MouseButton::Left) => {
        println!("Click at ({}, {})", event.x, event.y);
    },
    _ => {}
});

Feature Flags

Pick what you need — unused code is not compiled.

# Full (default)
tuiuiu = "0.1"

# Minimal core only
tuiuiu = { version = "0.1", default-features = false, features = ["core"] }

# Just what you need
tuiuiu = { version = "0.1", default-features = false, features = ["molecules"] }
Feature Contents Includes
full Everything atoms, molecules, organisms, templates, themes
core Signals, layout, renderer
primitives Box, Text, Spacer, etc. core
atoms Button, Input, Spinner, etc. primitives
molecules Select, Table, Tabs, etc. atoms
organisms Modal, DataTable, etc. molecules
templates AppShell, Page, etc. organisms
themes Dark, Light, Monokai, etc.

Performance

Why Rust?

Metric tuiuiu.rs tuiuiu.js
Startup time ~1ms ~50ms
Memory usage ~2MB ~30MB
Binary size ~500KB N/A
Dependencies 0* 0
Type safety Compile-time Runtime

* Only libc for raw terminal mode

Examples

# Clone the repo
git clone https://github.com/forattini-dev/tuiuiu.rs
cd tuiuiu.rs

# Run examples
cargo run --example counter      # Simple counter
cargo run --example dashboard    # Full dashboard
cargo run --example 03_molecules # Component showcase

Comparison

Feature tuiuiu.rs tuiuiu.js Ratatui
Signal reactivity
Flexbox layout
50+ components
Zero deps ✅*
Mouse support
Native binary
Memory safe

Documentation

📖 For full documentation, concepts, and detailed API reference, see tuiuiu.js — the authoritative source.

Topic Description
Quick Start Get up and running
Signals Reactive state management
Layout Flexbox for terminals
Components All 50+ components
Mouse Click, hover, scroll
Charts Data visualization

Numbers

Metric Value
Components 50+
Dependencies 0*
Hooks 10
Border styles 9
Named colors 18
Feature flags 8
Binary size ~500KB

Why "Tuiuiu"?

The Tuiuiu (Jabiru mycteria) is a majestic Brazilian bird — the tallest flying bird in South America. Just like this bird stands out in its environment, Tuiuiu stands out in the terminal UI landscape: elegant, powerful, and distinctly Brazilian.

🇧🇷 Made with ❤️ in Brazil

License

MIT License


tuiuiu.js — JavaScript/TypeScript version • tuiuiu.rs — Rust version (you are here)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages