Termcap

Termcap

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 applications. Bill Joy wrote the first termcap library [ [http://www.byte.com/art/9410/sec8/art3.htm Peter H. Salus, "The history of Unix is as much about collaboration as it is about technology", Byte, October 1994.] ] [ [http://www.mirbsd.org/cman/manPSD/19.curses.htm Kenneth C. R. C. Arnold and Elan Amir, "Screen Updating and Cursor Movement Optimization: A Library Package"] ] for the Berkeley Unix operating system; it has since been ported to most Unix and Unix-like environments. Joy's design was reportedly influenced by the design of the terminal data store in the earlier Incompatible Timesharing System system. [ [http://www.inwap.com/pdp10/usenet/its alt.sys.pdp10 posting] ]

A termcap 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. On-screen text editors such as vi and emacs are examples of programs that may use termcap. Other programs are listed in the category.

Examples of what the database describes:
*how many columns wide it is
*what string to send to move the cursor to an arbitrary position (including how to encode the row and column numbers)
*how to scroll the screen up one or several lines
*how much padding is needed for such a scrolling operation.

Data model

Termcap 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 termcap database.

Data Values

The description contains one or more capabilities, which have conventional names.The capabilities are typed: "boolean", "numeric" and "string".The termcap library has no predetermined type for each capability name.It determines 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 termcap do expect specific types for the commonly used capabilities,and obtain the values of capabilities from the termcap database using library calls that return successfullyonly when the database contents matches the assumed type.

Hierarchy

Termcap 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 termcap library constructs the terminal descriptionfrom the requested description, including, suppressing or overriding at the time of the request.

torage Model

Termcap data is stored as text, making it simple to modify.The text can be retrieved by the termcap library from files or environment variables.

Environment Variable

The TERMCAP environment variable may contain a termcap database.It is most often used to store a single termcap description,set by a terminal emulator to provide the terminal's characteristics to the shell and dependent programs.

Flat File

The original (and most common) implementation of the termcap library retrieves data from a flat text file.Searching a large termcap file, e.g., 500Kb, can be slow.To aid performance, a utility such as reorder is usedto put the most frequently used entries near the beginning of the file.

Hashed Database

Newer implementations of termcap 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.The text of the termcap entry is stored literally.

Limitations and Extensions

The original termcap implementation was designed to use little memory:
* the first name is two characters, to fit in 16 bits
* capability names are two characters
* descriptions are limited to 1023 characters.
* only one description can be included, and must be at the end.

Newer implementations of the termcap interface generally do not require the two-character name at the beginning of the entry.

Capability names are still two characters in all implementations.

The tgetent function used to read the terminal description uses a buffer whose size must be large enough for the data,and is assumed to be 1024 characters.Newer implementations of the termcap interface may relax this constraint by allowing a null pointer in place of the fixed buffer [ [http://www.gnu.org/software/termutils/manual/termcap-1.3/termcap.html The GNU Termcap Library] ] ,or by hiding the data which would not fit, e.g., via the ZZ capability in NetBSD termcap. [ [http://www.daemon-systems.org/man/termcap.5.html NetBSD termcap file format] ] The terminfo library interface also emulates the termcap interface, and does not actually use the fixed-size buffer.

The terminfo library's emulation of termcap allows multiple descriptions to be included without restricting the position.A few other newer implementations of the termcap library may also provide this ability, though it is not well-documented. [ [http://freshmeat.net/projects/vi/ Discussion of termcap in vi] ]

ee also

*Computer terminals
*curses (programming library)
*Terminfo

References

External links

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


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • termcap — Terminal Capability Database (UNIX, s. /etc/termcap) …   Acronyms

  • termcap — Terminal Capability Database (UNIX, s. /etc/termcap) …   Acronyms von A bis Z

  • termcap — n. database in UNIX that contains information about the types of terminals in use and character strings to make the terminals perform a particular function (Computers) …   English contemporary dictionary

  • TERMCAP — abbr. TERMinal CAPability (Unix) …   United dictionary of abbreviations and acronyms

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

  • 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

  • ncurses — based menuconfig Developer(s) GNU Project Stable release 5.9 / 4 April 2011; 7 months ago ( …   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

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

  • 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

Share the article and excerpts

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