gtcaca 0.0.1

Safe, idiomatic Rust bindings for GTCaca, a libcaca-based terminal UI toolkit
docs.rs failed to build gtcaca-0.0.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

gtcaca

Safe, idiomatic Rust bindings for GTCaca, a libcaca-based terminal UI toolkit written in C.

This is the high-level crate. It wraps the raw FFI in gtcaca-sys with widget handles, builder-style constructors, and closure-based key callbacks. The whole toolkit is single-threaded (one global context, one blocking event loop), so the context and every widget are !Send/!Sync.

Requirements

libcaca development files, found at build time via pkg-config:

Platform Install
Debian/Ubuntu apt install libcaca-dev pkg-config
Fedora/RHEL dnf install libcaca-devel pkgconf-pkg-config
macOS brew install libcaca pkg-config

Example

use gtcaca::{key, Application, Button, Entry, Gtcaca, Label, Window};

fn main() -> Result<(), gtcaca::Error> {
    let ctx = Gtcaca::init()?;                 // opens the terminal display

    let app = Application::new(&ctx, "Demo");
    let win = Window::fullscreen(&app, None);

    Label::new(&win, "Name:", 5, 2);
    let entry = Entry::new(&win, 12, 2, 20);
    let quit = Button::new(&win, "Quit", 5, 4);

    quit.on_key(|k| {
        if k == key::RETURN { gtcaca::quit(); true } else { false }
    });

    ctx.run();                                 // blocking loop
    println!("you typed: {}", entry.text());
    Ok(())
}

Run the bundled demo in a real terminal:

cargo run --example hello

Coverage

The safe API currently wraps the core loop and the common widgets (application, window, label, button, entry, checkbox), and is growing. The entire C API — all ~490 functions — is available today, unsafe, via the re-exported gtcaca_sys FFI:

use gtcaca::ffi;
unsafe { /* call any gtcaca_* function directly */ }

License

Public Domain (Unlicense), same as GTCaca.