xref: /freebsd/contrib/ncurses/man/infocmp.1m (revision 21817992b3314c908ab50f0bb88d2ee750b9c4ac)
t
***************************************************************************
Copyright 2018-2023,2024 Thomas E. Dickey *
Copyright 1998-2017,2018 Free Software Foundation, Inc. *
*
Permission is hereby granted, free of charge, to any person obtaining a *
copy of this software and associated documentation files (the *
"Software"), to deal in the Software without restriction, including *
without limitation the rights to use, copy, modify, merge, publish, *
distribute, distribute with modifications, sublicense, and/or sell *
copies of the Software, and to permit persons to whom the Software is *
furnished to do so, subject to the following conditions: *
*
The above copyright notice and this permission notice shall be included *
in all copies or substantial portions of the Software. *
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
*
Except as contained in this notice, the name(s) of the above copyright *
holders shall not be used in advertising or otherwise to promote the *
sale, use or other dealings in this Software without prior written *
authorization. *
***************************************************************************

$Id: infocmp.1m,v 1.109 2024/03/16 15:35:01 tom Exp $
@INFOCMP@ 1M 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
.\} .\} . .. .
NAME
@INFOCMP@ - compare or print out terminfo descriptions
SYNOPSIS
@INFOCMP@ [-\ 1\ c\ C\ d\ D\ e\ E\ F\ g\ G\ i\ I\ K\ l\ L\ n\ p\ q\ r\ t\ T\ u\ U\ V\ W\ x\ ] [-v n] [-s d| i| l| c] [-Q n] [-R subset] [-w width] [-A directory] [-B directory] [terminal-type ...]
DESCRIPTION
@INFOCMP@ can be used to compare a binary terminfo entry with other terminfo entries, rewrite a terminfo description to take advantage of the use= terminfo field, or print out a terminfo description from the binary file (term) in a variety of formats. In all cases, the Boolean fields will be printed first, followed by the numeric fields, followed by the string fields.
"Default Options"
If no options are specified and zero or one terminal-types are specified, the -I option will be assumed. If more than one terminal-type is specified, the -d option will be assumed.
"Comparison Options [-d] [-c] [-n]"
@INFOCMP@ compares the terminfo description of the first terminal terminal-type with each of the descriptions given by the entries for the other terminal's terminal-types. If a capability is defined for only one of the terminals, the value returned depends on the type of the capability: .bP F for missing Boolean variables .bP NULL for missing integer or string variables

Use the -q option to show the distinction between absent and cancelled capabilities.

These options produce a list which you can use to compare two or more terminal descriptions:

