terminfokit 0.1.0

Terminfo parsing, compilation, formatting, database access, and expansion
Documentation
  • Coverage
  • 100%
    1056 out of 1056 items documented1 out of 397 items with examples
  • Size
  • Source code size: 333.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.2 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • P4suta/terminfokit
    0 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • P4suta

terminfokit

CI MSRV License

terminfokit compiles, decodes, edits, decompiles, queries, and expands terminfo descriptions.

The library is no_std + alloc and #![forbid(unsafe_code)]. Its only dependency, behind the default std feature, is atomic-write-file for database installation; with default features off it has none.

The 0.1 series is alpha-quality. APIs and CLI behavior may change.

Checked against ncurses, byte for byte

Compiled terminfo is a binary format whose exact layout matters, so compatibility here is measured rather than asserted. The conformance harness downloads and builds the real tic from ncurses 6.6, compiles all 1,861 entries of its terminfo.src with both implementations, and compares every output file byte for byte in normal and -x extended mode. It then decodes and re-encodes each file ncurses produced and requires the round trip to reproduce the original bytes. Differences can be waived only through an allowlist whose entries carry a mandatory expiry, and a stale allowlist is itself reported as a difference. The comparison runs on every pull request.

Installation

cargo install terminfokit-cli

This installs terminfokit plus tik-tic, tik-infocmp, tik-tput, tik-captoinfo, and tik-infotocap. The ncurses names are deliberately prefixed: cargo install writes into a directory that rustup places ahead of the system path, so binaries named tput or tic would replace the ncurses tools for every shell script, prompt, and curses program on the machine.

Usage

terminfokit --help
terminfokit doctor
tik-tput colors

Compile a terminfo source entry in memory:

use terminfokit::Compiler;

let source = b"demo|demo terminal,am,cols#80,cup=\\E[%i%p1%d;%p2%dH,\n";
let compilation = Compiler::new().compile(source)?;
let demo = compilation.get("demo").expect("compiled entry");

assert_eq!(demo.entry().names().primary(), "demo");
assert!(!demo.bytes().is_empty());
# Ok::<(), Box<dyn std::error::Error>>(())

Windows

Windows has no system terminfo database, so there is no default search path to fall back on. Every lookup fails with NotFound until you point the tools at a directory you control:

set TERMINFO=C:\terminfo
terminfokit doctor

TERMINFO_DIRS and the hex: and b64: inline transports work the same way as on Unix. $HOME/.terminfo is Unix-only. The library's parsing, compilation, formatting, and expansion are unaffected and behave identically everywhere.

Not implemented

The 0.1 series covers the System V capability vocabulary and directory-backed databases. It does not implement the ncurses hashed-database file format, and tic -R, infocmp -R, infocmp -e, infocmp -E, and infocmp -i are unsupported; each reports a diagnostic naming the supported alternative.

Contributing

See CONTRIBUTING.md. Report vulnerabilities with GitHub private vulnerability reporting, not a public issue.

License

The code is licensed under MIT OR Apache-2.0. The ncurses-derived capability metadata is also covered by the X11 license, so the library's SPDX expression is (MIT OR Apache-2.0) AND X11. Downstream license audits need to allow X11 for this crate.