micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 1 | '\" t |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 2 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 3 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 4 | .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 5 | .\" * |
| 6 | .\" Permission is hereby granted, free of charge, to any person obtaining a * |
| 7 | .\" copy of this software and associated documentation files (the * |
| 8 | .\" "Software"), to deal in the Software without restriction, including * |
| 9 | .\" without limitation the rights to use, copy, modify, merge, publish, * |
| 10 | .\" distribute, distribute with modifications, sublicense, and/or sell * |
| 11 | .\" copies of the Software, and to permit persons to whom the Software is * |
| 12 | .\" furnished to do so, subject to the following conditions: * |
| 13 | .\" * |
| 14 | .\" The above copyright notice and this permission notice shall be included * |
| 15 | .\" in all copies or substantial portions of the Software. * |
| 16 | .\" * |
| 17 | .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 18 | .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 19 | .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 20 | .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 21 | .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 22 | .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 23 | .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 24 | .\" * |
| 25 | .\" Except as contained in this notice, the name(s) of the above copyright * |
| 26 | .\" holders shall not be used in advertising or otherwise to promote the * |
| 27 | .\" sale, use or other dealings in this Software without prior written * |
| 28 | .\" authorization. * |
| 29 | .\"*************************************************************************** |
| 30 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 31 | .\" $Id: term.5,v 1.77 2024/04/20 21:24:19 tom Exp $ |
| 32 | .TH term 5 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "File formats" |
| 33 | .ie \n(.g \{\ |
| 34 | .ds `` \(lq |
| 35 | .ds '' \(rq |
| 36 | .ds ' \(aq |
| 37 | .ds ^ \(ha |
| 38 | .\} |
| 39 | .el \{\ |
| 40 | .ie t .ds `` `` |
| 41 | .el .ds `` "" |
| 42 | .ie t .ds '' '' |
| 43 | .el .ds '' "" |
| 44 | .ds ' ' |
| 45 | .ds ^ ^ |
| 46 | .\} |
| 47 | .ie n .ds CW R |
| 48 | .el \{ |
| 49 | .ie \n(.g .ds CW CR |
| 50 | .el .ds CW CW |
| 51 | .\} |
| 52 | . |
| 53 | .de bP |
| 54 | .ie n .IP \(bu 4 |
| 55 | .el .IP \(bu 2 |
| 56 | .. |
| 57 | . |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 58 | .ds d @TERMINFO@ |
| 59 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 60 | term \- |
| 61 | compiled \fIterminfo\fR terminal description |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 62 | .SH SYNOPSIS |
| 63 | .B term |
| 64 | .SH DESCRIPTION |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 65 | .SS "Storage Location" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 66 | Compiled terminfo descriptions are placed under the directory \fB\*d\fP. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 67 | Two configurations are supported |
| 68 | (when building the \fI\%ncurses\fP libraries): |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 69 | .TP 5 |
| 70 | .B directory tree |
| 71 | A two-level scheme is used to avoid a linear search |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 72 | of a huge Unix system directory: \fB\*d/c/name\fP where |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 73 | .I name |
| 74 | is the name of the terminal, and |
| 75 | .I c |
| 76 | is the first character of |
| 77 | .IR name . |
| 78 | Thus, |
| 79 | .I act4 |
| 80 | can be found in the file \fB\*d/a/act4\fP. |
| 81 | Synonyms for the same terminal are implemented by multiple |
| 82 | links to the same compiled file. |
| 83 | .TP 5 |
| 84 | .B hashed database |
| 85 | Using Berkeley database, two types of records are stored: |
| 86 | the terminfo data in the same format as stored in a directory tree with |
| 87 | the terminfo's primary name as a key, |
| 88 | and records containing only aliases pointing to the primary name. |
| 89 | .IP |
| 90 | If built to write hashed databases, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 91 | \fI\%ncurses\fP can still read terminfo databases organized as a |
| 92 | directory tree, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 93 | but cannot write entries into the directory tree. |
| 94 | It can write (or rewrite) entries in the hashed database. |
| 95 | .IP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 96 | \fI\%ncurses\fP distinguishes the two cases in the \fI\%TERMINFO\fP and |
| 97 | \fI\%TERMINFO_DIRS\fP environment variable by assuming a directory tree |
| 98 | for entries that correspond to an existing directory, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 99 | and hashed database otherwise. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 100 | .SS "Legacy Storage Format" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 101 | The format has been chosen so that it will be the same on all hardware. |
| 102 | An 8 or more bit byte is assumed, but no assumptions about byte ordering |
| 103 | or sign extension are made. |
| 104 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 105 | The compiled file is created with the \fB@TIC@\fP program, |
| 106 | and read by the routine \fBsetupterm\fP(3X). |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 107 | The file is divided into six parts: |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 108 | .RS 5 |
| 109 | .TP 3 |
| 110 | a) \fIheader\fP, |
| 111 | .TP 3 |
| 112 | b) \fIterminal names\fP, |
| 113 | .TP 3 |
| 114 | c) \fIBoolean flags\fP, |
| 115 | .TP 3 |
| 116 | d) \fInumbers\fP, |
| 117 | .TP 3 |
| 118 | e) \fIstrings\fP, and |
| 119 | .TP 3 |
| 120 | f) \fIstring table\fP. |
| 121 | .RE |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 122 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 123 | The \fIheader\fP section begins the file. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 124 | This section contains six short integers in the format |
| 125 | described below. |
| 126 | These integers are |
| 127 | .RS 5 |
| 128 | .TP 5 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 129 | (1) the \fImagic number\fP (octal 0432); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 130 | .TP 5 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 131 | (2) the size, in bytes, of the \fIterminal names\fP section; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 132 | .TP 5 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 133 | (3) the number of bytes in the \fIBoolean flags\fP section; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 134 | .TP 5 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 135 | (4) the number of short integers in the \fInumbers\fP section; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 136 | .TP 5 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 137 | (5) the number of offsets (short integers) in the \fIstrings\fP section; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 138 | .TP 5 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 139 | (6) the size, in bytes, of the \fIstring table\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 140 | .RE |
| 141 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 142 | The capabilities in the |
| 143 | \fIBoolean flags\fP, |
| 144 | \fInumbers\fP, and |
| 145 | \fIstrings\fP |
| 146 | sections are in the same order as the file <term.h>. |
| 147 | .PP |
| 148 | Short integers are signed, in the range \-32768 to 32767. |
| 149 | They are stored as two 8-bit bytes. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 150 | The first byte contains the least significant 8 bits of the value, |
| 151 | and the second byte contains the most significant 8 bits. |
| 152 | (Thus, the value represented is 256*second+first.) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 153 | This format corresponds to the hardware of the \s-1VAX\s+1 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 154 | and \s-1PDP\s+1-11 (that is, little-endian machines). |
| 155 | Machines where this does not correspond to the hardware must read the |
| 156 | integers as two bytes and compute the little-endian value. |
| 157 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 158 | Numbers in a terminal description, |
| 159 | whether they are entries in the \fInumbers\fP or \fIstrings\fP table, |
| 160 | are positive integers. |
| 161 | Boolean flags are treated as positive one-byte integers. |
| 162 | In each case, those positive integers represent a terminal capability. |
| 163 | The terminal compiler @TIC@ uses negative integers to handle the cases where |
| 164 | a capability is not available: |
| 165 | .bP |
| 166 | If a capability is absent from this terminal, |
| 167 | @TIC@ stores a \-1 in the corresponding table. |
| 168 | .IP |
| 169 | The integer value \-1 is represented by two bytes 0377, 0377. |
| 170 | .br |
| 171 | Absent Boolean values are represented by the byte 0 (false). |
| 172 | .bP |
| 173 | If a capability has been canceled from this terminal, |
| 174 | @TIC@ stores a \-2 in the corresponding table. |
| 175 | .IP |
| 176 | The integer value \-2 is represented by two bytes 0377, 0376. |
| 177 | .br |
| 178 | The Boolean value \-2 is represented by the byte 0376. |
| 179 | .br |
| 180 | .bP |
| 181 | Other negative values are illegal. |
| 182 | .PP |
| 183 | The \fIterminal names\fP section comes after the \fIheader\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 184 | It contains the first line of the terminfo description, |
| 185 | listing the various names for the terminal, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 186 | separated by the \*(``|\*('' character. |
| 187 | The \fIterminal names\fP section is terminated |
| 188 | with an \s-1ASCII NUL\s+1 character. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 189 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 190 | The \fIBoolean flags\fP section has one byte for each flag. |
| 191 | Boolean capabilities are either 1 or 0 (true or false) |
| 192 | according to whether the terminal supports the given capability or not. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 193 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 194 | Between the \fIBoolean flags\fP section and the \fInumber\fP section, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 195 | a null byte will be inserted, if necessary, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 196 | to ensure that the \fInumber\fP section begins on an even byte |
| 197 | This is a relic of the PDP\-11's word-addressed architecture, |
| 198 | originally designed to avoid traps induced |
| 199 | by addressing a word on an odd byte boundary. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 200 | All short integers are aligned on a short word boundary. |
| 201 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 202 | The \fInumbers\fP section is similar to the \fIBoolean flags\fP section. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 203 | Each capability takes up two bytes, |
| 204 | and is stored as a little-endian short integer. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 205 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 206 | The \fIstrings\fP section is also similar. |
| 207 | Each capability is stored as a short integer. |
| 208 | The capability value is an index into the \fIstring table\fP. |
| 209 | .PP |
| 210 | The \fIstring table\fP is the last section. |
| 211 | It contains all of the values of string capabilities referenced in |
| 212 | the \fIstrings\fP section. |
| 213 | Each string is null-terminated. |
| 214 | Special characters in \*^X or \ec notation are stored in their |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 215 | interpreted form, not the printing representation. |
| 216 | Padding information $<nn> and parameter information %x are |
| 217 | stored intact in uninterpreted form. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 218 | .SS "Extended Storage Format" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 219 | The previous section describes the conventional terminfo binary format. |
| 220 | With some minor variations of the offsets (see PORTABILITY), |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 221 | the same binary format is used in all modern Unix systems. |
| 222 | Each system uses a predefined set of Boolean, number or string capabilities. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 223 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 224 | The \fI\%ncurses\fP libraries and applications support |
| 225 | extended terminfo binary format, |
| 226 | allowing users to define capabilities which are loaded at runtime. |
| 227 | This |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 228 | extension is made possible by using the fact that the other implementations |
| 229 | stop reading the terminfo data when they have reached the end of the size given |
| 230 | in the header. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 231 | \fI\%ncurses\fP checks the size, |
| 232 | and if it exceeds that due to the predefined data, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 233 | continues to parse according to its own scheme. |
| 234 | .PP |
| 235 | First, it reads the extended header (5 short integers): |
| 236 | .RS 5 |
| 237 | .TP 5 |
| 238 | (1) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 239 | count of extended Boolean capabilities |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 240 | .TP 5 |
| 241 | (2) |
| 242 | count of extended numeric capabilities |
| 243 | .TP 5 |
| 244 | (3) |
| 245 | count of extended string capabilities |
| 246 | .TP 5 |
| 247 | (4) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 248 | count of the items in extended string table |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 249 | .TP 5 |
| 250 | (5) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 251 | size of the extended string table in bytes |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 252 | .RE |
| 253 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 254 | The count- and size-values for the extended string table |
| 255 | include the extended capability \fInames\fP as well as |
| 256 | extended capability \fIvalues\fP. |
| 257 | .PP |
| 258 | Using the counts and sizes, |
| 259 | \fI\%ncurses\fP allocates arrays and reads data for the extended |
| 260 | capabilities in the same order as the header information. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 261 | .PP |
| 262 | The extended string table contains values for string capabilities. |
| 263 | After the end of these values, it contains the names for each of |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 264 | the extended capabilities in order, e.g., Booleans, then numbers and |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 265 | finally strings. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 266 | .PP |
| 267 | By storing terminal descriptions in this way, |
| 268 | \fI\%ncurses\fP is able to provide a database useful with legacy |
| 269 | applications, |
| 270 | as well as providing data for applications which need more than the |
| 271 | predefined capabilities. |
| 272 | See \fBuser_caps\fP(5) for an overview |
| 273 | of the way \fI\%ncurses\fP uses this extended information. |
| 274 | .PP |
| 275 | Applications which manipulate terminal data can use the definitions |
| 276 | described in \fBterm_variables\fP(3X) which associate the long capability |
| 277 | names with members of a \fBTERMTYPE\fP structure. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 278 | . |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 279 | .SS "Extended Number Format" |
| 280 | On occasion, 16-bit signed integers are not large enough. |
| 281 | With \fI\%ncurses\fP 6.1, |
| 282 | a new format was introduced by making a few changes |
| 283 | to the legacy format: |
| 284 | .bP |
| 285 | a different magic number (octal 01036) |
| 286 | .bP |
| 287 | changing the type for the \fInumber\fP array from signed 16-bit integers |
| 288 | to signed 32-bit integers. |
| 289 | .PP |
| 290 | To maintain compatibility, the library presents the same data structures |
| 291 | to direct users of the \fBTERMTYPE\fP structure as in previous formats. |
| 292 | However, that cannot provide callers with the extended numbers. |
| 293 | The library uses a similar but hidden data structure \fBTERMTYPE2\fP |
| 294 | to provide data for the terminfo functions. |
| 295 | .SH FILES |
| 296 | .TP |
| 297 | .I \*d |
| 298 | compiled terminal description database |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 299 | .SH PORTABILITY |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 300 | .SS setupterm |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 301 | Note that it is possible for |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 302 | .B setupterm |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 303 | to expect a different set of capabilities |
| 304 | than are actually present in the file. |
| 305 | Either the database may have been updated since |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 306 | .B setupterm |
| 307 | was recompiled |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 308 | (resulting in extra unrecognized entries in the file) |
| 309 | or the program may have been recompiled more recently |
| 310 | than the database was updated |
| 311 | (resulting in missing entries). |
| 312 | The routine |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 313 | .B setupterm |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 314 | must be prepared for both possibilities \- |
| 315 | this is why the numbers and sizes are included. |
| 316 | Also, new capabilities must always be added at the end of the lists |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 317 | of Boolean, number, and string capabilities. |
| 318 | .SS "Binary Format" |
| 319 | X/Open Curses does not specify a format for the terminfo database. |
| 320 | System V curses used a directory-tree of binary files, |
| 321 | one per terminal description. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 322 | .PP |
| 323 | Despite the consistent use of little-endian for numbers and the otherwise |
| 324 | self-describing format, it is not wise to count on portability of binary |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 325 | terminfo entries between commercial Unix versions. |
| 326 | The problem is that there |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 327 | are at least three versions of terminfo (under HP\-UX, AIX, and OSF/1) which |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 328 | diverged from System V terminfo after SVr1, and have added extension |
| 329 | capabilities to the string table that (in the binary format) collide with |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 330 | System V and X/Open Curses extensions. |
| 331 | See \fBterminfo\fP(5) for detailed |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 332 | discussion of terminfo source compatibility issues. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 333 | .PP |
| 334 | This implementation is by default compatible with the binary |
| 335 | terminfo format used by Solaris curses, |
| 336 | except in a few less-used details |
| 337 | where it was found that the latter did not match X/Open Curses. |
| 338 | The format used by the other Unix versions |
| 339 | can be matched by building \fI\%ncurses\fP |
| 340 | with different configuration options. |
| 341 | .SS "Magic Codes" |
| 342 | The magic number in a binary terminfo file is the first 16-bits (two bytes). |
| 343 | Besides making it more reliable for the library to check that a file |
| 344 | is terminfo, |
| 345 | utilities such as \fBfile\fP(1) also use that to tell what the file-format is. |
| 346 | System V defined more than one magic number, |
| 347 | with 0433, 0435 as screen-dumps (see \fBscr_dump\fP(5)). |
| 348 | This implementation uses 01036 as a continuation of that sequence, |
| 349 | but with a different high-order byte to avoid confusion. |
| 350 | .SS "The \fITERMTYPE\fP Structure" |
| 351 | Direct access to the \fBTERMTYPE\fP structure is provided for legacy |
| 352 | applications. |
| 353 | Portable applications should use the \fBtigetflag\fP and related functions |
| 354 | described in \fBcurs_terminfo\fP(3X) for reading terminal capabilities. |
| 355 | .SS "Mixed-case Terminal Names" |
| 356 | A small number of terminal descriptions use uppercase characters in |
| 357 | their names. |
| 358 | If the underlying filesystem ignores the difference between |
| 359 | uppercase and lowercase, |
| 360 | \fI\%ncurses\fP represents the \*(``first character\*('' |
| 361 | of the terminal name used as |
| 362 | the intermediate level of a directory tree in (two-character) hexadecimal form. |
| 363 | .SS Limits |
| 364 | \fI\%ncurses\fP stores compiled terminal descriptions |
| 365 | in three related formats, |
| 366 | described in the sections |
| 367 | .bP |
| 368 | \fBLEGACY STORAGE FORMAT\fP, and |
| 369 | .bP |
| 370 | \fBEXTENDED STORAGE FORMAT\fP, and |
| 371 | .bP |
| 372 | \fBEXTENDED NUMBER FORMAT\fP. |
| 373 | .PP |
| 374 | The legacy storage format and the extended number format differ by |
| 375 | the types of numeric capability which they can store |
| 376 | (i.e., 16-bit versus 32-bit integers). |
| 377 | The extended storage format introduced by \fI\%ncurses\fP 5.0 adds data |
| 378 | to either of these formats. |
| 379 | .PP |
| 380 | Some limitations apply: |
| 381 | .bP |
| 382 | total compiled entries cannot exceed 4096 bytes in the legacy format. |
| 383 | .bP |
| 384 | total compiled entries cannot exceed 32768 bytes in the extended format. |
| 385 | .bP |
| 386 | the name field cannot exceed 128 bytes. |
| 387 | .PP |
| 388 | Compiled entries are limited to 32768 bytes because offsets into the |
| 389 | \fIstrings table\fP use two-byte integers. |
| 390 | The legacy format could have supported 32768-byte entries, |
| 391 | but was limited to a virtual memory page's 4096 bytes. |
| 392 | .SH EXAMPLES |
| 393 | As an example, here is a description for the Lear-Siegler |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 394 | ADM\-3, a popular though rather stupid early terminal: |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 395 | .PP |
| 396 | .EX |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 397 | adm3a|lsi adm3a, |
| 398 | am, |
| 399 | cols#80, lines#24, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 400 | bel=\*^G, clear=\e032$<1>, cr=\*^M, cub1=\*^H, cud1=\*^J, |
| 401 | cuf1=\*^L, cup=\eE=%p1%{32}%+%c%p2%{32}%+%c, cuu1=\*^K, |
| 402 | home=\*^\*^, ind=\*^J, |
| 403 | .EE |
| 404 | .PP |
| 405 | and a hexadecimal dump of the compiled terminal description: |
| 406 | .PP |
| 407 | .if t .in +4n |
| 408 | .ft \*(CW |
| 409 | .TS |
| 410 | Lp-1. |
| 411 | 0000 1a 01 10 00 02 00 03 00 82 00 31 00 61 64 6d 33 ........ ..1.adm3 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 412 | 0010 61 7c 6c 73 69 20 61 64 6d 33 61 00 00 01 50 00 a|lsi ad m3a...P. |
| 413 | 0020 ff ff 18 00 ff ff 00 00 02 00 ff ff ff ff 04 00 ........ ........ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 414 | 0030 ff ff ff ff ff ff ff ff 0a 00 25 00 27 00 ff ff ........ ..%.\*'... |
| 415 | 0040 29 00 ff ff ff ff 2b 00 ff ff 2d 00 ff ff ff ff ).....+. ..\-..... |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 416 | 0050 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 417 | 0060 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 418 | 0070 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 419 | 0080 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 420 | 0090 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 421 | 00a0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 422 | 00b0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 423 | 00c0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 424 | 00d0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 425 | 00e0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 426 | 00f0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 427 | 0100 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 428 | 0110 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 429 | 0120 ff ff ff ff ff ff 2f 00 07 00 0d 00 1a 24 3c 31 ....../. .....$<1 |
| 430 | 0130 3e 00 1b 3d 25 70 31 25 7b 33 32 7d 25 2b 25 63 >..=%p1% {32}%+%c |
| 431 | 0140 25 70 32 25 7b 33 32 7d 25 2b 25 63 00 0a 00 1e %p2%{32} %+%c.... |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 432 | 0150 00 08 00 0c 00 0b 00 0a 00 ........ . |
| 433 | .TE |
| 434 | .ft |
| 435 | .in |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 436 | .SH AUTHORS |
| 437 | Thomas E. Dickey |
| 438 | .br |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 439 | extended terminfo format for \fI\%ncurses\fP 5.0 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 440 | .br |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 441 | hashed database support for \fI\%ncurses\fP 5.6 |
| 442 | .br |
| 443 | extended number support for \fI\%ncurses\fP 6.1 |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 444 | .sp |
| 445 | Eric S. Raymond |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 446 | .br |
| 447 | documented legacy terminfo format, e.g., from \fIpcurses\fP. |
| 448 | .SH SEE ALSO |
| 449 | \fB\%curses\fP(3X), |
| 450 | \fB\%curs_terminfo\fP(3X), |
| 451 | \fB\%terminfo\fP(5), |
| 452 | \fB\%user_caps\fP(5) |