mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-09-03 21:00:27 +00:00
Ghostty's full termio path answers XTGETTCAP from the static terminfo map, but terminal/stream_terminal.zig, which backs libghostty-vt, parses the same DCS request and then discards it. There is no XTGETTCAP effect either, so an embedder cannot restore the replies through the C API. Programs query these over SSH instead of assuming the remote host has the client's terminfo entry. This matters more for an embedder than for the desktop app, which can install its entry on the remote through shell integration. Answer the queries in stream_terminal the same way termio does: look up each requested key in the static terminfo map and write the reply to the pty, skipping the lookups entirely when no write_pty effect is set. The map now stores null-terminated responses so they can be handed straight to write_pty without copying. terminal/dcs.zig and the termio path are unchanged. "TN" is handled separately. It names the terminfo entry the terminal runs as, so it has to agree with TERM -- which is set in termio/Exec.zig, a layer libghostty-vt does not contain. The library never sees TERM and cannot answer on the embedder's behalf, and answering with Ghostty's own entry from the static map would misreport every embedder, so "TN" is intercepted before the map lookup. The name is instead configured through a new option, GHOSTTY_TERMINAL_OPT_TERMINFO_NAME: the string is copied into the terminal, names longer than 128 bytes are rejected, and while unset the query goes unanswered. This is the first dependency from src/terminal on src/terminfo, so libghostty-vt now carries Ghostty's terminfo table: +16,023 bytes (+1.9%) on a wasm32-freestanding ReleaseSmall build. Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>