]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/term.5
ncurses 6.0 - patch 20171209
[ncurses.git] / man / term.5
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2016,2017 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: term.5,v 1.26 2017/02/18 16:58:21 tom Exp $
30 .TH term 5
31 .ie \n(.g .ds `` \(lq
32 .el       .ds `` ``
33 .ie \n(.g .ds '' \(rq
34 .el       .ds '' ''
35 .ds n 5
36 .ds d @TERMINFO@
37 .SH NAME
38 term \- format of compiled term file.
39 .SH SYNOPSIS
40 .B term
41 .SH DESCRIPTION
42 .SS STORAGE LOCATION
43 Compiled terminfo descriptions are placed under the directory \fB\*d\fP.
44 Two configurations are supported (when building the ncurses libraries):
45 .TP 5
46 .B directory tree
47 A two-level scheme is used to avoid a linear search
48 of a huge \s-1UNIX\s+1 system directory: \fB\*d/c/name\fP where
49 .I name
50 is the name of the terminal, and
51 .I c
52 is the first character of
53 .IR name .
54 Thus,
55 .I act4
56 can be found in the file \fB\*d/a/act4\fP.
57 Synonyms for the same terminal are implemented by multiple
58 links to the same compiled file.
59 .TP 5
60 .B hashed database
61 Using Berkeley database, two types of records are stored:
62 the terminfo data in the same format as stored in a directory tree with
63 the terminfo's primary name as a key,
64 and records containing only aliases pointing to the primary name.
65 .IP
66 If built to write hashed databases,
67 ncurses can still read terminfo databases organized as a directory tree,
68 but cannot write entries into the directory tree.
69 It can write (or rewrite) entries in the hashed database.
70 .IP
71 ncurses distinguishes the two cases in the TERMINFO and TERMINFO_DIRS
72 environment variable by assuming a directory tree for entries that
73 correspond to an existing directory,
74 and hashed database otherwise.
75 .SS STORAGE FORMAT
76 The format has been chosen so that it will be the same on all hardware.
77 An 8 or more bit byte is assumed, but no assumptions about byte ordering
78 or sign extension are made.
79 .PP
80 The compiled file is created with the \fB@TIC@\fP program,
81 and read by the routine \fBsetupterm\fP(3X).
82 The file is divided into six parts:
83 the header,
84 terminal names,
85 boolean flags,
86 numbers,
87 strings,
88 and
89 string table.
90 .PP
91 The header section begins the file.
92 This section contains six short integers in the format
93 described below.
94 These integers are
95 .RS 5
96 .TP 5
97 (1) the magic number (octal 0432);
98 .TP 5
99 (2) the size, in bytes, of the names section;
100 .TP 5
101 (3) the number of bytes in the boolean section;
102 .TP 5
103 (4) the number of short integers in the numbers section;
104 .TP 5
105 (5) the number of offsets (short integers) in the strings section;
106 .TP 5
107 (6) the size, in bytes, of the string table.
108 .RE
109 .PP
110 Short integers are stored in two 8-bit bytes.
111 The first byte contains the least significant 8 bits of the value,
112 and the second byte contains the most significant 8 bits.
113 (Thus, the value represented is 256*second+first.)
114 The value \-1 is represented by the two bytes 0377, 0377; other negative
115 values are illegal. This value generally
116 means that the corresponding capability is missing from this terminal.
117 Note that this format corresponds to the hardware of the \s-1VAX\s+1
118 and \s-1PDP\s+1-11 (that is, little-endian machines).
119 Machines where this does not correspond to the hardware must read the
120 integers as two bytes and compute the little-endian value.
121 .PP
122 The terminal names section comes next.
123 It contains the first line of the terminfo description,
124 listing the various names for the terminal,
125 separated by the \*(``|\*('' character.
126 The section is terminated with an \s-1ASCII NUL\s+1 character.
127 .PP
128 The boolean flags have one byte for each flag.
129 This byte is either 0 or 1 as the flag is present or absent.
130 The capabilities are in the same order as the file <term.h>.
131 .PP
132 Between the boolean section and the number section,
133 a null byte will be inserted, if necessary,
134 to ensure that the number section begins on an even byte (this is a
135 relic of the PDP\-11's word-addressed architecture, originally
136 designed in to avoid IOT traps induced by addressing a word on an
137 odd byte boundary).
138 All short integers are aligned on a short word boundary.
139 .PP
140 The numbers section is similar to the flags section.
141 Each capability takes up two bytes,
142 and is stored as a little-endian short integer.
143 If the value represented is \-1, the capability is taken to be missing.
144 .PP
145 The strings section is also similar.
146 Each capability is stored as a short integer, in the format above.
147 A value of \-1 means the capability is missing.
148 Otherwise, the value is taken as an offset from the beginning
149 of the string table.
150 Special characters in ^X or \ec notation are stored in their
151 interpreted form, not the printing representation.
152 Padding information $<nn> and parameter information %x are
153 stored intact in uninterpreted form.
154 .PP
155 The final section is the string table.
156 It contains all the values of string capabilities referenced in
157 the string section.
158 Each string is null terminated.
159 .SS EXTENDED STORAGE FORMAT
160 The previous section describes the conventional terminfo binary format.
161 With some minor variations of the offsets (see PORTABILITY),
162 the same binary format is used in all modern UNIX systems.
163 Each system uses a predefined set of boolean, number or string capabilities.
164 .PP
165 The ncurses libraries and applications support extended terminfo binary format,
166 allowing users to define capabilities which are loaded at runtime.  This
167 extension is made possible by using the fact that the other implementations
168 stop reading the terminfo data when they have reached the end of the size given
169 in the header.
170 ncurses checks the size, and if it exceeds that due to the predefined data,
171 continues to parse according to its own scheme.
172 .PP
173 First, it reads the extended header (5 short integers):
174 .RS 5
175 .TP 5
176 (1)
177 count of extended boolean capabilities
178 .TP 5
179 (2)
180 count of extended numeric capabilities
181 .TP 5
182 (3)
183 count of extended string capabilities
184 .TP 5
185 (4)
186 size of the extended string table in bytes.
187 .TP 5
188 (5)
189 last offset of the extended string table in bytes.
190 .RE
191 .PP
192 Using the counts and sizes, ncurses allocates arrays and reads data
193 for the extended capabilities in the same order as the header information.
194 .PP
195 The extended string table contains values for string capabilities.
196 After the end of these values, it contains the names for each of
197 the extended capabilities in order, e.g., booleans, then numbers and
198 finally strings.
199 .
200 .SH PORTABILITY
201 Note that it is possible for
202 .B setupterm
203 to expect a different set of capabilities
204 than are actually present in the file.
205 Either the database may have been updated since
206 .B setupterm
207 has been recompiled
208 (resulting in extra unrecognized entries in the file)
209 or the program may have been recompiled more recently
210 than the database was updated
211 (resulting in missing entries).
212 The routine
213 .B setupterm
214 must be prepared for both possibilities \-
215 this is why the numbers and sizes are included.
216 Also, new capabilities must always be added at the end of the lists
217 of boolean, number, and string capabilities.
218 .PP
219 Despite the consistent use of little-endian for numbers and the otherwise
220 self-describing format, it is not wise to count on portability of binary
221 terminfo entries between commercial UNIX versions.  The problem is that there
222 are at least three versions of terminfo (under HP\-UX, AIX, and OSF/1) which
223 diverged from System V terminfo after SVr1, and have added extension
224 capabilities to the string table that (in the binary format) collide with
225 System V and XSI Curses extensions.  See \fBterminfo\fR(\*n) for detailed
226 discussion of terminfo source compatibility issues.
227 .SH EXAMPLE
228 As an example, here is a hex dump of the description for the Lear-Siegler
229 ADM\-3, a popular though rather stupid early terminal:
230 .nf
231 .sp
232 adm3a|lsi adm3a,
233         am,
234         cols#80, lines#24,
235         bel=^G, clear=\032$<1>, cr=^M, cub1=^H, cud1=^J,
236         cuf1=^L, cup=\\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K,
237         home=^^, ind=^J,
238 .sp
239 .ft CW
240 \s-20000  1a 01 10 00 02 00 03 00  82 00 31 00 61 64 6d 33  ........ ..1.adm3
241 0010  61 7c 6c 73 69 20 61 64  6d 33 61 00 00 01 50 00  a|lsi ad m3a...P.
242 0020  ff ff 18 00 ff ff 00 00  02 00 ff ff ff ff 04 00  ........ ........
243 0030  ff ff ff ff ff ff ff ff  0a 00 25 00 27 00 ff ff  ........ ..%.'...
244 0040  29 00 ff ff ff ff 2b 00  ff ff 2d 00 ff ff ff ff  ).....+. ..-.....
245 0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
246 0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
247 0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
248 0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
249 0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
250 00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
251 00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
252 00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
253 00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
254 00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
255 00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
256 0100  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
257 0110  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
258 0120  ff ff ff ff ff ff 2f 00  07 00 0d 00 1a 24 3c 31  ....../. .....$<1
259 0130  3e 00 1b 3d 25 70 31 25  7b 33 32 7d 25 2b 25 63  >..=%p1% {32}%+%c
260 0140  25 70 32 25 7b 33 32 7d  25 2b 25 63 00 0a 00 1e  %p2%{32} %+%c....
261 0150  00 08 00 0c 00 0b 00 0a  00                       ........ .\s+2
262 .ft R
263 .fi
264 .sp
265 .SH LIMITS
266 Some limitations: total compiled entries cannot exceed 4096 bytes.
267 The name field cannot exceed 128 bytes.
268 .SH FILES
269 \*d/*/* compiled terminal capability data base
270 .SH SEE ALSO
271 \fBcurses\fR(3X), \fBterminfo\fR(\*n).
272 .SH AUTHORS
273 Thomas E. Dickey
274 .br
275 extended terminfo format for ncurses 5.0
276 .br
277 hashed database support for ncurses 5.6
278 .sp
279 Eric S. Raymond