Terminfo Databases


The terminfo vocabulary contains words for querying the terminfo database, which contains low-level information about the capabilities and protocols of different terminals. It supports both SysV ("Legacy") and Curses 6.1 ("Extended Number") formats, and automatically selects the appropriate format depending on the file header. It also supports Curses 5 user-defined ("Extended") capabilities.

Terminfo capability descriptions are returned as assocs, where the keys are capability names; see terminfo(5) for a list of standardized capability names and their meanings. Capabilities that are disabled or absent are not present in the assoc and can be assumed to be f. In addition, all of the terminal's names are returned in the ".names" pseudocapability, in the same order they appear in the terminfo file.

Words for getting terminal information:
my-terminfo ( -- terminfo/f )

name>terminfo ( name -- terminfo/f )

file>terminfo ( path -- terminfo )

bytes>terminfo ( bytes -- terminfo )


Limitations
The database search behaviour is not a perfect match for the behaviour implemented in Curses. In particular, setting the $TERMINFO environment variable does not disable searching the system-wide database as well, and the compiled-in search paths are not guaranteed to match the ones compiled into libcurses (although they should be correct on the vast majority of systems).

BerkeleyDB "hashed database" format is not supported and BDB terminfo databases will be ignored.

External References
terminfo(5) for information about terminfo capabilities and how to use them; term(5) for information about the on-disk database format; and term(7) for information about terminal naming conventions. I also found https://github.com/mauke/unibilium/blob/master/secret/terminfo.pod useful for clarifying some aspects of the Curses 5 format which are not clear in the man page.