5 -d produces a list of each capability that is different between two entries. Each item in the list shows \*(``:\*('' after the capability name, followed by the capability values, separated by a comma.

-c produces a list of each capability that is common between two or more entries. Missing capabilities are ignored. Each item in the list shows \*(``=\*('' after the capability name, followed by the capability value.

The -u option provides a related output, showing the first terminal description rewritten to use the second as a building block via the \*(``use=\*('' clause.

-n produces a list of each capability that is in none of the given entries. Each item in the list shows \*(``!\*('' before the capability name.

Normally only the conventional capabilities are shown. Use the -x option to add the BSD-compatibility capabilities (names prefixed with \*(``OT\*('').
If no terminal-types are given, @INFOCMP@ uses the environment variable TERM for each of the terminal-types.
"Source Listing Options [-I] [-L] [-C] [-r]"
The -I, -L, and -C options will produce a source listing for each terminal named.

-I use terminfo capability codes
-L use \*(``long\*('' capability names
-C use termcap capability codes
-r with -C, include nonstandard capabilities
-K with -C, improve BSD compatibility

If no terminal-types are given, the environment variable TERM will be used for the terminal name.

The source produced by the -C option may be used directly as a termcap entry, but not all parameterized strings can be changed to the termcap format. @INFOCMP@ will attempt to convert most of the parameterized information, and anything not converted will be plainly marked in the output and commented out. These should be edited by hand.

For best results when converting to termcap format, you should use both -C and -r. Normally a termcap description is limited to 1023 bytes. @INFOCMP@ trims away less essential parts to make it fit. If you are converting to one of the (rare) termcap implementations which accept an unlimited size of termcap, you may want to add the -T option. More often however, you must help the termcap implementation, and trim excess whitespace (use the -0 option for that).

All padding information for strings will be collected together and placed at the beginning of the string where termcap expects it. Mandatory padding (padding information with a trailing \*(``/\*('') will become optional.

All termcap variables no longer supported by terminfo, but which are derivable from other terminfo variables, will be output. Not all terminfo capabilities will be translated; only those variables which were part of termcap will normally be output. Specifying the -r option will take off this restriction, allowing all capabilities to be output in termcap form. Normally you would use both the -C and -r options. The actual format used incorporates some improvements for escaped characters from terminfo format. For a stricter BSD-compatible translation, use the -K option rather than -C.

Note that because padding is collected to the beginning of the capability, not all capabilities are output. Mandatory padding is not supported. Because termcap strings are not as flexible, it is not always possible to convert a terminfo string capability into an equivalent termcap format. A subsequent conversion of the termcap file back into terminfo format will not necessarily reproduce the original terminfo source.

Some common terminfo parameter sequences, their termcap equivalents, and some terminal types which commonly have such sequences, are:

terminfo termcap Terminal Types
.\" ansi-m cup (adm3a has other stuff in between, more like concept)
%p1%c %. ansi-m
.\" ansi cub, vt100 cub
%p1%d %d ansi, vt100
.\" vt52 cup (via vt52-basic)
%p1%\*' \*'%+%c %+x vt52
.\" ansi cup, vt100 cup
%i %iq ansi, vt100
.\" annarbor4080 cup
%p1%?%\*'x\*'%>%t%p1%\*'y\*'%+%; %>xy annarbor4080
.\" hpgeneric cup
%p2\|.\|.\|.\|%p1 %r hpgeneric
"Use= Option [-u]"
The -u option produces a terminfo source description of the first terminal terminal-type which is relative to the sum of the descriptions given by the entries for the other terminal-types. It does this by analyzing the differences between the first terminal-types and the other terminal-types and producing a description with use= fields for the other terminals. In this manner, it is possible to retrofit generic terminfo entries into a terminal's description. Or, if two similar terminals exist, but were coded at different times or by different people so that each description is a full description, using @INFOCMP@ will show what can be done to change one description to be relative to the other.

A capability will be printed with an at-sign (@) if it no longer exists in the first terminal-type, but one of the other terminal-type entries contains a value for it. A capability's value will be printed if the value in the first terminal-type is not found in any of the other terminal-type entries, or if the first of the other terminal-type entries that has this capability gives a different value for the capability than that in the first terminal-type.

The order of the other terminal-type entries is significant. Since the terminfo compiler @TIC@ does a left-to-right scan of the capabilities, specifying two use= entries that contain differing entries for the same capabilities will produce different results depending on the order that the entries are given in. @INFOCMP@ will flag any such inconsistencies between the other terminal-type entries as they are found.

Alternatively, specifying a capability after a use= entry that contains that capability will cause the second specification to be ignored. Using @INFOCMP@ to recreate a description can be a useful check to make sure that everything was specified correctly in the original source description.

Another error that does not cause incorrect compiled files, but will slow down the compilation time, is specifying extra use= fields that are superfluous. @INFOCMP@ will flag any other terminal-type use= fields that were not needed.

"Changing Databases [-A directory] [-B directory]"
Like other \%ncurses utilities, @INFOCMP@ looks for the terminal descriptions in several places. You can use the \%TERMINFO and \%TERMINFO_DIRS environment variables to override the compiled-in default list of places to search. See curses(3X), as well as the Fetching Compiled Descriptions section in terminfo(5).

You can also use the options -A and -B to override the list of places to search when comparing terminal descriptions: .bP The -A option sets the location for the first terminal-type .bP The -B option sets the location for the other terminal-types.

Using these options, it is possible to compare descriptions for a terminal with the same name located in two different databases. For instance, you can use this feature for comparing descriptions for the same terminal created by different people.

"Other Options"

5 -0 causes the fields to be printed on one line, without wrapping.

5 -1 causes the fields to be printed out one to a line. Otherwise, the fields will be printed several to a line to a maximum width of 60 characters.

-a tells @INFOCMP@ to retain commented-out capabilities rather than discarding them. Capabilities are commented by prefixing them with a period.

-D tells @INFOCMP@ to print the database locations that it knows about, and exit.

5 -E Dump the capabilities of the given terminal as tables, needed in the C initializer for a TERMTYPE structure (the terminal capability structure in the <term.h>). This option is useful for preparing versions of the curses library hardwired for a given terminal type. The tables are all declared static, and are named according to the type and the name of the corresponding terminal entry. Before \%ncurses 5.0, the split between the -e and -E options was not needed; but support for extended names required making the arrays of terminal capabilities separate from the TERMTYPE structure.

5 -e Dump the capabilities of the given terminal as a C initializer for a TERMTYPE structure (the terminal capability structure in the <term.h>). This option is useful for preparing versions of the curses library hardwired for a given terminal type.

5 -F compare terminfo files. This assumes that two following arguments are filenames. The files are searched for pairwise matches between entries, with two entries considered to match if any of their names do. The report printed to standard output lists entries with no matches in the other file, and entries with more than one match. For entries with exactly one match it includes a difference report. Normally, to reduce the volume of the report, use references are not resolved before looking for differences, but resolution can be forced by also specifying -r.

5 -f Display complex terminfo strings which contain if/then/else/endif expressions indented for readability.

5 -G Display constant literals in decimal form rather than their character equivalents.

5 -g Display constant character literals in quoted form rather than their decimal equivalents.

5 -i Analyze the initialization (is1, is2, is3), and reset (rs1, rs2, rs3), strings in the entry, as well as those used for starting/stopping cursor-positioning mode (smcup, rmcup) as well as starting/stopping keymap mode (smkx, rmkx).

For each string, the code tries to analyze it into actions in terms of the other capabilities in the entry, certain X3.64/ISO 6429/ECMA-48 capabilities, and certain DEC VT-series private modes (the set of recognized special sequences has been selected for completeness over the existing terminfo database). Each report line consists of the capability name, followed by a colon and space, followed by a printable expansion of the capability string with sections matching recognized actions translated into {}-bracketed descriptions.
Here is a list of the DEC/ANSI special sequences recognized:

Action Meaning
RIS full reset
SC save cursor
RC restore cursor
LL home-down
RSR reset scroll region
DECSTR soft reset (VT320)
S7C1T 7-bit controls (VT220)
ISO DEC G0 enable DEC graphics for G0
ISO UK G0 enable UK chars for G0
ISO US G0 enable US chars for G0
ISO DEC G1 enable DEC graphics for G1
ISO UK G1 enable UK chars for G1
ISO US G1 enable US chars for G1
DECPAM application keypad mode
DECPNM normal keypad mode
DECANSI enter ANSI mode
ECMA[+-]AM keyboard action mode
ECMA[+-]IRM insert replace mode
ECMA[+-]SRM send receive mode
ECMA[+-]LNM linefeed mode
DEC[+-]CKM application cursor keys
DEC[+-]ANM set VT52 mode
DEC[+-]COLM 132-column mode
DEC[+-]SCLM smooth scroll
DEC[+-]SCNM reverse video mode
DEC[+-]OM origin mode
DEC[+-]AWM wraparound mode
DEC[+-]ARM auto-repeat mode
It also recognizes a SGR action corresponding to ANSI/ISO 6429/ECMA Set Graphics Rendition, with the values NORMAL, BOLD, UNDERLINE, BLINK, and REVERSE. All but NORMAL may be prefixed with

.bP \*(``+\*('' (turn on) or .bP \*(``-\*('' (turn off).

An SGR0 designates an empty highlight sequence (equivalent to {SGR:NORMAL}).

5 -l Set output format to terminfo.

5 -p Ignore padding specifications when comparing strings.

5 -Q n Rather than show source in terminfo (text) format, print the compiled (binary) format in hexadecimal or base64 form, depending on the option's value:

3 1 hexadecimal

3 2 base64

3 3 hexadecimal and base64

For example, this prints the compiled terminfo value as a string which could be assigned to the \%TERMINFO environment variable:

.EX @INFOCMP@ -0 -q -Q2

5 -q This makes the output a little shorter:

.bP Make the comparison listing shorter by omitting subheadings, and using \*(``-\*('' for absent capabilities, \*(``@\*('' for canceled rather than \*(``NULL\*(''. .bP However, show differences between absent and cancelled capabilities. .bP Omit the \*(``Reconstructed from\*('' comment for source listings.

5 -Rsubset Restrict output to a given subset. This option is for use with archaic versions of terminfo like those on SVr1, Ultrix, or HP-UX that do not support the full set of SVR4/XSI Curses terminfo; and variants such as AIX that have their own extensions incompatible with SVr4/XSI.

.bP Available terminfo subsets are \*(``SVr1\*('', \*(``Ultrix\*('', \*(``HP\*('', and \*(``AIX\*(''; see terminfo(5) for details. .bP You can also choose the subset \*(``BSD\*('' which selects only capabilities with termcap equivalents recognized by 4.4BSD. .bP If you select any other value for -R, it is the same as no subset, i.e., all capabilities are used.

A few options override the subset selected with -R, if they are processed later in the command parameters:

5 -C sets the \*(``BSD\*('' subset as a side-effect.

5 -I sets the subset to all capabilities.

5 -r sets the subset to all capabilities.

-s [d|i|l|c] The -s option sorts the fields within each type according to the argument below:

5 d leave fields in the order that they are stored in the terminfo database.

5 i sort by terminfo name.

5 l sort by the long C variable name.

5 c sort by the termcap name.

If the -s option is not given, the fields printed out will be sorted alphabetically by the terminfo name within each type, except in the case of the -C or the -L options, which cause the sorting to be done by the termcap name or the long C variable name, respectively.

5 -T eliminates size-restrictions on the generated text. This is mainly useful for testing and analysis, since the compiled descriptions are limited (e.g., 1023 for termcap, 4096 for terminfo).

-t tells @TIC@ to discard commented-out capabilities. Normally when translating from terminfo to termcap, untranslatable capabilities are commented-out.

5 -U tells @INFOCMP@ to not post-process the data after parsing the source file. This feature helps when comparing the actual contents of two source files, since it excludes the inferences that @INFOCMP@ makes to fill in missing data.

5 -V reports the version of \%ncurses which was used in this program, and exits.

5 -v n prints out tracing information on standard error as the program runs.

The optional parameter n is a number from 1 to 10, inclusive, indicating the desired level of detail of information. If \%ncurses is built without tracing support, the optional parameter is ignored.

-W By itself, the -w option will not force long strings to be wrapped. Use the -W option to do this.

5 -w width changes the output to width characters.

-x print information for user-defined capabilities (see user_caps(5). These are extensions to the terminfo repertoire which can be loaded using the -x option of @TIC@.

FILES

\*d compiled terminal description database

EXTENSIONS
The -0, -1, -E, -F, -G, -Q, -R, -T, -V, -a, -e, -f, -g, -i, -l, -p, -q and -t options are not supported in SVr4 curses.

SVr4 infocmp does not distinguish between absent and cancelled capabilities. Also, it shows missing integer capabilities as -1 (the internal value used to represent missing integers). This implementation shows those as \*(``NULL\*('', for consistency with missing strings.

The -r option's notion of \*(``termcap\*('' capabilities is System V Release 4's. Actual BSD curses versions will have a more restricted set. To see only the 4.4BSD set, use -r -RBSD.

PORTABILITY
X/Open Curses, Issue 7 (2009) provides a description of infocmp. It does not mention the options used for converting to termcap format.
HISTORY
Although System V Release 2 provided a terminfo library, it had no documented tool for decompiling the terminal descriptions. Tony Hansen (AT&T) wrote the first infocmp in early 1984, for System V Release 3.

Eric Raymond used the AT&T documentation in 1995 to provide an equivalent @INFOCMP@ for \%ncurses. In addition, he added a few new features such as: .bP the -e option, to support fallback (compiled-in) terminal descriptions .bP the -i option, to help with analysis

Later, Thomas Dickey added the -x (user-defined capabilities) option, and the -E option to support fallback entries with user-defined capabilities.

For a complete list, see the EXTENSIONS section.

In 2010, Roy Marples provided an infocmp program for NetBSD. It is less capable than the SVr4 or \%ncurses versions (e.g., it lacks the sorting options documented in X/Open), but does include the -x option adapted from \%ncurses.

BUGS
The -F option of \%@INFOCMP@(1M) should be a \%@TOE@(1M) mode.
AUTHORS
Eric S. Raymond <esr@snark.thyrsus.com> and

Thomas E. Dickey <dickey@invisible-island.net>

SEE ALSO
\%@CAPTOINFO@(1M), \%@INFOTOCAP@(1M), \%@TIC@(1M), \%@TOE@(1M), \%curses(3X), \%terminfo(5), \%user_caps(5)

https://invisible-island.net/ncurses/tctest.html