
Terminfo is a
library
A library is a collection of Book, books, and possibly other Document, materials and Media (communication), media, that is accessible for use by its members and members of allied institutions. Libraries provide physical (hard copies) or electron ...
and
database
In computing, a database is an organized collection of data or a type of data store based on the use of a database management system (DBMS), the software that interacts with end users, applications, and the database itself to capture and a ...
that enables programs to use display
terminals in a device-independent manner.
Mary Ann Horton
Mary Ann Horton (born Mark R. Horton, November 21, 1955), is a Usenet and Internet pioneer. Horton contributed to Berkeley UNIX (BSD), including the vi editor and terminfo database, (see Acknowlegments section at end of file) created the first ...
implemented the first terminfo library in 1981–1982 as an improvement over
termcap
Termcap ("terminal capability") is a legacy software library (computing), library and database used on Unix-like computers that enables programs to use display computer terminals in a terminal-independent manner, which greatly simplifies the proc ...
. The improvements include
* faster access to stored terminal descriptions,
* longer, more understandable names for
terminal capabilities and
* general expression evaluation for strings sent to the terminal.
Terminfo was included with
UNIX System V
Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
Release 2 and soon became the preferred form of terminal descriptions in System V, rather than
termcap
Termcap ("terminal capability") is a legacy software library (computing), library and database used on Unix-like computers that enables programs to use display computer terminals in a terminal-independent manner, which greatly simplifies the proc ...
(which BSD continued to use). This was imitated in
pcurses in 1982–1984 by
Pavel Curtis
Pavel Curtis is an American software architect at Microsoft who is best known for having founded and managed ''LambdaMOO'', an online community.
In the mid- to late 1980s Curtis developed and taught parts of the computer science course at the ...
, and was available on other
UNIX
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
implementations, adapting or incorporating fixes from Mary Horton. For more information, refer to the posting on the
comp.sources.unix
newsgroup from December 1986.
A terminfo database can describe the capabilities of hundreds of different display terminals. This allows external programs to be able to have
character-based display output, independent of the type of terminal.
Some configurations are:
*Number of lines on the screen
*Mono mode; suppress color
*Use visible bell instead of beep
Data model
Terminfo databases consist of one or more descriptions of terminals.
Indices
Each description must contain the
canonical name of the terminal. It may also contain one or more aliases for the name of the terminal. The canonical name or aliases are the keys by which the library searches the terminfo database.
Data values
The description contains one or more capabilities, which have conventional names.
The capabilities are typed: ''boolean'', ''numeric'' and ''string''.
The terminfo library has predetermined types for each capability name.
It checks the types of each capability by the syntax:
* ''string'' capabilities have an "=" between the capability name and its value,
* ''numeric'' capabilities have a "#" between the capability name and its value, and
* ''boolean'' capabilities have no associated value (they are always ''true'' if specified).
Applications which use terminfo know the types for the respective capabilities, and obtain the values of capabilities from the terminfo database using library calls that return successfully only when the capability name corresponds to one of the predefined typed capabilities.
Like
termcap
Termcap ("terminal capability") is a legacy software library (computing), library and database used on Unix-like computers that enables programs to use display computer terminals in a terminal-independent manner, which greatly simplifies the proc ...
, some of the ''string'' capabilities represent
escape sequence
In computer science, an escape sequence is a combination of characters that has a meaning other than the literal characters contained therein; it is marked by one or more preceding (and possibly terminating) characters.
Examples
* In C and ma ...
s which may be sent to the host by pressing special keys on the keyboard. Other capabilities represent strings that may be sent by an application to the terminal. In the latter case, the terminfo library functions (as does a termcap library) for substituting application
parameters into the string which is sent. These functions provide a
stack-based expression parser, which is primarily used to help minimize the number of characters sent for control sequences which have optional parameters such as
SGR (Select Graphic Rendition). In contrast, termcap libraries provide a limited set of operations which are useful for most terminals.
Hierarchy
Terminfo descriptions can be constructed by including the contents of one description in another, suppressing capabilities from the included description or overriding or adding capabilities. No matter what
storage model is used, the terminfo library returns the terminal description from the requested description, using data which is compiled using a standalone tool (e.g., tic).
Storage model
Terminfo data is stored as a
binary file
A binary file is a computer file that is not a text file. The term "binary file" is often used as a term meaning "non-text file". Many binary file formats contain parts that can be interpreted as text; for example, some computer document files ...
, making it less simple to modify than
termcap
Termcap ("terminal capability") is a legacy software library (computing), library and database used on Unix-like computers that enables programs to use display computer terminals in a terminal-independent manner, which greatly simplifies the proc ...
. The data can be retrieved by the terminfo library from the files where it is stored. The data itself is organized as tables for the boolean, numeric and string capabilities, respectively. This is the scheme devised by Mary Horton, and except for some differences regarding the available names is used in most terminfo implementations.
X/Open X/Open group (also known as the Open Group for Unix Systems and incorporated in 1987 as X/Open Company, Ltd.) was a consortium founded by several European UNIX systems manufacturers in 1984 to identify and promote open standards in the field of info ...
does not specify the format of the compiled terminal description. In fact, it does not even mention the common tic or infocmp utilities. Because the compiled terminfo entries do not contain
metadata
Metadata (or metainformation) is "data that provides information about other data", but not the content of the data itself, such as the text of a message or the image itself. There are many distinct types of metadata, including:
* Descriptive ...
identifying the
indices within the tables to which each capability is assigned, they are not necessarily compatible between implementations. However, since most implementations use the same overall table structure (including sizes of
header and data items), it is possible to automatically construct customized terminfo libraries which can read data for a given implementation. For example,
ncurses can be built to match the terminfo data for several other implementations.
Directory tree
The original (and most common) implementation of the terminfo library retrieves data from a
directory hierarchy
A hierarchy (from Ancient Greek, Greek: , from , 'president of sacred rites') is an arrangement of items (objects, names, values, categories, etc.) that are represented as being "above", "below", or "at the same level as" one another. Hierarchy ...
. By using the first character of the name of the terminal description as one component of the pathname, and the name of the terminal description as the name of the file to retrieve, the terminfo library usually outperforms searching a large termcap file.
Hashed database
Some implementations of terminfo store the terminal description in a hashed database (e.g., something like
Berkeley DB version 1.85). These store two types of records: aliases which point to the canonical entry, and the canonical entry itself, which contains the data for the terminal capabilities.
Limitations and extensions
The Open Group
The Open Group is a global consortium that seeks to "enable the achievement of business objectives" by developing " open, vendor-neutral technology standards and certifications." It has 900+ member organizations and provides a number of services ...
documents the limits for terminfo (minimum guaranteed values), which apply only to the source file.
Two of these are of special interest:
* 14 character maximum for terminal aliases
* 32,767 maximum for numeric quantities
The 14-character limit addresses very old filesystems which could represent filenames no longer than that. While those filesystems are generally obsolete, these limits were as documented from the late 1980s, and unreviewed since then.
The 32,767 limit is for positive values in a signed
two's complement
Two's complement is the most common method of representing signed (positive, negative, and zero) integers on computers, and more generally, fixed point binary values. Two's complement uses the binary digit with the ''greatest'' value as the ''s ...
16-bit value. A terminfo entry may use negative numbers to represent cancelled or absent values.
Unlike
termcap
Termcap ("terminal capability") is a legacy software library (computing), library and database used on Unix-like computers that enables programs to use display computer terminals in a terminal-independent manner, which greatly simplifies the proc ...
, terminfo has both a source and compiled representation. The limits for the compiled representation are unspecified. However, most implementations note in their documentation for tic (terminal information compiler) that compiled entries cannot exceed 4,096 bytes in size.
See also
*
Curses (programming library)
curses is a terminal control library for Unix-like systems, enabling the construction of text user interface (TUI) applications.
The name is a pun on the term " cursor optimization". It is a library of functions that manage an application's d ...
*
tput
In computing, tput is a standard Unix operating system command which makes use of terminal capabilities.
Depending on the system, ''tput'' uses the terminfo or termcap database, as well as looking into the environment for the terminal type.
...
References
{{reflist
External links
Current terminfo dataTermcap/Terminfo Resources Pageat
Eric S. Raymond
Eric Steven Raymond (born December 4, 1957), often referred to as ESR, is an American software developer, open-source software advocate, and author of the 1997 essay and 1999 book ''The Cathedral and the Bazaar''. He wrote a guidebook for the R ...
's website
man terminfo(5)
Database management systems
Unix software
Text mode
1980s software