Skip to main content

Crate terminfokit

Crate terminfokit 

Source
Expand description

Terminfo compilation, formatting, database access, and expansion.

The transformation core is no_std with alloc; enabling the default std feature adds filesystem and environment-backed database access.

§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());

§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.

Re-exports§

pub use binary::BinaryDocument;
pub use binary::BinaryLimits;
pub use binary::DecodeOptions;
pub use binary::EncodeOptions;
pub use binary::Magic;
pub use binary::NumberFormat;
pub use caps::BooleanCap;
pub use caps::CapabilityId;
pub use caps::CapabilityKind;
pub use caps::CapabilityMetadata;
pub use caps::Lookup;
pub use caps::NameNamespace;
pub use caps::NumericCap;
pub use caps::ParameterType;
pub use caps::StringCap;
pub use caps::all_capabilities;
pub use caps::lookup;
pub use caps::lookup_all;
pub use error::BuildError;
pub use error::CompileError;
pub use error::ConvertError;
pub use error::DecodeError;
pub use error::Diagnostic;
pub use error::EncodeError;
pub use error::ExpandError;
pub use error::ParseError;
pub use error::SourceId;
pub use error::Span;
pub use error::TextRange;
pub use model::BooleanState;
pub use model::CapabilityState;
pub use model::CapabilityValueRef;
pub use model::Entry;
pub use model::EntryBuilder;
pub use model::EntryNames;
pub use model::ExtendedCapability;
pub use model::ExtendedKind;
pub use model::ExtendedValue;
pub use model::Number;
pub use resolve::Compilation;
pub use resolve::CompiledEntry;
pub use resolve::Compiler;
pub use resolve::CompilerOptions;
pub use resolve::EntryProvider;
pub use resolve::ProviderError;
pub use resolve::Resolution;
pub use source::SourceDocument;

Modules§

binary
Compiled terminfo decoding and encoding.
caps
Generated terminfo capability metadata.
database
Filesystem databases, search paths, and inline transport.
error
Errors and machine-readable diagnostics.
expand
tparm expansion and padding events.
format
Terminfo formatting and logical diffs.
model
Logical terminfo entries.
resolve
Source compilation and use= resolution.
source
Unresolved terminfo source parsing.
termcap
Termcap parsing, writing, inheritance, and conversion.