Terminfo
Encyclopedia
Terminfo is a library and database
Database
A database is an organized collection of data for one or more purposes, usually in digital form. The data are typically organized to model relevant aspects of reality , in a way that supports processes requiring this information...

 that enables programs to use display terminals in a device-independent manner. This library has its origins in the UNIX System III
UNIX System III
UNIX System III was a version of the Unix operating system released by AT&T's Unix Support Group . It was first released outside of Bell Labs in 1982. UNIX System III was a mix of various AT&T Unixes: PWB/UNIX 2.0, CB UNIX 3.0, UNIX/TS 3.0.1 and UNIX/32V...

 operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

.
Mark Horton
Mary Ann Horton
Mary Ann Horton, formerly Mark R. Horton , is a Usenet and Internet pioneer. Horton contributed to Berkeley UNIX , including the vi editor and terminfo database, and led the growth of Usenet in the 1980s....

 implemented the first terminfo library in 1981-1982 as an improvement over termcap
Termcap
Termcap is a software library and database used on Unix-like computers. It enables programs to use display computer terminals in a device-independent manner, which greatly simplifies the process of writing portable text mode applications...

. 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 soon became the preferred form of terminal descriptions in UNIX
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

, rather than termcap. This was imitated in pcurses in 1982-1984 by Pavel Curtis
Pavel Curtis
Pavel Curtis is an American software architect at Microsoft who is best known for having founded and managed LambdaMOO, an online community...

, and was available on other UNIX
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 implementations, adapting or incorporating fixes from Mark 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

Indices

Each description must contain the canonical
Canonical
Canonical is an adjective derived from canon. Canon comes from the greek word κανών kanon, "rule" or "measuring stick" , and is used in various meanings....

 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
Termcap is a software library and database used on Unix-like computers. It enables programs to use display computer terminals in a device-independent manner, which greatly simplifies the process of writing portable text mode applications...

, some of the string capabilities represent escape sequence
Escape sequence
An escape sequence is a series of characters used to change the state of computers and their attached peripheral devices. These are also known as control sequences, reflecting their use in device control. Some control sequences are special characters that always have the same meaning...

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
Parameter (computer science)
In computer programming, a parameter is a special kind of variable, used in a subroutine to refer to one of the pieces of data provided as input to the subroutine. These pieces of data are called arguments...

 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
Storage model
A storage model is a model that captures key physical aspects of data structure in a data store.On the other hand, a data model is a model that captures key logical aspects of data structure in a database....

 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
Binary file
A binary file is a computer file which may contain any type of data, encoded in binary form for computer storage and processing purposes; for example, computer document files containing formatted text...

, making it less simple to modify than termcap
Termcap
Termcap is a software library and database used on Unix-like computers. It enables programs to use display computer terminals in a device-independent manner, which greatly simplifies the process of writing portable text mode applications...

. 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 Mark Horton
Mark Horton
Mark Horton may refer to* Mark Horton , British maritime and historical archaeologist, television presenter and writer* Mary Ann Horton , Usenet and Internet pioneer...

, and except for some differences regarding the available names is used in most terminfo implementations. X/Open 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
The term metadata is an ambiguous term which is used for two fundamentally different concepts . Although the expression "data about data" is often used, it does not apply to both in the same way. Structural metadata, the design and specification of data structures, cannot be about data, because at...

 identifying the indices
Index (information technology)
In computer science, an index can be:# an integer that identifies an array element# a data structure that enables sublinear-time lookup -Array element identifier:...

 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
Header (information technology)
In information technology, header refers to supplemental data placed at the beginning of a block of data being stored or transmitted. In data transmission, the data following the header are sometimes called the payload or body....

 and data items), it is possible to automatically construct customized terminfo libraries which can read data for a given implementation. For example, ncurses
Ncurses
ncurses is a programming library that provides an API which allows the programmer to write text user interfaces in a terminal-independent manner. It is a toolkit for developing "GUI-like" application software that runs under a terminal emulator...

 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
Directory (file systems)
In computing, a folder, directory, catalog, or drawer, is a virtual container originally derived from an earlier Object-oriented programming concept by the same name within a digital file system, in which groups of computer files and other folders can be kept and organized.A typical file system may...

 hierarchy
Hierarchy
A hierarchy is an arrangement of items in which the items are represented as being "above," "below," or "at the same level as" one another...

. 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
Berkeley DB
Berkeley DB is a computer software library that provides a high-performance embedded database for key/value data. Berkeley DB is a programmatic software library written in C with API bindings for C++, PHP, Java, Perl, Python, Ruby, Tcl, Smalltalk, and most other programming languages...

 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
The Open Group is a vendor and technology-neutral industry consortium, currently with over three hundred member organizations. It was formed in 1996 when X/Open merged with the Open Software Foundation...

 documents the minimum limits for terminfo, which apply only to the source file.
Two of these are of special interest:
  • 14 characters for terminal aliases
  • 32,767 limit on 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
The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of two...

 16-bit value. A terminfo entry may use negative numbers to represent cancelled or absent values.

Unlike termcap
Termcap
Termcap is a software library and database used on Unix-like computers. It enables programs to use display computer terminals in a device-independent manner, which greatly simplifies the process of writing portable text mode applications...

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

External links

  • Current terminfo data
  • Termcap/Terminfo Resources Page at Eric S. Raymond
    Eric S. Raymond
    Eric Steven Raymond , often referred to as ESR, is an American computer programmer, author and open source software advocate. After the 1997 publication of The Cathedral and the Bazaar, Raymond was for a number of years frequently quoted as an unofficial spokesman for the open source movement...

    's website
  • man terminfo(5)
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK