| Crates.io | zaz |
| lib.rs | zaz |
| version | 0.0.3 |
| created_at | 2025-10-19 14:50:43.188731+00 |
| updated_at | 2025-10-19 22:30:53.507695+00 |
| description | cross-platform textual UI toolkit with bindings for Rust, C++, Zig and etc |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1890500 |
| size | 250,963 |
A terminal manipulation library for Rust and C/FFI bindings for other languages.
| Rust | Zig |
|---|---|
![]() |
![]() |
Add to your Cargo.toml:
[dependencies]
zaz = "*"
TODO: I will improve this flow eventually.
To use Zaz in your Zig project:
cargo build --release
cp bindings/zig/zaz.zig your-project/
cp bindings/zig/zaz.h your-project/
cp target/release/libzaz.dylib your-project/ # macOS
# or
cp target/release/libzaz.so your-project/ # Linux
build.zig:const zaz_mod = b.createModule(.{
.root_source_file = b.path("zaz.zig"),
.link_libc = true,
});
zaz_mod.addIncludePath(b.path("."));
const exe = b.addExecutable(.{
.name = "my-app",
.root_source_file = b.path("main.zig"),
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zaz", zaz_mod);
exe.addIncludePath(b.path("."));
exe.addLibraryPath(b.path("."));
exe.linkSystemLibrary("zaz");
exe.linkLibC();
# macOS
DYLD_LIBRARY_PATH=. zig build run
# Linux
LD_LIBRARY_PATH=. zig build run
use zaz::{Screen, Color, Attr};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut scr = Screen::init()?;
scr.clear()?;
scr.mvprint(2, 4, "Hello from Zaz!")?;
scr.set_fg(Color::Rgb(255, 200, 0))?;
scr.attron(Attr::BOLD)?;
scr.mvprint(4, 4, "Colored text!")?;
scr.refresh()?;
scr.getch()?;
scr.endwin()?;
Ok(())
}
const std = @import("std");
const zaz = @import("zaz");
pub fn main() !void {
const screen = try zaz.Screen.init();
defer screen.deinit() catch {};
try screen.clear();
try screen.mvprint(2, 4, "Hello from Zig + Zaz!");
try screen.setFgColor(255, 200, 0);
try screen.attrOn(.bold);
try screen.mvprint(4, 4, "Colored text!");
try screen.attrOff(.bold);
try screen.refresh();
_ = try screen.getch();
}
The library exports a C-compatible API for use with other languages:
zaz_init() - Initialize screenzaz_endwin() - Clean up and restore terminalzaz_clear() - Clear screenzaz_refresh() - Refresh displayzaz_print() - Print at cursor positionzaz_mvprint() - Print at specific positionzaz_move_cursor() - Move cursorzaz_set_fg_color() - Set foreground RGB colorzaz_set_bg_color() - Set background RGB colorzaz_attron() - Enable text attributeszaz_attroff() - Disable text attributeszaz_getch() - Get key inputzaz_get_size() - Get terminal dimensionszaz_render_mosaic() - Render image as Unicode artzaz_free_string() - Free mosaic stringSee LICENSE file for details.