Terminfo

Terminfo

Terminfo is a library and database that enables programs to use display terminals in a device-independent manner. The origins of this library are from the UNIX System III operating system.
Mark Horton implemented the first terminfo library in 1981-1982 as an improvement over termcap. [Citation
first = Mark
last = Horton
contribution = The New Curses and Terminfo Package
pages = 79-91
publisher = USENIX
title = USENIX Conference Proceedings
volume = Summer 1982
location = Boston, MA
institution = Bell Laboratories, Columbus
] 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, rather than termcap, [cite web |url=http://groups.google.pl/group/fa.info-terms/browse_thread/thread/f2e4b40ed2a1064c/2fb02654a836e813#2fb02654a836e813|title=fa.info-terms mailing list comments on termcap/terminfo in 1985] This was imitated in pcurses in 1982-1984 by Pavel Curtis, and was available on other UNIX implementations, adapting or incorporating fixes from Mark Horton [cite web |url=http://mvb.saic.com/freeware/uni87a/mod/sources_1/pcurses.9|title=pcurses shar file from 1986 showing change history] For more information, refer to the posting on the comp.sources.unix newsgroup from December 1986. [cite web|url=ftp://ftp.isc.org/usenet/comp.sources.unix/volume1/pcurses/|title=pcurses complete posting]

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 successfullyonly when the capability name corresponds to one of the predefined typed capabilities.

Like termcap, some of the "string" capabilities represent escape sequences 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 descriptionfrom the requested description, using data which is compiled using a standalone tool, e.g., tic.

torage Model

Terminfo data is stored as a binary file, making it less simple to modify than termcap.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, and except for some differences regarding theavailable names is used in most terminfo implementations. [cite web
url=http://invisible-island.net/ncurses/man/term.5.html
title=term - format of compiled term file
author=Thomas E. Dickey
date=December 17, 2006
] 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. [cite web
url=http://www.opengroup.org/onlinepubs/007908799/cursesix.html
title=X/Open Curses, Issue 4 Version 2 — Reference Pages
publisher=The Open Group
date=1997
] [cite web
url=http://www.opengroup.org/onlinepubs/007908799/xcuix.html
title=Commands & Utilities Issue 5 — Reference Pages
publisher=The Open Group
date=1997
] Because the compiled terminfo entries do not contain metadata 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. [cite web
url=http://invisible-island.net/ncurses/announce-5.3.html
title=Announcing ncurses 5.3
author=Thomas E. Dickey
date=October 12, 2002
]

Directory Tree

The original (and most common) implementation of the terminfo library retrieves data from a directory 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. [cite web
url=http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libcurses/tinfo/read_bsd_terminfo.c
title=OpenBSD read_bsd_terminfo.c module
author=Todd C. Miller
date=1999
] [cite web
url=http://invisible-island.net/ncurses/announce.html
title=Announcing ncurses 5.6
author=Thomas E. Dickey
date=December 17, 2006
] 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 documents the minimum limits for terminfo, which apply only to the source file. [Most of this was done before X/Open merged with Open Software Foundation to form The Open Group, consequently there are many sources that say "X/Open".] [cite web
url=http://www.opengroup.org/onlinepubs/007908799/xcurses/terminfo.html#tag_002_001_001
title=Terminfo Source Format (ENHANCED CURSES) — Minimum Guaranteed Limits
publisher=The Open Group
date=1997
] Two of these are of special interest:
* 14 characters for terminal aliases
* 32767 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 32767 limit is for positive values in a signed two's complement 16-bit value.A terminfo entry may use negative numbers to represent cancelled or absent values.

Unlike termcap, 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) thatcompiled entries cannot exceed 4096 bytes in size.

=See also=
*Computer terminals
*curses (programming library)
*termcap
*tput

References

External links

* [http://invisible-island.net/ncurses/ncurses.faq.html#which_terminfo Current terminfo data]
* [http://www.catb.org/~esr/terminfo/ Termcap/Terminfo Resources Page] at Eric S. Raymond's website
* [http://invisible-island.net/ncurses/man/terminfo.5.html man terminfo(5)]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • terminfo — Terminal Information Database (UNIX, Nachfolgesystem von termcap) …   Acronyms

  • terminfo — Terminal Information Database (UNIX, Nachfolgesystem von termcap) …   Acronyms von A bis Z

  • TERMINFO — abbr. TERMinal INFOrmation (Unix) …   United dictionary of abbreviations and acronyms

  • Tput — is a standard Unix computer operating system command which is used to set terminal features. Depending on the system, tput uses the terminfo or termcap database, as well as looking into the environment for the terminal type. History Tput was… …   Wikipedia

  • Curses (programming library) — curses is a terminal control library for Unix like systems, enabling the construction of text user interface (TUI) applications.Curses is a on the term cursor optimization . It is a library of functions that manage an application s display on… …   Wikipedia

  • Termcap — (terminal capability) 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… …   Wikipedia

  • POSIX terminal interface — The POSIX terminal interface is the generalized abstraction, comprising both an Application Programming Interface for programs, and a set of behavioural expectations for users of a terminal, as defined by the POSIX standard and the Single Unix… …   Wikipedia

  • 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… …   Wikipedia

  • ncurses — based menuconfig Developer(s) GNU Project Stable release 5.9 / 4 April 2011; 7 months ago ( …   Wikipedia

  • Ncurses — Desarrollador Proyecto GNU www.gnu.org/software/ncurses/ncurses.html Información general Última versión estable 5.6 …   Wikipedia Español

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”