Ports ZIG/src/lib_vt.zig and terminal/c/* as crates/ghostty-vt-capi (cdylib + staticlib + rlib, soname libghostty-vt.so) implementing the unchanged include/ghostty/vt.h + vt/*.h ABI: OSC parser, SGR parser, key events and key encoding, paste safety, colors, result codes - all 38 native symbols, plus the ghostty_wasm_* helpers on wasm32. Verification: - tests/abi.rs generates a C probe from the headers, compiled with cc, that checks sizeof/alignof/offsetof of every struct/union, every enumerator and #define against Rust, and links every declared symbol; nm -D exports equal the declared functions. - Ghostty's example/c-vt* programs compile unchanged against the Rust library (shared and static) and produce the expected output. - The wasm32 build runs Ghostty's wasm-key-encode/wasm-sgr example scripts unmodified under node (upstream's wasm-sgr tag table is stale vs sgr.h; a regenerated copy checks full output). Test Plan: - cargo test -p ghostty-vt-capi (22 unit + 2 ABI + 5 C + 3 wasm tests)
27 lines
886 B
Rust
27 lines
886 B
Rust
//! C ABI of libghostty-vt (ZIG/src/lib_vt.zig, ZIG/src/terminal/c/*.zig).
|
|
//!
|
|
//! The exported symbols and struct/enum layouts match
|
|
//! `include/ghostty/vt.h` (copied unchanged from upstream) exactly. Each
|
|
//! Zig file under `terminal/c/` maps to a module of the same name; the
|
|
//! Zig `@export` list in `lib_vt.zig` is expressed here as
|
|
//! `#[unsafe(no_mangle)]` on each `extern "C"` function.
|
|
//!
|
|
//! Wasm: on `wasm32` the allocation helpers (`ghostty_wasm_alloc_*`,
|
|
//! `ghostty_wasm_free_*`, `ghostty_wasm_{alloc,free}_sgr_attribute`) are
|
|
//! exported as well; on other targets they exist as ordinary Rust functions
|
|
//! but are not exported (like upstream).
|
|
|
|
#![cfg_attr(test, allow(clippy::unwrap_used))]
|
|
|
|
pub mod alloc;
|
|
pub mod color;
|
|
pub mod key_encode;
|
|
pub mod key_event;
|
|
pub mod osc;
|
|
pub mod paste;
|
|
pub mod result;
|
|
pub mod sgr;
|
|
pub mod wasm;
|
|
|
|
pub use result::GhosttyResult;
|