Linux cli command term
4 minute read
NAME 🖥️ term 🖥️
compiled terminfo terminal description
SYNOPSIS
term
DESCRIPTION
Storage Location
Compiled terminfo descriptions are placed under the directory /etc/terminfo. Two configurations are supported (when building the ncurses libraries):
directory tree
A two-level scheme is used to avoid a linear search of a huge Unix system directory: /etc/terminfo/c/name where name is the name of the terminal, and c is the first character of name. Thus, act4 can be found in the file /etc/terminfo/a/act4. Synonyms for the same terminal are implemented by multiple links to the same compiled file.
hashed database
Using Berkeley database, two types of records are stored: the terminfo data in the same format as stored in a directory tree with the terminfo’s primary name as a key, and records containing only aliases pointing to the primary name.
If built to write hashed databases, ncurses can still read terminfo databases organized as a directory tree, but cannot write entries into the directory tree. It can write (or rewrite) entries in the hashed database.
ncurses distinguishes the two cases in the TERMINFO and TERMINFO_DIRS environment variable by assuming a directory tree for entries that correspond to an existing directory, and hashed database otherwise.
Legacy Storage Format
The format has been chosen so that it will be the same on all hardware. An 8 or more bit byte is assumed, but no assumptions about byte ordering or sign extension are made.
The compiled file is created with the tic program, and read by the routine setupterm(3NCURSES). The file is divided into six parts:
a) header,
b) terminal names,
c) Boolean flags,
d) numbers,
e) strings, and
f) string table.The header section begins the file. This section contains six short integers in the format described below. These integers are
(1) the magic number (octal 0432);
(2) the size, in bytes, of the terminal names section;
(3) the number of bytes in the Boolean flags section;
(4) the number of short integers in the numbers section;
(5) the number of offsets (short integers) in the strings section;
(6) the size, in bytes, of the string table.The capabilities in the Boolean flags, numbers, and strings sections are in the same order as the file <term.h>.
Short integers are signed, in the range -32768 to 32767. They are stored as two 8-bit bytes. The first byte contains the least significant 8 bits of the value, and the second byte contains the most significant 8 bits. (Thus, the value represented is 256*second+first.) This format corresponds to the hardware of the VAX and PDP-11 (that is, little-endian machines). Machines where this does not correspond to the hardware must read the integers as two bytes and compute the little-endian value.
Numbers in a terminal description, whether they are entries in the numbers or strings table, are positive integers. Boolean flags are treated as positive one-byte integers. In each case, those positive integers represent a terminal capability. The terminal compiler tic uses negative integers to handle the cases where a capability is not available:
If a capability is absent from this terminal, tic stores a -1 in the corresponding table.
The integer value -1 is represented by two bytes 0377, 0377.
Absent Boolean values are represented by the byte 0 (false).If a capability has been canceled from this terminal, tic stores a -2 in the corresponding table.
The integer value -2 is represented by two bytes 0377, 0376.
The Boolean value -2 is represented by the byte 0376.Other negative values are illegal.
The terminal names section comes after the header. It contains the first line of the terminfo description, listing the various names for the terminal, separated by the | character. The terminal names section is terminated with an ASCII NUL character.
The Boolean flags section has one byte for each flag. Boolean capabilities are either 1 or 0 (true or false) according to whether the terminal supports the given capability or not.
Between the Boolean flags section and the number section, a null byte will be inserted, if necessary, to ensure that the number section begins on an even byte This is a relic of the PDP-11’s word-addressed architecture, originally designed to avoid traps induced by addressing a word on an odd byte boundary. All short integers are aligned on a short word boundary.
The numbers section is similar to the Boolean flags section. Each capability takes up two bytes, and is stored as a little-endian short integer.
The strings section is also similar. Each capability is stored as a short integer. The capability value is an index into the string table.
The string table is the last section. It contains all of the values of string capabilities referenced in the strings section. Each string is null-terminated. Special characters in X or
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.