Files
ddidderr 75252a7651 feat(vt-capi): port the libghostty-vt C API
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)
2026-10-12 05:16:41 +02:00

58 lines
1.9 KiB
TOML

[package]
name = "ghostty-vt-capi"
version.workspace = true
edition.workspace = true
license.workspace = true
description = "C ABI of libghostty-vt (include/ghostty/vt.h), ported from Ghostty's lib_vt.zig"
# The crate name cannot contain a hyphen, so Cargo produces
# `libghostty_vt_capi.{so,a}`. `just vt-lib` (and the integration tests)
# install them as `libghostty-vt.{so,a}`, the names Ghostty ships; the soname
# is set to `libghostty-vt.so` by build.rs.
[lib]
name = "ghostty_vt_capi"
crate-type = ["cdylib", "staticlib", "rlib"]
[dependencies]
ghostty-vt.workspace = true
ghostty-input.workspace = true
log = "0.4.34"
# The workspace forbids `unsafe`; this crate is the C ABI boundary, so it
# denies it instead and allows it (with SAFETY comments) in the FFI modules.
# Everything else is copied from `[workspace.lints]`.
[lints.rust]
unsafe_code = "deny"
[lints.clippy]
pedantic = { level = "warn", priority = -1 }
todo = "warn"
unwrap_used = "warn"
cast_possible_truncation = "allow"
cast_possible_wrap = "allow"
cast_sign_loss = "allow"
cast_precision_loss = "allow"
cast_lossless = "allow"
module_name_repetitions = "allow"
too_many_lines = "allow"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
similar_names = "allow"
struct_excessive_bools = "allow"
fn_params_excessive_bools = "allow"
match_same_arms = "allow"
unreadable_literal = "allow"
many_single_char_names = "allow"
doc_markdown = "allow"
must_use_candidate = "allow"
return_self_not_must_use = "allow"
used_underscore_binding = "allow"
large_stack_arrays = "allow"
inline_always = "allow"
# The exported functions are `unsafe extern "C"` mirroring the header contracts.
missing_safety_doc = "allow"
# `&mut x` coerced to `*mut T` is the idiomatic way to pass out-params in FFI tests.
borrow_as_ptr = "allow"
# Allocations are made with the layout of the pointee, so the cast is aligned.
cast_ptr_alignment = "allow"