In computing and telecommunications, the capabilities of a
terminal are various terminal features, above and beyond what is available from a pure
teletypewriter
A teleprinter (teletypewriter, teletype or TTY) is an electromechanical device that can be used to send and receive typed messages through various communications channels, in both point-to-point and point-to-multipoint configurations.
Init ...
, that host systems (and the programs that run on them) can make use of. They are (mainly)
control code
In computing and telecommunications, a control character or non-printing character (NPC) is a code point in a character set that does not represent a written character or symbol. They are used as in-band signaling to cause effects other than ...
s and
escape codes that can be sent to or received from the terminal. The escape codes sent to the terminal perform various functions that a
CRT
CRT or Crt most commonly refers to:
* Cathode-ray tube, a display
* Critical race theory, an academic framework of analysis
CRT may also refer to:
Law
* Charitable remainder trust, United States
* Civil Resolution Tribunal, Canada
* Columbia ...
terminal (and software
terminal emulator
A terminal emulator, or terminal application, is a computer program that emulates a video terminal within some other display architecture. Though typically synonymous with a shell or text terminal, the term ''terminal'' covers all remote term ...
s) is capable of, but that a teletypewriter is not; such as moving the terminal's cursor to positions on the screen, clearing and scrolling all or parts of the screen, turning on and off attached printer devices, programming programmable function keys, changing display colours and attributes (such as
reverse video
Reverse video (or invert video or inverse video or reverse screen) is a computer display technique whereby the background and text color values are inverted. On older computers, displays were usually designed to display text on a black backgroun ...
), and setting display title strings. The escape codes received from the terminal signify things such as
function key
A function key is a key on a computer or computer terminal, terminal computer keyboard, keyboard that can be programmed to cause the operating system or an application program to perform certain actions, a form of soft key. On some keyboards/com ...
,
arrow key, and other special key (
home key
The key is commonly found on desktop and laptop keyboards. The key has the opposite effect of the End key. In limited-size keyboards where the key is missing the same functionality can be reached via the key combination of .
Its standard ...
,
end key
The key is a key commonly found on desktop and laptop keyboards. The key has the opposite effect of the Home key. In some limited-size keyboards where the key is missing the same functionality can be reached via the key combination of or C ...
,
help key,
PgUp key,
PgDn key,
insert key
The Insert key (often abbreviated Ins) is a key commonly found on computer keyboards.
It is primarily used to switch between the two text-entering modes on a personal computer (PC) or word processor:
* overtype mode, in which the cursor, whe ...
,
delete key
The delete key (often abbreviated del) is a button on most computer keyboards which is typically used to delete either (in text mode) the character ahead of or beneath the cursor, or (in GUI mode) the currently-selected object. The key is somet ...
, and so forth)
keystrokes.
Unix and POSIX: termcap, terminfo, et al.
In Unix and other
POSIX
The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
-compliant systems that support the
POSIX terminal interface, these capabilities are encoded in databases that are configured by a system administrator and accessed from programs via the
terminfo
Terminfo is a library and database that enables programs to use display terminals in a device-independent manner. Mary Ann Horton implemented the first terminfo library in 1981–1982 as an improvement over termcap. The improvements include
* fas ...
library (which supersedes the older
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 ...
library), upon which in turn are built libraries such as the
curses
A curse (also called an imprecation, malediction, execration, malison, anathema, or commination) is any expressed wish that some form of adversity or misfortune will befall or attach to one or more persons, a place, or an object. In particular ...
and
ncurses libraries, by which applications programs use the terminal capabilities to provide
textual user interfaces with windows, dialogue boxes, buttons, labels, input fields, menus, and so forth. The intention is that this allows applications programs to be independent of actual terminal characteristics. They don't need to hardwire any control codes or escape sequences into their code, and so don't have problems being used on a range of terminals with a range of capabilities.
termcap
The (for "terminal capabilities") library was developed for BSD systems. It uses a database stored in the file . This database consists of a series of records (each of which consists of one or more lines in the file, joined by backslash characters at the ends of each line that continues onto a following one) each of which represents the capabilities of a particular terminal. The fields of the record comprise the terminal type name, or names, followed by a sequence of capabilities, separated by colons. The capability fields themselves fall into three groups:
;characteristics of the terminal
:These comprise such things as the (nominal) number of rows and columns the terminal's display has, whether output automatically wraps onto the next line when it reaches the end of a line, and so forth.
;control sequences sent as output to the terminal
:These comprise the control codes and escape sequences sent to the terminal in order for it to perform some action (not necessarily a display action). An example of one of the simplest is the output sequence to clear the screen, which may be the
form feed
A page break is a marker in an electronic document that tells the document interpreter the content which follows is part of a new page. A page break causes a form feed to be sent to the printer during spooling of the document to the printer. It i ...
(ASCII ) character on some types of terminal but may, say, be the escape sequence on a terminal that requires
ANSI escape sequence
ANSI escape sequences are a standard for in-band signaling to control cursor location, color, font styling, and other options on video text terminals and terminal emulators. Certain sequences of bytes, most starting with an ASCII escape charac ...
s.
;control sequences sent as input by the terminal
:These comprise the control codes and escape sequences that the terminal sends to the host to represent various actions and events, such as
function key
A function key is a key on a computer or computer terminal, terminal computer keyboard, keyboard that can be programmed to cause the operating system or an application program to perform certain actions, a form of soft key. On some keyboards/com ...
s and
arrow keys being pressed.
terminfo
The terminfo ("terminal information") library was developed for System V systems. It uses a database stored in multiple files within a directory, which can be variously (on different Unices and POSIX-compatible systems) , , or even . (Its location isn't even uniform across different
distributions of Linux.)
Unlike the termcap database, the terminfo database is compiled, a machine-readable database that is constructed from a human-readable source file format by a utility program, . They can be decompiled from machine-readable form back to human-readable form by another utility program, . The command to output the human-readable form of the "vt100" terminal definition, for example, is:
infocmp vt100
The use of a machine-readable format was to avoid the unnecessary overhead, in applications programs using systems such as the termcap library, of repeatedly parsing the database content to read the fields of a record. The use of multiple files was to avoid the similar overhead of parsing the database content to find the database record for the target terminal type. The terminal type name index is, effectively, the Unix/POSIX filesystem's ordinary directory structure. Originally, Unix had severe performance problems with large directories containing many files, and thus terminfo uses a two-level structure, dividing up the directory entries by first letter into a series of subdirectories. More recent filesystem formats used on Unix systems don't suffer as much from such problems (because their on-disc directory structures are no longer simple arrays of entries, but are organized into trees or hash tables) and so the necessity for this design element, that still exists in modern terminfo implementations, has since disappeared.
Utility programs to exercise terminal capabilities
On Unix systems, the command is used to look up a specific capability in the system's database, and output it to the command's
standard output Standard may refer to:
Symbols
* Colours, standards and guidons, kinds of military signs
* Standard (emblem), a type of a large symbol or emblem used for identification
Norms, conventions or requirements
* Standard (metrology), an object t ...
(which is, presumably, the terminal by which the function denoted by the capability is to be performed). One of the simplest operations is clearing the screen. The name of the database field that stores the output sequence for this is , so the command arguments to the program to clear the screen are
tput clear Another operation is initializing or resetting the terminal to a known default state (of character attributes, fonts, colours, and so forth). The commands for this are:
tput init and
tput reset
Normally the command uses the terminal type specified by the
TERM
environment variable
An environment variable is a user-definable value that can affect the way running processes will behave on a computer. Environment variables are part of the environment in which a process runs. For example, a running process can query the va ...
, one of the
controlling environment variables of the POSIX terminal interface. This can be overridden, however, to force to look up a different terminal type in the database, with a command-line option to the command. So, for example, to issue the reset sequence appropriate for the type of terminal named "vt100" in the database (usually a
DEC VT100 terminal), irrespective of terminal type specified in environment variables, the command is:
tput -T vt100 reset
References
What supports what
Sources used
*
*
*
*
*
*
*
Further reading
* {{cite book,
title=Termcap and terminfo,
series=Nutshell handbook,
first1=John, last1=Strang,
first2=Linda, last2=Mui,
first3=Tim, last3=O'Reilly,
edition=3rd,
publisher=O'Reilly Media, Inc.,
year=1991,
isbn=978-0-937175-22-4
Capabilities
Telecommunications equipment