]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/terminfo.tail
ncurses 6.2 - patch 20210905
[ncurses.git] / man / terminfo.tail
1 .\"***************************************************************************
2 .\" Copyright 2018-2020,2021 Thomas E. Dickey                                *
3 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: terminfo.tail,v 1.106 2021/08/28 19:00:29 tom Exp $
31 .ps +1
32 .SS User-Defined Capabilities
33 .
34 The preceding section listed the \fIpredefined\fP capabilities.
35 They deal with some special features for terminals no longer
36 (or possibly never) produced.
37 Occasionally there are special features of newer terminals which
38 are awkward or impossible to represent by reusing the predefined
39 capabilities.
40 .PP
41 \fBncurses\fP addresses this limitation by allowing user-defined capabilities.
42 The \fB@TIC@\fP and \fB@INFOCMP@\fP programs provide
43 the \fB\-x\fP option for this purpose.
44 When \fB\-x\fP is set,
45 \fB@TIC@\fP treats unknown capabilities as user-defined.
46 That is, if \fB@TIC@\fP encounters a capability name
47 which it does not recognize,
48 it infers its type (boolean, number or string) from the syntax
49 and makes an extended table entry for that capability.
50 The \fBuse_extended_names\fP(3X) function makes this information
51 conditionally available to applications.
52 The ncurses library provides the data leaving most of the behavior
53 to applications:
54 .bP
55 User-defined capability strings whose name begins
56 with \*(``k\*('' are treated as function keys.
57 .bP
58 The types (boolean, number, string) determined by \fB@TIC@\fP
59 can be inferred by successful calls on \fBtigetflag\fP, etc.
60 .bP
61 If the capability name happens to be two characters,
62 the capability is also available through the termcap interface.
63 .PP
64 While termcap is said to be extensible because it does not use a predefined set
65 of capabilities,
66 in practice it has been limited to the capabilities defined by
67 terminfo implementations.
68 As a rule,
69 user-defined capabilities intended for use by termcap applications should
70 be limited to booleans and numbers to avoid running past the 1023 byte
71 limit assumed by termcap implementations and their applications.
72 In particular, providing extended sets of function keys (past the 60
73 numbered keys and the handful of special named keys) is best done using
74 the longer names available using terminfo.
75 .
76 .SS A Sample Entry
77 .
78 The following entry, describing an ANSI-standard terminal, is representative
79 of what a \fBterminfo\fR entry for a modern terminal typically looks like.
80 .PP
81 .nf
82 .ft CW
83 \s-2ansi|ansi/pc-term compatible with color,
84         am, mc5i, mir, msgr,
85         colors#8, cols#80, it#8, lines#24, ncv#3, pairs#64,
86         acsc=+\\020\\,\\021-\\030.^Y0\\333`\\004a\\261f\\370g\\361h\\260
87              j\\331k\\277l\\332m\\300n\\305o~p\\304q\\304r\\304s_t\\303
88              u\\264v\\301w\\302x\\263y\\363z\\362{\\343|\\330}\\234~\\376,
89         bel=^G, blink=\\E[5m, bold=\\E[1m, cbt=\\E[Z, clear=\\E[H\\E[J,
90         cr=^M, cub=\\E[%p1%dD, cub1=\\E[D, cud=\\E[%p1%dB, cud1=\\E[B,
91         cuf=\\E[%p1%dC, cuf1=\\E[C, cup=\\E[%i%p1%d;%p2%dH,
92         cuu=\\E[%p1%dA, cuu1=\\E[A, dch=\\E[%p1%dP, dch1=\\E[P,
93         dl=\\E[%p1%dM, dl1=\\E[M, ech=\\E[%p1%dX, ed=\\E[J, el=\\E[K,
94         el1=\\E[1K, home=\\E[H, hpa=\\E[%i%p1%dG, ht=\\E[I, hts=\\EH,
95         ich=\\E[%p1%d@, il=\\E[%p1%dL, il1=\\E[L, ind=^J,
96         indn=\\E[%p1%dS, invis=\\E[8m, kbs=^H, kcbt=\\E[Z, kcub1=\\E[D,
97         kcud1=\\E[B, kcuf1=\\E[C, kcuu1=\\E[A, khome=\\E[H, kich1=\\E[L,
98         mc4=\\E[4i, mc5=\\E[5i, nel=\\r\\E[S, op=\\E[39;49m,
99         rep=%p1%c\\E[%p2%{1}%-%db, rev=\\E[7m, rin=\\E[%p1%dT,
100         rmacs=\\E[10m, rmpch=\\E[10m, rmso=\\E[m, rmul=\\E[m,
101         s0ds=\\E(B, s1ds=\\E)B, s2ds=\\E*B, s3ds=\\E+B,
102         setab=\\E[4%p1%dm, setaf=\\E[3%p1%dm,
103         sgr=\\E[0;10%?%p1%t;7%;
104                    %?%p2%t;4%;
105                    %?%p3%t;7%;
106                    %?%p4%t;5%;
107                    %?%p6%t;1%;
108                    %?%p7%t;8%;
109                    %?%p9%t;11%;m,
110         sgr0=\\E[0;10m, smacs=\\E[11m, smpch=\\E[11m, smso=\\E[7m,
111         smul=\\E[4m, tbc=\\E[3g, u6=\\E[%i%d;%dR, u7=\\E[6n,
112         u8=\\E[?%[;0123456789]c, u9=\\E[c, vpa=\\E[%i%p1%dd,
113 .fi
114 .ft R
115 .PP
116 Entries may continue onto multiple lines by placing white space at
117 the beginning of each line except the first.
118 Comments may be included on lines beginning with \*(``#\*(''.
119 Capabilities in
120 .I terminfo
121 are of three types:
122 .bP
123 Boolean capabilities which indicate that the terminal has
124 some particular feature,
125 .bP
126 numeric capabilities giving the size of the terminal
127 or the size of particular delays, and
128 .bP
129 string
130 capabilities, which give a sequence which can be used to perform particular
131 terminal operations.
132 .PP
133 .SS Types of Capabilities
134 .PP
135 All capabilities have names.
136 For instance, the fact that
137 ANSI-standard terminals have
138 .I "automatic margins"
139 (i.e., an automatic return and line-feed
140 when the end of a line is reached) is indicated by the capability \fBam\fR.
141 Hence the description of ansi includes \fBam\fR.
142 Numeric capabilities are followed by the character \*(``#\*('' and then a positive value.
143 Thus \fBcols\fR, which indicates the number of columns the terminal has,
144 gives the value \*(``80\*('' for ansi.
145 Values for numeric capabilities may be specified in decimal, octal or hexadecimal,
146 using the C programming language conventions (e.g., 255, 0377 and 0xff or 0xFF).
147 .PP
148 Finally, string valued capabilities, such as \fBel\fR (clear to end of line
149 sequence) are given by the two-character code, an \*(``=\*('', and then a string
150 ending at the next following \*(``,\*(''.
151 .PP
152 A number of escape sequences are provided in the string valued capabilities
153 for easy encoding of characters there:
154 .bP
155 Both \fB\eE\fR and \fB\ee\fR
156 map to an \s-1ESCAPE\s0 character,
157 .bP
158 \fB^x\fR maps to a control-x for any appropriate \fIx\fP, and
159 .bP
160 the sequences
161 .RS 6
162 .PP
163 \fB\en\fP, \fB\el\fP, \fB\er\fP, \fB\et\fP, \fB\eb\fP, \fB\ef\fP, and \fB\es\fR
164 .RE
165 .IP
166 produce
167 .RS 6
168 .PP
169 \fInewline\fP, \fIline-feed\fP, \fIreturn\fP, \fItab\fP, \fIbackspace\fP, \fIform-feed\fP, and \fIspace\fP,
170 .RE
171 .IP
172 respectively.
173 .PP
174 X/Open Curses does not say what \*(``appropriate \fIx\fP\*('' might be.
175 In practice, that is a printable ASCII graphic character.
176 The special case \*(``^?\*('' is interpreted as DEL (127).
177 In all other cases, the character value is AND'd with 0x1f,
178 mapping to ASCII control codes in the range 0 through 31.
179 .PP
180 Other escapes include
181 .bP
182 \fB\e^\fR for \fB^\fR,
183 .bP
184 \fB\e\e\fR for \fB\e\fR,
185 .bP
186 \fB\e\fR, for comma,
187 .bP
188 \fB\e:\fR for \fB:\fR,
189 .bP
190 and \fB\e0\fR for null.
191 .IP
192 \fB\e0\fR will produce \e200, which does not terminate a string but behaves
193 as a null character on most terminals, providing CS7 is specified.
194 See \fBstty\fP(1).
195 .IP
196 The reason for this quirk is to maintain binary compatibility of the
197 compiled terminfo files with other implementations,
198 e.g., the SVr4 systems, which document this.
199 Compiled terminfo files use null-terminated strings, with no lengths.
200 Modifying this would require a new binary format,
201 which would not work with other implementations.
202 .PP
203 Finally, characters may be given as three octal digits after a \fB\e\fR.
204 .PP
205 A delay in milliseconds may appear anywhere in a string capability, enclosed in
206 $<..> brackets, as in \fBel\fP=\eEK$<5>,
207 and padding characters are supplied by \fBtputs\fP(3X)
208 to provide this delay.
209 .bP
210 The delay must be a number with at most one decimal
211 place of precision; it may be followed by suffixes \*(``*\*('' or \*(``/\*('' or both.
212 .bP
213 A \*(``*\*(''
214 indicates that the padding required is proportional to the number of lines
215 affected by the operation, and the amount given is the per-affected-unit
216 padding required.
217 (In the case of insert character, the factor is still the
218 number of \fIlines\fP affected.)
219 .IP
220 Normally, padding is advisory if the device has the \fBxon\fR
221 capability; it is used for cost computation but does not trigger delays.
222 .bP
223 A \*(``/\*(''
224 suffix indicates that the padding is mandatory and forces a delay of the given
225 number of milliseconds even on devices for which \fBxon\fR is present to
226 indicate flow control.
227 .PP
228 Sometimes individual capabilities must be commented out.
229 To do this, put a period before the capability name.
230 For example, see the second
231 .B ind
232 in the example above.
233 .br
234 .ne 5
235 .PP
236 .SS Fetching Compiled Descriptions
237 .PP
238 The \fBncurses\fP library searches for terminal descriptions in several places.
239 It uses only the first description found.
240 The library has a compiled-in list of places to search
241 which can be overridden by environment variables.
242 Before starting to search,
243 \fBncurses\fP eliminates duplicates in its search list.
244 .bP
245 If the environment variable TERMINFO is set, it is interpreted as the pathname
246 of a directory containing the compiled description you are working on.
247 Only that directory is searched.
248 .bP
249 If TERMINFO is not set,
250 \fBncurses\fR will instead look in the directory \fB$HOME/.terminfo\fR
251 for a compiled description.
252 .bP
253 Next, if the environment variable TERMINFO_DIRS is set,
254 \fBncurses\fR will interpret the contents of that variable
255 as a list of colon-separated directories (or database files) to be searched.
256 .IP
257 An empty directory name (i.e., if the variable begins or ends
258 with a colon, or contains adjacent colons)
259 is interpreted as the system location \fI\*d\fR.
260 .bP
261 Finally, \fBncurses\fP searches these compiled-in locations:
262 .RS
263 .bP
264 a list of directories (@TERMINFO_DIRS@), and
265 .bP
266 the system terminfo directory, \fI\*d\fR (the compiled-in default).
267 .RE
268 .SS Preparing Descriptions
269 .PP
270 We now outline how to prepare descriptions of terminals.
271 The most effective way to prepare a terminal description is by imitating
272 the description of a similar terminal in
273 .I terminfo
274 and to build up a description gradually, using partial descriptions
275 with
276 .I vi
277 or some other screen-oriented program to check that they are correct.
278 Be aware that a very unusual terminal may expose deficiencies in
279 the ability of the
280 .I terminfo
281 file to describe it
282 or bugs in the screen-handling code of the test program.
283 .PP
284 To get the padding for insert line right (if the terminal manufacturer
285 did not document it) a severe test is to edit a large file at 9600 baud,
286 delete 16 or so lines from the middle of the screen, then hit the \*(``u\*(''
287 key several times quickly.
288 If the terminal messes up, more padding is usually needed.
289 A similar test can be used for insert character.
290 .PP
291 .SS Basic Capabilities
292 .PP
293 The number of columns on each line for the terminal is given by the
294 \fBcols\fR numeric capability.
295 If the terminal is a \s-1CRT\s0, then the
296 number of lines on the screen is given by the \fBlines\fR capability.
297 If the terminal wraps around to the beginning of the next line when
298 it reaches the right margin, then it should have the \fBam\fR capability.
299 If the terminal can clear its screen, leaving the cursor in the home
300 position, then this is given by the \fBclear\fR string capability.
301 If the terminal overstrikes
302 (rather than clearing a position when a character is struck over)
303 then it should have the \fBos\fR capability.
304 If the terminal is a printing terminal, with no soft copy unit,
305 give it both
306 .B hc
307 and
308 .BR os .
309 .RB ( os
310 applies to storage scope terminals, such as \s-1TEKTRONIX\s+1 4010
311 series, as well as hard copy and APL terminals.)
312 If there is a code to move the cursor to the left edge of the current
313 row, give this as
314 .BR cr .
315 (Normally this will be carriage return, control/M.)
316 If there is a code to produce an audible signal (bell, beep, etc)
317 give this as
318 .BR bel .
319 .PP
320 If there is a code to move the cursor one position to the left
321 (such as backspace) that capability should be given as
322 .BR cub1 .
323 Similarly, codes to move to the right, up, and down should be
324 given as
325 .BR cuf1 ,
326 .BR cuu1 ,
327 and
328 .BR cud1 .
329 These local cursor motions should not alter the text they pass over,
330 for example, you would not normally use \*(``\fBcuf1\fP=\ \*('' because the
331 space would erase the character moved over.
332 .PP
333 A very important point here is that the local cursor motions encoded
334 in
335 .I terminfo
336 are undefined at the left and top edges of a \s-1CRT\s0 terminal.
337 Programs should never attempt to backspace around the left edge,
338 unless
339 .B bw
340 is given,
341 and never attempt to go up locally off the top.
342 In order to scroll text up, a program will go to the bottom left corner
343 of the screen and send the
344 .B ind
345 (index) string.
346 .PP
347 To scroll text down, a program goes to the top left corner
348 of the screen and sends the
349 .B ri
350 (reverse index) string.
351 The strings
352 .B ind
353 and
354 .B ri
355 are undefined when not on their respective corners of the screen.
356 .PP
357 Parameterized versions of the scrolling sequences are
358 .B indn
359 and
360 .B rin
361 which have the same semantics as
362 .B ind
363 and
364 .B ri
365 except that they take one parameter, and scroll that many lines.
366 They are also undefined except at the appropriate edge of the screen.
367 .PP
368 The \fBam\fR capability tells whether the cursor sticks at the right
369 edge of the screen when text is output, but this does not necessarily
370 apply to a
371 .B cuf1
372 from the last column.
373 The only local motion which is defined from the left edge is if
374 .B bw
375 is given, then a
376 .B cub1
377 from the left edge will move to the right edge of the previous row.
378 If
379 .B bw
380 is not given, the effect is undefined.
381 This is useful for drawing a box around the edge of the screen, for example.
382 If the terminal has switch selectable automatic margins,
383 the
384 .I terminfo
385 file usually assumes that this is on; i.e., \fBam\fR.
386 If the terminal has a command which moves to the first column of the next
387 line, that command can be given as
388 .B nel
389 (newline).
390 It does not matter if the command clears the remainder of the current line,
391 so if the terminal has no
392 .B cr
393 and
394 .B lf
395 it may still be possible to craft a working
396 .B nel
397 out of one or both of them.
398 .PP
399 These capabilities suffice to describe hard-copy and \*(``glass-tty\*('' terminals.
400 Thus the model 33 teletype is described as
401 .PP
402 .DT
403 .nf
404 .ft CW
405 .\".in -2
406 \s-133\||\|tty33\||\|tty\||\|model 33 teletype,
407         bel=^G, cols#72, cr=^M, cud1=^J, hc, ind=^J, os,\s+1
408 .\".in +2
409 .ft R
410 .fi
411 .PP
412 while the Lear Siegler \s-1ADM-3\s0 is described as
413 .PP
414 .DT
415 .nf
416 .ft CW
417 .\".in -2
418 \s-1adm3\||\|3\||\|lsi adm3,
419         am, bel=^G, clear=^Z, cols#80, cr=^M, cub1=^H, cud1=^J,
420         ind=^J, lines#24,\s+1
421 .\".in +2
422 .ft R
423 .fi
424 .PP
425 .SS Parameterized Strings
426 .PP
427 Cursor addressing and other strings requiring parameters
428 in the terminal are described by a
429 parameterized string capability,
430 with \fIprintf\fP-like escapes such as \fI%x\fR in it.
431 For example, to address the cursor, the
432 .B cup
433 capability is given, using two parameters:
434 the row and column to address to.
435 (Rows and columns are numbered from zero and refer to the
436 physical screen visible to the user, not to any unseen memory.)
437 If the terminal has memory relative cursor addressing,
438 that can be indicated by
439 .BR mrcup .
440 .PP
441 The parameter mechanism uses a stack and special \fB%\fP codes
442 to manipulate it.
443 Typically a sequence will push one of the
444 parameters onto the stack and then print it in some format.
445 Print (e.g., \*(``%d\*('') is a special case.
446 Other operations, including \*(``%t\*('' pop their operand from the stack.
447 It is noted that more complex operations are often necessary,
448 e.g., in the \fBsgr\fP string.
449 .PP
450 The \fB%\fR encodings have the following meanings:
451 .PP
452 .TP 5
453 \fB%%\fP
454 outputs \*(``%\*(''
455 .TP
456 \fB%\fP\fI[[\fP:\fI]flags][width[.precision]][\fP\fBdoxXs\fP\fI]\fP
457 as in \fBprintf\fP(3), flags are \fI[\-+#]\fP and \fIspace\fP.
458 Use a \*(``:\*('' to allow the next character to be a \*(``\-\*('' flag,
459 avoiding interpreting \*(``%\-\*('' as an operator.
460 .TP
461 \f(CW%c\fP
462 print \fIpop()\fP like %c in \fBprintf\fP
463 .TP
464 \fB%s\fP
465 print \fIpop()\fP like %s in \fBprintf\fP
466 .TP
467 \fB%p\fP\fI[1\-9]\fP
468 push \fIi\fP'th parameter
469 .TP
470 \fB%P\fP\fI[a\-z]\fP
471 set dynamic variable \fI[a\-z]\fP to \fIpop()\fP
472 .TP
473 \fB%g\fP\fI[a\-z]/\fP
474 get dynamic variable \fI[a\-z]\fP and push it
475 .TP
476 \fB%P\fP\fI[A\-Z]\fP
477 set static variable \fI[a\-z]\fP to \fIpop()\fP
478 .TP
479 \fB%g\fP\fI[A\-Z]\fP
480 get static variable \fI[a\-z]\fP and push it
481 .IP
482 The terms \*(``static\*('' and \*(``dynamic\*('' are misleading.
483 Historically, these are simply two different sets of variables,
484 whose values are not reset between calls to \fBtparm\fP(3X).
485 However, that fact is not documented in other implementations.
486 Relying on it will adversely impact portability to other implementations:
487 .RS
488 .bP
489 SVr2 curses supported \fIdynamic\fP variables.
490 Those are set only by a \fB%P\fP operator.
491 A \fB%g\fP for a given variable without first setting it with \fB%P\fP
492 will give unpredictable results, because dynamic variables are
493 an uninitialized local array on the stack in the \fBtparm\fP function.
494 .bP
495 SVr3.2 curses supported \fIstatic\fP variables.
496 Those are an array in the \fBTERMINAL\fP
497 structure (declared in \fBterm.h\fP),
498 and are zeroed automatically when the \fBsetupterm\fP function
499 allocates the data.
500 .bP
501 SVr4 curses made no further improvements
502 to the \fIdynamic/static\fP variable feature.
503 .bP
504 Solaris XPG4 curses does not distinguish between \fIdynamic\fP and
505 \fIstatic\fP variables.
506 They are the same.
507 Like SVr4 curses, XPG4 curses does not initialize these explicitly.
508 .bP
509 Before version 6.3, ncurses stores both \fIdynamic\fP and \fIstatic\fP
510 variables in persistent storage, initialized to zeros.
511 .bP
512 Beginning with version 6.3, ncurses stores \fIstatic\fP and \fIdynamic\fP
513 variables in the same manner as SVr4.
514 Unlike other implementations, ncurses zeros dynamic variables 
515 before the first \fB%g\fP or \fB%P\fP operator.
516 .RE
517 .TP
518 \fB%\(aq\fP\fIc\fP\fB\(aq\fP
519 char constant \fIc\fP
520 .TP
521 \fB%{\fP\fInn\fP\fB}\fP
522 integer constant \fInn\fP
523 .TP
524 \fB%l\fP
525 push strlen(pop)
526 .TP
527 \fB%+\fP, \fB%\-\fP, \fB%*\fP, \fB%/\fP, \fB%m\fP
528 arithmetic (%m is \fImod\fP): \fIpush(pop() op pop())\fP
529 .TP
530 \fB%&\fP, \fB%|\fP, \fB%^\fP
531 bit operations (AND, OR and exclusive-OR): \fIpush(pop() op pop())\fP
532 .TP
533 \fB%=\fP, \fB%>\fP, \fB%<\fP
534 logical operations: \fIpush(pop() op pop())\fP
535 .TP
536 \fB%A\fP, \fB%O\fP
537 logical AND and OR operations (for conditionals)
538 .TP
539 \fB%!\fP, \fB%~\fP
540 unary operations (logical and bit complement): \fIpush(op pop())\fP
541 .TP
542 \fB%i\fP
543 add 1 to first two parameters (for ANSI terminals)
544 .TP
545 \fB%?\fP \fIexpr\fP \fB%t\fP \fIthenpart\fP \fB%e\fP \fIelsepart\fP \fB%;\fP
546 This forms an if-then-else.
547 The \fB%e\fP \fIelsepart\fP is optional.
548 Usually the \fB%?\fP \fIexpr\fP part pushes a value onto the stack,
549 and \fB%t\fP pops it from the stack, testing if it is nonzero (true).
550 If it is zero (false), control passes to the \fB%e\fP (else) part.
551 .IP
552 It is possible to form else-if's a la Algol 68:
553 .RS
554 \fB%?\fP c\d1\u \fB%t\fP b\d1\u \fB%e\fP c\d2\u \fB%t\fP b\d2\u \fB%e\fP c\d3\u \fB%t\fP b\d3\u \fB%e\fP c\d4\u \fB%t\fP b\d4\u \fB%e\fP \fB%;\fP
555 .RE
556 .IP
557 where c\di\u are conditions, b\di\u are bodies.
558 .IP
559 Use the \fB\-f\fP option of \fB@TIC@\fP or \fB@INFOCMP@\fP to see
560 the structure of if-then-else's.
561 Some strings, e.g., \fBsgr\fP can be very complicated when written
562 on one line.
563 The \fB\-f\fP option splits the string into lines with the parts indented.
564 .PP
565 Binary operations are in postfix form with the operands in the usual order.
566 That is, to get x\-5 one would use \*(``%gx%{5}%\-\*(''.
567 \fB%P\fP and \fB%g\fP variables are
568 persistent across escape-string evaluations.
569 .PP
570 Consider the HP2645, which, to get to row 3 and column 12, needs
571 to be sent \eE&a12c03Y padded for 6 milliseconds.
572 Note that the order
573 of the rows and columns is inverted here, and that the row and column
574 are printed as two digits.
575 Thus its \fBcup\fR capability is \*(``cup=6\eE&%p2%2dc%p1%2dY\*(''.
576 .PP
577 The Microterm \s-1ACT-IV\s0 needs the current row and column sent
578 preceded by a \fB^T\fR, with the row and column simply encoded in binary,
579 \*(``cup=^T%p1%c%p2%c\*(''.
580 Terminals which use \*(``%c\*('' need to be able to
581 backspace the cursor (\fBcub1\fR),
582 and to move the cursor up one line on the screen (\fBcuu1\fR).
583 This is necessary because it is not always safe to transmit \fB\en\fR
584 \fB^D\fR and \fB\er\fR, as the system may change or discard them.
585 (The library routines dealing with terminfo set tty modes so that
586 tabs are never expanded, so \et is safe to send.
587 This turns out to be essential for the Ann Arbor 4080.)
588 .PP
589 A final example is the \s-1LSI ADM\s0-3a, which uses row and column
590 offset by a blank character, thus \*(``cup=\eE=%p1%\(aq \(aq%+%c%p2%\(aq \(aq%+%c\*(''.
591 After sending \*(``\eE=\*('', this pushes the first parameter, pushes the
592 ASCII value for a space (32), adds them (pushing the sum on the stack
593 in place of the two previous values) and outputs that value as a character.
594 Then the same is done for the second parameter.
595 More complex arithmetic is possible using the stack.
596 .PP
597 .SS Cursor Motions
598 .PP
599 If the terminal has a fast way to home the cursor
600 (to very upper left corner of screen) then this can be given as
601 \fBhome\fR; similarly a fast way of getting to the lower left-hand corner
602 can be given as \fBll\fR; this may involve going up with \fBcuu1\fR
603 from the home position,
604 but a program should never do this itself (unless \fBll\fR does) because it
605 can make no assumption about the effect of moving up from the home position.
606 Note that the home position is the same as addressing to (0,0):
607 to the top left corner of the screen, not of memory.
608 (Thus, the \eEH sequence on HP terminals cannot be used for
609 .BR home .)
610 .PP
611 If the terminal has row or column absolute cursor addressing,
612 these can be given as single parameter capabilities
613 .B hpa
614 (horizontal position absolute)
615 and
616 .B vpa
617 (vertical position absolute).
618 Sometimes these are shorter than the more general two parameter
619 sequence (as with the hp2645) and can be used in preference to
620 .BR cup .
621 If there are parameterized local motions (e.g., move
622 .I n
623 spaces to the right) these can be given as
624 .BR cud ,
625 .BR cub ,
626 .BR cuf ,
627 and
628 .B cuu
629 with a single parameter indicating how many spaces to move.
630 These are primarily useful if the terminal does not have
631 .BR cup ,
632 such as the \s-1TEKTRONIX\s+1 4025.
633 .PP
634 If the terminal needs to be in a special mode when running
635 a program that uses these capabilities,
636 the codes to enter and exit this mode can be given as \fBsmcup\fR and \fBrmcup\fR.
637 This arises, for example, from terminals like the Concept with more than
638 one page of memory.
639 If the terminal has only memory relative cursor addressing and not screen
640 relative cursor addressing, a one screen-sized window must be fixed into
641 the terminal for cursor addressing to work properly.
642 This is also used for the \s-1TEKTRONIX\s+1 4025,
643 where
644 .B smcup
645 sets the command character to be the one used by terminfo.
646 If the \fBsmcup\fP sequence will not restore the screen after an
647 \fBrmcup\fP sequence is output (to the state prior to outputting
648 \fBrmcup\fP), specify \fBnrrmc\fP.
649 .PP
650 .SS Area Clears
651 .PP
652 If the terminal can clear from the current position to the end of the
653 line, leaving the cursor where it is, this should be given as \fBel\fR.
654 If the terminal can clear from the beginning of the line to the current
655 position inclusive, leaving
656 the cursor where it is, this should be given as \fBel1\fP.
657 If the terminal can clear from the current position to the end of the
658 display, then this should be given as \fBed\fR.
659 \fBEd\fR is only defined from the first column of a line.
660 (Thus, it can be simulated by a request to delete a large number of lines,
661 if a true
662 .B ed
663 is not available.)
664 .PP
665 .SS Insert/delete line and vertical motions
666 .PP
667 If the terminal can open a new blank line before the line where the cursor
668 is, this should be given as \fBil1\fR; this is done only from the first
669 position of a line.
670 The cursor must then appear on the newly blank line.
671 If the terminal can delete the line which the cursor is on, then this
672 should be given as \fBdl1\fR; this is done only from the first position on
673 the line to be deleted.
674 Versions of
675 .B il1
676 and
677 .B dl1
678 which take a single parameter and insert or delete that many lines can
679 be given as
680 .B il
681 and
682 .BR dl .
683 .PP
684 If the terminal has a settable scrolling region (like the vt100)
685 the command to set this can be described with the
686 .B csr
687 capability, which takes two parameters:
688 the top and bottom lines of the scrolling region.
689 The cursor position is, alas, undefined after using this command.
690 .PP
691 It is possible to get the effect of insert or delete line using
692 .B csr
693 on a properly chosen region; the
694 .B sc
695 and
696 .B rc
697 (save and restore cursor) commands may be useful for ensuring that
698 your synthesized insert/delete string does not move the cursor.
699 (Note that the \fBncurses\fR(3X) library does this synthesis
700 automatically, so you need not compose insert/delete strings for
701 an entry with \fBcsr\fR).
702 .PP
703 Yet another way to construct insert and delete might be to use a combination of
704 index with the memory-lock feature found on some terminals (like the HP\-700/90
705 series, which however also has insert/delete).
706 .PP
707 Inserting lines at the top or bottom of the screen can also be
708 done using
709 .B ri
710 or
711 .B ind
712 on many terminals without a true insert/delete line,
713 and is often faster even on terminals with those features.
714 .PP
715 The boolean \fBnon_dest_scroll_region\fR should be set if each scrolling
716 window is effectively a view port on a screen-sized canvas.
717 To test for
718 this capability, create a scrolling region in the middle of the screen,
719 write something to the bottom line, move the cursor to the top of the region,
720 and do \fBri\fR followed by \fBdl1\fR or \fBind\fR.
721 If the data scrolled
722 off the bottom of the region by the \fBri\fR re-appears, then scrolling
723 is non-destructive.
724 System V and XSI Curses expect that \fBind\fR, \fBri\fR,
725 \fBindn\fR, and \fBrin\fR will simulate destructive scrolling; their
726 documentation cautions you not to define \fBcsr\fR unless this is true.
727 This \fBcurses\fR implementation is more liberal and will do explicit erases
728 after scrolling if \fBndsrc\fR is defined.
729 .PP
730 If the terminal has the ability to define a window as part of
731 memory, which all commands affect,
732 it should be given as the parameterized string
733 .BR wind .
734 The four parameters are the starting and ending lines in memory
735 and the starting and ending columns in memory, in that order.
736 .PP
737 If the terminal can retain display memory above, then the
738 \fBda\fR capability should be given; if display memory can be retained
739 below, then \fBdb\fR should be given.
740 These indicate
741 that deleting a line or scrolling may bring non-blank lines up from below
742 or that scrolling back with \fBri\fR may bring down non-blank lines.
743 .PP
744 .SS Insert/Delete Character
745 .PP
746 There are two basic kinds of intelligent terminals with respect to
747 insert/delete character which can be described using
748 .I terminfo.
749 The most common insert/delete character operations affect only the characters
750 on the current line and shift characters off the end of the line rigidly.
751 Other terminals, such as the Concept 100 and the Perkin Elmer Owl, make
752 a distinction between typed and untyped blanks on the screen, shifting
753 upon an insert or delete only to an untyped blank on the screen which is
754 either eliminated, or expanded to two untyped blanks.
755 .PP
756 You can determine the
757 kind of terminal you have by clearing the screen and then typing
758 text separated by cursor motions.
759 Type \*(``abc\ \ \ \ def\*('' using local
760 cursor motions (not spaces) between the \*(``abc\*('' and the \*(``def\*(''.
761 Then position the cursor before the \*(``abc\*('' and put the terminal in insert
762 mode.
763 If typing characters causes the rest of the line to shift
764 rigidly and characters to fall off the end, then your terminal does
765 not distinguish between blanks and untyped positions.
766 If the \*(``abc\*(''
767 shifts over to the \*(``def\*('' which then move together around the end of the
768 current line and onto the next as you insert, you have the second type of
769 terminal, and should give the capability \fBin\fR, which stands for
770 \*(``insert null\*(''.
771 .PP
772 While these are two logically separate attributes (one line versus multi-line
773 insert mode, and special treatment of untyped spaces) we have seen no
774 terminals whose insert mode cannot be described with the single attribute.
775 .PP
776 Terminfo can describe both terminals which have an insert mode, and terminals
777 which send a simple sequence to open a blank position on the current line.
778 Give as \fBsmir\fR the sequence to get into insert mode.
779 Give as \fBrmir\fR the sequence to leave insert mode.
780 Now give as \fBich1\fR any sequence needed to be sent just before sending
781 the character to be inserted.
782 Most terminals with a true insert mode
783 will not give \fBich1\fR; terminals which send a sequence to open a screen
784 position should give it here.
785 .PP
786 If your terminal has both, insert mode is usually preferable to \fBich1\fR.
787 Technically, you should not give both unless the terminal actually requires
788 both to be used in combination.
789 Accordingly, some non-curses applications get
790 confused if both are present; the symptom is doubled characters in an update
791 using insert.
792 This requirement is now rare; most \fBich\fR sequences do not
793 require previous smir, and most smir insert modes do not require \fBich1\fR
794 before each character.
795 Therefore, the new \fBcurses\fR actually assumes this
796 is the case and uses either \fBrmir\fR/\fBsmir\fR or \fBich\fR/\fBich1\fR as
797 appropriate (but not both).
798 If you have to write an entry to be used under
799 new curses for a terminal old enough to need both, include the
800 \fBrmir\fR/\fBsmir\fR sequences in \fBich1\fR.
801 .PP
802 If post insert padding is needed, give this as a number of milliseconds
803 in \fBip\fR (a string option).
804 Any other sequence which may need to be
805 sent after an insert of a single character may also be given in \fBip\fR.
806 If your terminal needs both to be placed into an \*(``insert mode\*('' and
807 a special code to precede each inserted character, then both
808 .BR smir / rmir
809 and
810 .B ich1
811 can be given, and both will be used.
812 The
813 .B ich
814 capability, with one parameter,
815 .IR n ,
816 will repeat the effects of
817 .B ich1
818 .I n
819 times.
820 .PP
821 If padding is necessary between characters typed while not
822 in insert mode, give this as a number of milliseconds padding in \fBrmp\fP.
823 .PP
824 It is occasionally necessary to move around while in insert mode
825 to delete characters on the same line (e.g., if there is a tab after
826 the insertion position).
827 If your terminal allows motion while in
828 insert mode you can give the capability \fBmir\fR to speed up inserting
829 in this case.
830 Omitting \fBmir\fR will affect only speed.
831 Some terminals
832 (notably Datamedia's) must not have \fBmir\fR because of the way their
833 insert mode works.
834 .PP
835 Finally, you can specify
836 .B dch1
837 to delete a single character,
838 .B dch
839 with one parameter,
840 .IR n ,
841 to delete
842 .I n characters,
843 and delete mode by giving \fBsmdc\fR and \fBrmdc\fR
844 to enter and exit delete mode (any mode the terminal needs to be placed
845 in for
846 .B dch1
847 to work).
848 .PP
849 A command to erase
850 .I n
851 characters (equivalent to outputting
852 .I n
853 blanks without moving the cursor)
854 can be given as
855 .B ech
856 with one parameter.
857 .PP
858 .SS "Highlighting, Underlining, and Visible Bells"
859 .PP
860 If your terminal has one or more kinds of display attributes,
861 these can be represented in a number of different ways.
862 You should choose one display form as
863 \f2standout mode\fR,
864 representing a good, high contrast, easy-on-the-eyes,
865 format for highlighting error messages and other attention getters.
866 (If you have a choice, reverse video plus half-bright is good,
867 or reverse video alone.)
868 The sequences to enter and exit standout mode
869 are given as \fBsmso\fR and \fBrmso\fR, respectively.
870 If the code to change into or out of standout
871 mode leaves one or even two blank spaces on the screen,
872 as the TVI 912 and Teleray 1061 do,
873 then \fBxmc\fR should be given to tell how many spaces are left.
874 .PP
875 Codes to begin underlining and end underlining can be given as \fBsmul\fR
876 and \fBrmul\fR respectively.
877 If the terminal has a code to underline the current character and move
878 the cursor one space to the right,
879 such as the Microterm Mime,
880 this can be given as \fBuc\fR.
881 .PP
882 Other capabilities to enter various highlighting modes include
883 .B blink
884 (blinking)
885 .B bold
886 (bold or extra bright)
887 .B dim
888 (dim or half-bright)
889 .B invis
890 (blanking or invisible text)
891 .B prot
892 (protected)
893 .B rev
894 (reverse video)
895 .B sgr0
896 (turn off
897 .I all
898 attribute modes)
899 .B smacs
900 (enter alternate character set mode)
901 and
902 .B rmacs
903 (exit alternate character set mode).
904 Turning on any of these modes singly may or may not turn off other modes.
905 .PP
906 If there is a sequence to set arbitrary combinations of modes,
907 this should be given as
908 .B sgr
909 (set attributes),
910 taking 9 parameters.
911 Each parameter is either 0 or nonzero, as the corresponding attribute is on or off.
912 The 9 parameters are, in order:
913 standout, underline, reverse, blink, dim, bold, blank, protect, alternate
914 character set.
915 Not all modes need be supported by
916 .BR sgr ,
917 only those for which corresponding separate attribute commands exist.
918 .PP
919 For example, the DEC vt220 supports most of the modes:
920 .PP
921 .TS
922 center;
923 l l l
924 l l l
925 lw18 lw14 lw18.
926 \fBtparm parameter      attribute       escape sequence\fP
927
928 none    none    \\E[0m
929 p1      standout        \\E[0;1;7m
930 p2      underline       \\E[0;4m
931 p3      reverse \\E[0;7m
932 p4      blink   \\E[0;5m
933 p5      dim     not available
934 p6      bold    \\E[0;1m
935 p7      invis   \\E[0;8m
936 p8      protect not used
937 p9      altcharset      ^O (off) ^N (on)
938 .TE
939 .PP
940 We begin each escape sequence by turning off any existing modes, since
941 there is no quick way to determine whether they are active.
942 Standout is set up to be the combination of reverse and bold.
943 The vt220 terminal has a protect mode,
944 though it is not commonly used in sgr
945 because it protects characters on the screen from the host's erasures.
946 The altcharset mode also is different in that it is either ^O or ^N,
947 depending on whether it is off or on.
948 If all modes are turned on, the resulting sequence is \\E[0;1;4;5;7;8m^N.
949 .PP
950 Some sequences are common to different modes.
951 For example, ;7 is output when either p1 or p3 is true, that is, if
952 either standout or reverse modes are turned on.
953 .PP
954 Writing out the above sequences, along with their dependencies yields
955 .PP
956 .ne 11
957 .TS
958 center;
959 l l l
960 l l l
961 lw18 lw14 lw18.
962 \fBsequence     when to output  terminfo translation\fP
963
964 .ft CW
965 \\E[0   always  \\E[0
966 ;1      if p1 or p6     %?%p1%p6%|%t;1%;
967 ;4      if p2   %?%p2%|%t;4%;
968 ;5      if p4   %?%p4%|%t;5%;
969 ;7      if p1 or p3     %?%p1%p3%|%t;7%;
970 ;8      if p7   %?%p7%|%t;8%;
971 m       always  m
972 ^N or ^O        if p9 ^N, else ^O       %?%p9%t^N%e^O%;
973 .ft R
974 .TE
975 .PP
976 Putting this all together into the sgr sequence gives:
977 .PP
978 .ft CW
979 .nf
980     sgr=\\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p4%t;5%;
981         %?%p1%p3%|%t;7%;%?%p7%t;8%;m%?%p9%t\\016%e\\017%;,
982 .fi
983 .ft R
984 .PP
985 Remember that if you specify sgr, you must also specify sgr0.
986 Also, some implementations rely on sgr being given if sgr0 is,
987 Not all terminfo entries necessarily have an sgr string, however.
988 Many terminfo entries are derived from termcap entries
989 which have no sgr string.
990 The only drawback to adding an sgr string is that termcap also
991 assumes that sgr0 does not exit alternate character set mode.
992 .PP
993 Terminals with the \*(``magic cookie\*('' glitch
994 .RB ( xmc )
995 deposit special \*(``cookies\*('' when they receive mode-setting sequences,
996 which affect the display algorithm rather than having extra bits for
997 each character.
998 Some terminals, such as the HP 2621, automatically leave standout
999 mode when they move to a new line or the cursor is addressed.
1000 Programs using standout mode should exit standout mode before
1001 moving the cursor or sending a newline,
1002 unless the
1003 .B msgr
1004 capability, asserting that it is safe to move in standout mode, is present.
1005 .PP
1006 If the terminal has
1007 a way of flashing the screen to indicate an error quietly (a bell replacement)
1008 then this can be given as \fBflash\fR; it must not move the cursor.
1009 .PP
1010 If the cursor needs to be made more visible than normal when it is
1011 not on the bottom line (to make, for example, a non-blinking underline into an
1012 easier to find block or blinking underline)
1013 give this sequence as
1014 .BR cvvis .
1015 If there is a way to make the cursor completely invisible, give that as
1016 .BR civis .
1017 The capability
1018 .B cnorm
1019 should be given which undoes the effects of both of these modes.
1020 .PP
1021 If your terminal correctly generates underlined characters
1022 (with no special codes needed)
1023 even though it does not overstrike,
1024 then you should give the capability \fBul\fR.
1025 If a character overstriking another leaves both characters on the screen,
1026 specify the capability \fBos\fP.
1027 If overstrikes are erasable with a blank,
1028 then this should be indicated by giving \fBeo\fR.
1029 .PP
1030 .SS Keypad and Function Keys
1031 .PP
1032 If the terminal has a keypad that transmits codes when the keys are pressed,
1033 this information can be given.
1034 Note that it is not possible to handle
1035 terminals where the keypad only works in local (this applies, for example,
1036 to the unshifted HP 2621 keys).
1037 If the keypad can be set to transmit or not transmit,
1038 give these codes as \fBsmkx\fR and \fBrmkx\fR.
1039 Otherwise the keypad is assumed to always transmit.
1040 .PP
1041 The codes sent by the left arrow, right arrow, up arrow, down arrow,
1042 and home keys can be given as
1043 \fBkcub1, kcuf1, kcuu1, kcud1, \fRand\fB khome\fR respectively.
1044 If there are function keys such as f0, f1, ..., f10, the codes they send
1045 can be given as \fBkf0, kf1, ..., kf10\fR.
1046 If these keys have labels other than the default f0 through f10, the labels
1047 can be given as \fBlf0, lf1, ..., lf10\fR.
1048 .PP
1049 The codes transmitted by certain other special keys can be given:
1050 .bP
1051 .B kll
1052 (home down),
1053 .bP
1054 .B kbs
1055 (backspace),
1056 .bP
1057 .B ktbc
1058 (clear all tabs),
1059 .bP
1060 .B kctab
1061 (clear the tab stop in this column),
1062 .bP
1063 .B kclr
1064 (clear screen or erase key),
1065 .bP
1066 .B kdch1
1067 (delete character),
1068 .bP
1069 .B kdl1
1070 (delete line),
1071 .bP
1072 .B krmir
1073 (exit insert mode),
1074 .bP
1075 .B kel
1076 (clear to end of line),
1077 .bP
1078 .B ked
1079 (clear to end of screen),
1080 .bP
1081 .B kich1
1082 (insert character or enter insert mode),
1083 .bP
1084 .B kil1
1085 (insert line),
1086 .bP
1087 .B knp
1088 (next page),
1089 .bP
1090 .B kpp
1091 (previous page),
1092 .bP
1093 .B kind
1094 (scroll forward/down),
1095 .bP
1096 .B kri
1097 (scroll backward/up),
1098 .bP
1099 .B khts
1100 (set a tab stop in this column).
1101 .PP
1102 In addition, if the keypad has a 3 by 3 array of keys including the four
1103 arrow keys, the other five keys can be given as
1104 .BR ka1 ,
1105 .BR ka3 ,
1106 .BR kb2 ,
1107 .BR kc1 ,
1108 and
1109 .BR kc3 .
1110 These keys are useful when the effects of a 3 by 3 directional pad are needed.
1111 .PP
1112 Strings to program function keys can be given as
1113 .BR pfkey ,
1114 .BR pfloc ,
1115 and
1116 .BR pfx .
1117 A string to program screen labels should be specified as \fBpln\fP.
1118 Each of these strings takes two parameters: the function key number to
1119 program (from 0 to 10) and the string to program it with.
1120 Function key numbers out of this range may program undefined keys in
1121 a terminal dependent manner.
1122 The difference between the capabilities is that
1123 .B pfkey
1124 causes pressing the given key to be the same as the user typing the
1125 given string;
1126 .B pfloc
1127 causes the string to be executed by the terminal in local; and
1128 .B pfx
1129 causes the string to be transmitted to the computer.
1130 .PP
1131 The capabilities \fBnlab\fP, \fBlw\fP and \fBlh\fP
1132 define the number of programmable
1133 screen labels and their width and height.
1134 If there are commands to turn the labels on and off,
1135 give them in \fBsmln\fP and \fBrmln\fP.
1136 \fBsmln\fP is normally output after one or more pln
1137 sequences to make sure that the change becomes visible.
1138 .PP
1139 .SS Tabs and Initialization
1140 .PP
1141 A few capabilities are used only for tabs:
1142 .bP
1143 If the terminal has hardware tabs, the command to advance to the next
1144 tab stop can be given as
1145 .B ht
1146 (usually control/I).
1147 .bP
1148 A \*(``back-tab\*('' command which moves leftward to the preceding tab stop can
1149 be given as
1150 .BR cbt .
1151 .IP
1152 By convention, if the teletype modes indicate that tabs are being
1153 expanded by the computer rather than being sent to the terminal,
1154 programs should not use
1155 .B ht
1156 or
1157 .B cbt
1158 even if they are present, since the user may not have the tab stops
1159 properly set.
1160 .bP
1161 If the terminal has hardware tabs which are initially set every
1162 .I n
1163 spaces when the terminal is powered up,
1164 the numeric parameter
1165 .B it
1166 is given, showing the number of spaces the tabs are set to.
1167 .IP
1168 The \fBit\fP capability is normally used by the \fB@TSET@\fP
1169 command to determine whether to set the mode for hardware tab expansion,
1170 and whether to set the tab stops.
1171 If the terminal has tab stops that can be saved in non-volatile memory,
1172 the terminfo description can assume that they are properly set.
1173 .PP
1174 Other capabilities
1175 include
1176 .bP
1177 .BR is1 ,
1178 .BR is2 ,
1179 and
1180 .BR is3 ,
1181 initialization strings for the terminal,
1182 .bP
1183 .BR iprog ,
1184 the path name of a program to be run to initialize the terminal,
1185 .bP
1186 and \fBif\fR, the name of a file containing long initialization strings.
1187 .PP
1188 These strings are expected to set the terminal into modes consistent
1189 with the rest of the terminfo description.
1190 They are normally sent to the terminal, by the
1191 .I init
1192 option of the \fB@TPUT@\fP program, each time the user logs in.
1193 They will be printed in the following order:
1194 .RS
1195 .TP
1196 run the program
1197 .B iprog
1198 .TP
1199 output
1200 .br
1201 \fBis1\fP and
1202 .br
1203 \fBis2\fP
1204 .TP
1205 set the margins using
1206 \fBmgc\fP or
1207 .br
1208 \fBsmglp\fP and \fBsmgrp\fP or
1209 .br
1210 \fBsmgl\fP and \fBsmgr\fP
1211 .TP
1212 set tabs using
1213 .B tbc
1214 and
1215 .B hts
1216 .TP
1217 print the file
1218 \fBif\fP
1219 .TP
1220 and finally output
1221 \fBis3\fP.
1222 .RE
1223 .PP
1224 Most initialization is done with
1225 .BR is2 .
1226 Special terminal modes can be set up without duplicating strings
1227 by putting the common sequences in
1228 .B is2
1229 and special cases in
1230 .B is1
1231 and
1232 .BR is3 .
1233 .PP
1234 A set of sequences that does a harder reset from a totally unknown state
1235 can be given as
1236 .BR rs1 ,
1237 .BR rs2 ,
1238 .B rf
1239 and
1240 .BR rs3 ,
1241 analogous to
1242 .B is1 ,
1243 .B is2 ,
1244 .B if
1245 and
1246 .B is3
1247 respectively.
1248 These strings are output
1249 by \fIreset\fP option of \fB@TPUT@\fP,
1250 or by the \fB@RESET@\fP program
1251 (an alias of \fB@TSET@\fP),
1252 which is used when the terminal gets into a wedged state.
1253 Commands are normally placed in
1254 .BR rs1 ,
1255 .B rs2
1256 .B rs3
1257 and
1258 .B rf
1259 only if they produce annoying effects on the screen and are not
1260 necessary when logging in.
1261 For example, the command to set the vt100 into 80-column mode would
1262 normally be part of
1263 .BR is2 ,
1264 but it causes an annoying glitch of the screen and is not normally
1265 needed since the terminal is usually already in 80-column mode.
1266 .PP
1267 The \fB@RESET@\fP program writes strings including
1268 .BR iprog ,
1269 etc., in the same order as the
1270 .I init
1271 program, using
1272 .BR rs1 ,
1273 etc., instead of
1274 .BR is1 ,
1275 etc.
1276 If any of
1277 .BR rs1 ,
1278 .BR rs2 ,
1279 .BR rs3 ,
1280 or
1281 .B rf
1282 reset capability strings are missing,
1283 the \fB@RESET@\fP program
1284 falls back upon the corresponding initialization capability string.
1285 .PP
1286 If there are commands to set and clear tab stops, they can be given as
1287 .B tbc
1288 (clear all tab stops)
1289 and
1290 .B hts
1291 (set a tab stop in the current column of every row).
1292 If a more complex sequence is needed to set the tabs than can be
1293 described by this, the sequence can be placed in
1294 .B is2
1295 or
1296 .BR if .
1297 .PP
1298 The \fB@TPUT@ reset\fP command uses the same capability strings
1299 as the \fB@RESET@\fP command,
1300 although the two programs (\fB@TPUT@\fP and \fB@RESET@\fP)
1301 provide different command-line options.
1302 .PP
1303 In practice, these terminfo capabilities are not often used in
1304 initialization of tabs
1305 (though they are required for the \fB@TABS@\fP program):
1306 .bP
1307 Almost all hardware terminals (at least those which supported tabs)
1308 initialized those to every \fIeight\fP columns:
1309 .IP
1310 The only exception was the AT&T 2300 series,
1311 which set tabs to every \fIfive\fP columns.
1312 .bP
1313 In particular, developers of the hardware terminals which are commonly used
1314 as models for modern terminal emulators provided documentation demonstrating
1315 that \fIeight\fP columns were the standard.
1316 .bP
1317 Because of this, the terminal initialization programs
1318 \fB@TPUT@\fP and \fB@TSET@\fP
1319 use the
1320 \fBtbc\fP (\fBclear_all_tabs\fP) and
1321 \fBhts\fP (\fBset_tab\fP) capabilities directly
1322 only when the \fBit\fP (\fBinit_tabs\fP) capability
1323 is set to a value other than \fIeight\fP.
1324 .SS Delays and Padding
1325 .PP
1326 Many older and slower terminals do not support either XON/XOFF or DTR
1327 handshaking, including hard copy terminals and some very archaic CRTs
1328 (including, for example, DEC VT100s).
1329 These may require padding characters
1330 after certain cursor motions and screen changes.
1331 .PP
1332 If the terminal uses xon/xoff handshaking for flow control (that is,
1333 it automatically emits ^S back to the host when its input buffers are
1334 close to full), set
1335 .BR xon .
1336 This capability suppresses the emission of padding.
1337 You can also set it
1338 for memory-mapped console devices effectively that do not have a speed limit.
1339 Padding information should still be included so that routines can
1340 make better decisions about relative costs, but actual pad characters will
1341 not be transmitted.
1342 .PP
1343 If \fBpb\fR (padding baud rate) is given, padding is suppressed at baud rates
1344 below the value of \fBpb\fR.
1345 If the entry has no padding baud rate, then
1346 whether padding is emitted or not is completely controlled by \fBxon\fR.
1347 .PP
1348 If the terminal requires other than a null (zero) character as a pad,
1349 then this can be given as \fBpad\fR.
1350 Only the first character of the
1351 .B pad
1352 string is used.
1353 .PP
1354 .SS Status Lines
1355 Some terminals have an extra \*(``status line\*('' which is not normally used by
1356 software (and thus not counted in the terminal's \fBlines\fR capability).
1357 .PP
1358 The simplest case is a status line which is cursor-addressable but not
1359 part of the main scrolling region on the screen; the Heathkit H19 has
1360 a status line of this kind, as would a 24-line VT100 with a 23-line
1361 scrolling region set up on initialization.
1362 This situation is indicated
1363 by the \fBhs\fR capability.
1364 .PP
1365 Some terminals with status lines need special sequences to access the
1366 status line.
1367 These may be expressed as a string with single parameter
1368 \fBtsl\fR which takes the cursor to a given zero-origin column on the
1369 status line.
1370 The capability \fBfsl\fR must return to the main-screen
1371 cursor positions before the last \fBtsl\fR.
1372 You may need to embed the
1373 string values of \fBsc\fR (save cursor) and \fBrc\fR (restore cursor)
1374 in \fBtsl\fR and \fBfsl\fR to accomplish this.
1375 .PP
1376 The status line is normally assumed to be the same width as the width
1377 of the terminal.
1378 If this is untrue, you can specify it with the numeric
1379 capability \fBwsl\fR.
1380 .PP
1381 A command to erase or blank the status line may be specified as \fBdsl\fR.
1382 .PP
1383 The boolean capability \fBeslok\fR specifies that escape sequences, tabs,
1384 etc., work ordinarily in the status line.
1385 .PP
1386 The \fBncurses\fR implementation does not yet use any of these capabilities.
1387 They are documented here in case they ever become important.
1388 .PP
1389 .SS Line Graphics
1390 .PP
1391 Many terminals have alternate character sets useful for forms-drawing.
1392 Terminfo and \fBcurses\fR have built-in support
1393 for most of the drawing characters
1394 supported by the VT100, with some characters from the AT&T 4410v1 added.
1395 This alternate character set may be specified by the \fBacsc\fR capability.
1396 .PP
1397 .TS H
1398 center expand;
1399 l l l l l
1400 l l l l l
1401 _ _ _ _ _
1402 lw25 lw10 lw6 lw6 lw6.
1403 .\".TH
1404 \fBGlyph        ACS     Ascii   acsc    acsc\fR
1405 \fBName Name    Default Char    Value\fR
1406 arrow pointing right    ACS_RARROW      >       +       0x2b
1407 arrow pointing left     ACS_LARROW      <       ,       0x2c
1408 arrow pointing up       ACS_UARROW      ^       \-      0x2d
1409 arrow pointing down     ACS_DARROW      v       .       0x2e
1410 solid square block      ACS_BLOCK       #       0       0x30
1411 diamond                 ACS_DIAMOND     +       `       0x60
1412 checker board (stipple) ACS_CKBOARD     :       a       0x61
1413 degree symbol           ACS_DEGREE      \e      f       0x66
1414 plus/minus              ACS_PLMINUS     #       g       0x67
1415 board of squares        ACS_BOARD       #       h       0x68
1416 lantern symbol          ACS_LANTERN     #       i       0x69
1417 lower right corner      ACS_LRCORNER    +       j       0x6a
1418 upper right corner      ACS_URCORNER    +       k       0x6b
1419 upper left corner       ACS_ULCORNER    +       l       0x6c
1420 lower left corner       ACS_LLCORNER    +       m       0x6d
1421 large plus or crossover ACS_PLUS        +       n       0x6e
1422 scan line 1             ACS_S1          ~       o       0x6f
1423 scan line 3             ACS_S3          \-      p       0x70
1424 horizontal line         ACS_HLINE       \-      q       0x71
1425 scan line 7             ACS_S7          \-      r       0x72
1426 scan line 9             ACS_S9          \&_     s       0x73
1427 tee pointing right      ACS_LTEE        +       t       0x74
1428 tee pointing left       ACS_RTEE        +       u       0x75
1429 tee pointing up         ACS_BTEE        +       v       0x76
1430 tee pointing down       ACS_TTEE        +       w       0x77
1431 vertical line           ACS_VLINE       |       x       0x78
1432 less-than-or-equal-to   ACS_LEQUAL      <       y       0x79
1433 greater-than-or-equal-to        ACS_GEQUAL      >       z       0x7a
1434 greek pi                ACS_PI  *       {       0x7b
1435 not-equal               ACS_NEQUAL      !       |       0x7c
1436 UK pound sign           ACS_STERLING    f       }       0x7d
1437 bullet                  ACS_BULLET      o       ~       0x7e
1438 .TE
1439 .PP
1440 A few notes apply to the table itself:
1441 .bP
1442 X/Open Curses incorrectly states that the mapping for \fIlantern\fP is
1443 uppercase \*(``I\*('' although Unix implementations use the
1444 lowercase \*(``i\*('' mapping.
1445 .bP
1446 The DEC VT100 implemented graphics using the alternate character set
1447 feature, temporarily switching \fImodes\fP and sending characters
1448 in the range 0x60 (96) to 0x7e (126)
1449 (the \fBacsc Value\fP column in the table).
1450 .bP
1451 The AT&T terminal added graphics characters outside that range.
1452 .IP
1453 Some of the characters within the range do not match the VT100;
1454 presumably they were used in the AT&T terminal:
1455 \fIboard of squares\fP replaces the VT100 \fInewline\fP symbol, while
1456 \fIlantern symbol\fP replaces the VT100 \fIvertical tab\fP symbol.
1457 The other VT100 symbols for control characters (\fIhorizontal tab\fP,
1458 \fIcarriage return\fP and \fIline-feed\fP) are not (re)used in curses.
1459 .PP
1460 The best way to define a new device's graphics set is to add a column
1461 to a copy of this table for your terminal, giving the character which
1462 (when emitted between \fBsmacs\fR/\fBrmacs\fR switches) will be rendered
1463 as the corresponding graphic.
1464 Then read off the VT100/your terminal
1465 character pairs right to left in sequence; these become the ACSC string.
1466 .PP
1467 .SS Color Handling
1468 .PP
1469 The curses library functions \fBinit_pair\fP and \fBinit_color\fP
1470 manipulate the \fIcolor pairs\fP and \fIcolor values\fP discussed in this
1471 section
1472 (see \fBcurs_color\fP(3X) for details on these and related functions).
1473 .PP
1474 Most color terminals are either \*(``Tektronix-like\*('' or \*(``HP-like\*('':
1475 .bP
1476 Tektronix-like
1477 terminals have a predefined set of \fIN\fP colors
1478 (where \fIN\fP is usually 8),
1479 and can set
1480 character-cell foreground and background characters independently, mixing them
1481 into \fIN\fP\ *\ \fIN\fP color-pairs.
1482 .bP
1483 On HP-like terminals, the user must set each color
1484 pair up separately (foreground and background are not independently settable).
1485 Up to \fIM\fP color-pairs may be set up from 2*\fIM\fP different colors.
1486 ANSI-compatible terminals are Tektronix-like.
1487 .PP
1488 Some basic color capabilities are independent of the color method.
1489 The numeric
1490 capabilities \fBcolors\fR and \fBpairs\fR specify the maximum numbers of colors
1491 and color-pairs that can be displayed simultaneously.
1492 The \fBop\fR (original
1493 pair) string resets foreground and background colors to their default values
1494 for the terminal.
1495 The \fBoc\fR string resets all colors or color-pairs to
1496 their default values for the terminal.
1497 Some terminals (including many PC
1498 terminal emulators) erase screen areas with the current background color rather
1499 than the power-up default background; these should have the boolean capability
1500 \fBbce\fR.
1501 .PP
1502 While the curses library works with \fIcolor pairs\fP
1503 (reflecting the inability of some devices to set foreground
1504 and background colors independently),
1505 there are separate capabilities for setting these features:
1506 .bP
1507 To change the current foreground or background color on a Tektronix-type
1508 terminal, use \fBsetaf\fR (set ANSI foreground) and \fBsetab\fR (set ANSI
1509 background) or \fBsetf\fR (set foreground) and \fBsetb\fR (set background).
1510 These take one parameter, the color number.
1511 The SVr4 documentation describes
1512 only \fBsetaf\fR/\fBsetab\fR; the XPG4 draft says that "If the terminal
1513 supports ANSI escape sequences to set background and foreground, they should
1514 be coded as \fBsetaf\fR and \fBsetab\fR, respectively.
1515 .bP
1516 If the terminal
1517 supports other escape sequences to set background and foreground, they should
1518 be coded as \fBsetf\fR and \fBsetb\fR, respectively.
1519 The \fBvidputs\fR and the \fBrefresh\fP(3X) functions
1520 use the \fBsetaf\fR and \fBsetab\fR capabilities if they are defined.
1521 .PP
1522 The \fBsetaf\fR/\fBsetab\fR and \fBsetf\fR/\fBsetb\fR capabilities take a
1523 single numeric argument each.
1524 Argument values 0-7 of \fBsetaf\fR/\fBsetab\fR are portably defined as
1525 follows (the middle column is the symbolic #define available in the header for
1526 the \fBcurses\fR or \fBncurses\fR libraries).
1527 The terminal hardware is free to
1528 map these as it likes, but the RGB values indicate normal locations in color
1529 space.
1530 .PP
1531 .TS H
1532 center;
1533 l c c c
1534 l l n l.
1535 \fBColor        #define         Value   RGB\fR
1536 black   \fBCOLOR_BLACK\fR       0       0, 0, 0
1537 red     \fBCOLOR_RED\ \fR       1       max,0,0
1538 green   \fBCOLOR_GREEN\fR       2       0,max,0
1539 yellow  \fBCOLOR_YELLOW\fR      3       max,max,0
1540 blue    \fBCOLOR_BLUE\fR        4       0,0,max
1541 magenta \fBCOLOR_MAGENTA\fR     5       max,0,max
1542 cyan    \fBCOLOR_CYAN\fR        6       0,max,max
1543 white   \fBCOLOR_WHITE\fR       7       max,max,max
1544 .TE
1545 .PP
1546 The argument values of \fBsetf\fR/\fBsetb\fR historically correspond to
1547 a different mapping, i.e.,
1548 .TS H
1549 center;
1550 l c c c
1551 l l n l.
1552 \fBColor        #define         Value   RGB\fR
1553 black   \fBCOLOR_BLACK\fR       0       0, 0, 0
1554 blue    \fBCOLOR_BLUE\fR        1       0,0,max
1555 green   \fBCOLOR_GREEN\fR       2       0,max,0
1556 cyan    \fBCOLOR_CYAN\fR        3       0,max,max
1557 red     \fBCOLOR_RED\ \fR       4       max,0,0
1558 magenta \fBCOLOR_MAGENTA\fR     5       max,0,max
1559 yellow  \fBCOLOR_YELLOW\fR      6       max,max,0
1560 white   \fBCOLOR_WHITE\fR       7       max,max,max
1561 .TE
1562 .PP
1563 It is important to not confuse the two sets of color capabilities;
1564 otherwise red/blue will be interchanged on the display.
1565 .PP
1566 On an HP-like terminal, use \fBscp\fR with a color-pair number parameter to set
1567 which color pair is current.
1568 .PP
1569 Some terminals allow the \fIcolor values\fP to be modified:
1570 .bP
1571 On a Tektronix-like terminal, the capability \fBccc\fR may be present to
1572 indicate that colors can be modified.
1573 If so, the \fBinitc\fR capability will
1574 take a color number (0 to \fBcolors\fR \- 1)and three more parameters which
1575 describe the color.
1576 These three parameters default to being interpreted as RGB
1577 (Red, Green, Blue) values.
1578 If the boolean capability \fBhls\fR is present,
1579 they are instead as HLS (Hue, Lightness, Saturation) indices.
1580 The ranges are
1581 terminal-dependent.
1582 .bP
1583 On an HP-like terminal, \fBinitp\fR may give a capability for changing a
1584 color-pair value.
1585 It will take seven parameters; a color-pair number (0 to
1586 \fBmax_pairs\fR \- 1), and two triples describing first background and then
1587 foreground colors.
1588 These parameters must be (Red, Green, Blue) or
1589 (Hue, Lightness, Saturation) depending on \fBhls\fR.
1590 .PP
1591 On some color terminals, colors collide with highlights.
1592 You can register
1593 these collisions with the \fBncv\fR capability.
1594 This is a bit-mask of
1595 attributes not to be used when colors are enabled.
1596 The correspondence with the
1597 attributes understood by \fBcurses\fR is as follows:
1598 .PP
1599 .TS
1600 center;
1601 l l l l
1602 lw20 lw2 lw10 lw10.
1603 \fBAttribute    Bit     Decimal Set by\fR
1604 A_STANDOUT      0       1       sgr
1605 A_UNDERLINE     1       2       sgr
1606 A_REVERSE       2       4       sgr
1607 A_BLINK         3       8       sgr
1608 A_DIM           4       16      sgr
1609 A_BOLD          5       32      sgr
1610 A_INVIS         6       64      sgr
1611 A_PROTECT       7       128     sgr
1612 A_ALTCHARSET    8       256     sgr
1613 A_HORIZONTAL    9       512     sgr1
1614 A_LEFT  10      1024    sgr1
1615 A_LOW   11      2048    sgr1
1616 A_RIGHT 12      4096    sgr1
1617 A_TOP   13      8192    sgr1
1618 A_VERTICAL      14      16384   sgr1
1619 A_ITALIC        15      32768   sitm
1620 .TE
1621 .PP
1622 For example, on many IBM PC consoles, the underline attribute collides with the
1623 foreground color blue and is not available in color mode.
1624 These should have
1625 an \fBncv\fR capability of 2.
1626 .PP
1627 SVr4 curses does nothing with \fBncv\fR, ncurses recognizes it and optimizes
1628 the output in favor of colors.
1629 .PP
1630 .SS Miscellaneous
1631 If the terminal requires other than a null (zero) character as a pad, then this
1632 can be given as pad.
1633 Only the first character of the pad string is used.
1634 If the terminal does not have a pad character, specify npc.
1635 Note that ncurses implements the termcap-compatible \fBPC\fR variable;
1636 though the application may set this value to something other than
1637 a null, ncurses will test \fBnpc\fR first and use napms if the terminal
1638 has no pad character.
1639 .PP
1640 If the terminal can move up or down half a line,
1641 this can be indicated with
1642 .B hu
1643 (half-line up)
1644 and
1645 .B hd
1646 (half-line down).
1647 This is primarily useful for superscripts and subscripts on hard-copy terminals.
1648 If a hard-copy terminal can eject to the next page (form feed), give this as
1649 .B ff
1650 (usually control/L).
1651 .PP
1652 If there is a command to repeat a given character a given number of
1653 times (to save time transmitting a large number of identical characters)
1654 this can be indicated with the parameterized string
1655 .BR rep .
1656 The first parameter is the character to be repeated and the second
1657 is the number of times to repeat it.
1658 Thus, tparm(repeat_char, \(aqx\(aq, 10) is the same as \*(``xxxxxxxxxx\*(''.
1659 .PP
1660 If the terminal has a settable command character, such as the \s-1TEKTRONIX\s+1 4025,
1661 this can be indicated with
1662 .BR cmdch .
1663 A prototype command character is chosen which is used in all capabilities.
1664 This character is given in the
1665 .B cmdch
1666 capability to identify it.
1667 The following convention is supported on some UNIX systems:
1668 The environment is to be searched for a
1669 .B CC
1670 variable, and if found, all
1671 occurrences of the prototype character are replaced with the character
1672 in the environment variable.
1673 .PP
1674 Terminal descriptions that do not represent a specific kind of known
1675 terminal, such as
1676 .IR switch ,
1677 .IR dialup ,
1678 .IR patch ,
1679 and
1680 .IR network ,
1681 should include the
1682 .B gn
1683 (generic) capability so that programs can complain that they do not know
1684 how to talk to the terminal.
1685 (This capability does not apply to
1686 .I virtual
1687 terminal descriptions for which the escape sequences are known.)
1688 .PP
1689 If the terminal has a \*(``meta key\*('' which acts as a shift key,
1690 setting the 8th bit of any character transmitted, this fact can
1691 be indicated with
1692 .BR km .
1693 Otherwise, software will assume that the 8th bit is parity and it
1694 will usually be cleared.
1695 If strings exist to turn this \*(``meta mode\*('' on and off, they
1696 can be given as
1697 .B smm
1698 and
1699 .BR rmm .
1700 .PP
1701 If the terminal has more lines of memory than will fit on the screen
1702 at once, the number of lines of memory can be indicated with
1703 .BR lm .
1704 A value of
1705 .BR lm #0
1706 indicates that the number of lines is not fixed,
1707 but that there is still more memory than fits on the screen.
1708 .PP
1709 If the terminal is one of those supported by the \s-1UNIX\s+1 virtual
1710 terminal protocol, the terminal number can be given as
1711 .BR vt .
1712 .PP
1713 Media copy
1714 strings which control an auxiliary printer connected to the terminal
1715 can be given as
1716 .BR mc0 :
1717 print the contents of the screen,
1718 .BR mc4 :
1719 turn off the printer, and
1720 .BR mc5 :
1721 turn on the printer.
1722 When the printer is on, all text sent to the terminal will be sent
1723 to the printer.
1724 It is undefined whether the text is also displayed on the terminal screen
1725 when the printer is on.
1726 A variation
1727 .B mc5p
1728 takes one parameter, and leaves the printer on for as many characters
1729 as the value of the parameter, then turns the printer off.
1730 The parameter should not exceed 255.
1731 All text, including
1732 .BR mc4 ,
1733 is transparently passed to the printer while an
1734 .B mc5p
1735 is in effect.
1736 .PP
1737 .SS Glitches and Braindamage
1738 .PP
1739 Hazeltine terminals, which do not allow \*(``~\*('' characters to be displayed should
1740 indicate \fBhz\fR.
1741 .PP
1742 Terminals which ignore a line-feed immediately after an \fBam\fR wrap,
1743 such as the Concept and vt100,
1744 should indicate \fBxenl\fR.
1745 .PP
1746 If
1747 .B el
1748 is required to get rid of standout
1749 (instead of merely writing normal text on top of it),
1750 \fBxhp\fP should be given.
1751 .PP
1752 Teleray terminals, where tabs turn all characters moved over to blanks,
1753 should indicate \fBxt\fR (destructive tabs).
1754 Note: the variable indicating this is now \*(``dest_tabs_magic_smso\*(''; in
1755 older versions, it was teleray_glitch.
1756 This glitch is also taken to mean that it is not possible to position
1757 the cursor on top of a \*(``magic cookie\*('',
1758 that to erase standout mode it is instead necessary to use
1759 delete and insert line.
1760 The ncurses implementation ignores this glitch.
1761 .PP
1762 The Beehive Superbee, which is unable to correctly transmit the escape
1763 or control/C characters, has
1764 .BR xsb ,
1765 indicating that the f1 key is used for escape and f2 for control/C.
1766 (Only certain Superbees have this problem, depending on the ROM.)
1767 Note that in older terminfo versions, this capability was called
1768 \*(``beehive_glitch\*(''; it is now \*(``no_esc_ctl_c\*(''.
1769 .PP
1770 Other specific terminal problems may be corrected by adding more
1771 capabilities of the form \fBx\fR\fIx\fR.
1772 .PP
1773 .SS Pitfalls of Long Entries
1774 .PP
1775 Long terminfo entries are unlikely to be a problem; to date, no entry has even
1776 approached terminfo's 4096-byte string-table maximum.
1777 Unfortunately, the termcap
1778 translations are much more strictly limited (to 1023 bytes), thus termcap translations
1779 of long terminfo entries can cause problems.
1780 .PP
1781 The man pages for 4.3BSD and older versions of \fBtgetent\fP instruct the user to
1782 allocate a 1024-byte buffer for the termcap entry.
1783 The entry gets null-terminated by
1784 the termcap library, so that makes the maximum safe length for a termcap entry
1785 1k\-1 (1023) bytes.
1786 Depending on what the application and the termcap library
1787 being used does, and where in the termcap file the terminal type that \fBtgetent\fP
1788 is searching for is, several bad things can happen.
1789 .PP
1790 Some termcap libraries print a warning message or exit if they find an
1791 entry that's longer than 1023 bytes; others do not; others truncate the
1792 entries to 1023 bytes.
1793 Some application programs allocate more than
1794 the recommended 1K for the termcap entry; others do not.
1795 .PP
1796 Each termcap entry has two important sizes associated with it: before
1797 \*(``tc\*('' expansion, and after \*(``tc\*('' expansion.
1798 \*(``tc\*('' is the capability that
1799 tacks on another termcap entry to the end of the current one, to add
1800 on its capabilities.
1801 If a termcap entry does not use the \*(``tc\*(''
1802 capability, then of course the two lengths are the same.
1803 .PP
1804 The \*(``before tc expansion\*('' length is the most important one, because it
1805 affects more than just users of that particular terminal.
1806 This is the
1807 length of the entry as it exists in /etc/termcap, minus the
1808 backslash-newline pairs, which \fBtgetent\fP strips out while reading it.
1809 Some termcap libraries strip off the final newline, too (GNU termcap does not).
1810 Now suppose:
1811 .bP
1812 a termcap entry before expansion is more than 1023 bytes long,
1813 .bP
1814 and the application has only allocated a 1k buffer,
1815 .bP
1816 and the termcap library (like the one in BSD/OS 1.1 and GNU) reads
1817 the whole entry into the buffer, no matter what its length, to see
1818 if it is the entry it wants,
1819 .bP
1820 and \fBtgetent\fP is searching for a terminal type that either is the
1821 long entry, appears in the termcap file after the long entry, or
1822 does not appear in the file at all (so that \fBtgetent\fP has to search
1823 the whole termcap file).
1824 .PP
1825 Then \fBtgetent\fP will overwrite memory, perhaps its stack, and probably core dump
1826 the program.
1827 Programs like telnet are particularly vulnerable; modern telnets
1828 pass along values like the terminal type automatically.
1829 The results are almost
1830 as undesirable with a termcap library, like SunOS 4.1.3 and Ultrix 4.4, that
1831 prints warning messages when it reads an overly long termcap entry.
1832 If a
1833 termcap library truncates long entries, like OSF/1 3.0, it is immune to dying
1834 here but will return incorrect data for the terminal.
1835 .PP
1836 The \*(``after tc expansion\*('' length will have a similar effect to the
1837 above, but only for people who actually set TERM to that terminal
1838 type, since \fBtgetent\fP only does \*(``tc\*('' expansion once it is found the
1839 terminal type it was looking for, not while searching.
1840 .PP
1841 In summary, a termcap entry that is longer than 1023 bytes can cause,
1842 on various combinations of termcap libraries and applications, a core
1843 dump, warnings, or incorrect operation.
1844 If it is too long even before
1845 \*(``tc\*('' expansion, it will have this effect even for users of some other
1846 terminal types and users whose TERM variable does not have a termcap
1847 entry.
1848 .PP
1849 When in \-C (translate to termcap) mode, the \fBncurses\fR implementation of
1850 \fB@TIC@\fR(1M) issues warning messages when the pre-tc length of a termcap
1851 translation is too long.
1852 The \-c (check) option also checks resolved (after tc
1853 expansion) lengths.
1854 .SS Binary Compatibility
1855 It is not wise to count on portability of binary terminfo entries between
1856 commercial UNIX versions.
1857 The problem is that there are at least two versions
1858 of terminfo (under HP\-UX and AIX) which diverged from System V terminfo after
1859 SVr1, and have added extension capabilities to the string table that (in the
1860 binary format) collide with System V and XSI Curses extensions.
1861 .SH EXTENSIONS
1862 .PP
1863 Searching for terminal descriptions in
1864 \fB$HOME/.terminfo\fR and TERMINFO_DIRS
1865 is not supported by older implementations.
1866 .PP
1867 Some SVr4 \fBcurses\fR implementations, and all previous to SVr4, do not
1868 interpret the %A and %O operators in parameter strings.
1869 .PP
1870 SVr4/XPG4 do not specify whether \fBmsgr\fR licenses movement while in
1871 an alternate-character-set mode (such modes may, among other things, map
1872 CR and NL to characters that do not trigger local motions).
1873 The \fBncurses\fR implementation ignores \fBmsgr\fR in \fBALTCHARSET\fR
1874 mode.
1875 This raises the possibility that an XPG4
1876 implementation making the opposite interpretation may need terminfo
1877 entries made for \fBncurses\fR to have \fBmsgr\fR turned off.
1878 .PP
1879 The \fBncurses\fR library handles insert-character and insert-character modes
1880 in a slightly non-standard way to get better update efficiency.
1881 See
1882 the \fBInsert/Delete Character\fR subsection above.
1883 .PP
1884 The parameter substitutions for \fBset_clock\fR and \fBdisplay_clock\fR are
1885 not documented in SVr4 or the XSI Curses standard.
1886 They are deduced from the
1887 documentation for the AT&T 505 terminal.
1888 .PP
1889 Be careful assigning the \fBkmous\fR capability.
1890 The \fBncurses\fR library wants to interpret it as \fBKEY_MOUSE\fR,
1891 for use by terminals and emulators like xterm
1892 that can return mouse-tracking information in the keyboard-input stream.
1893 .PP
1894 X/Open Curses does not mention italics.
1895 Portable applications must assume that numeric capabilities are
1896 signed 16-bit values.
1897 This includes the \fIno_color_video\fP (ncv) capability.
1898 The 32768 mask value used for italics with ncv can be confused with
1899 an absent or cancelled ncv.
1900 If italics should work with colors,
1901 then the ncv value must be specified, even if it is zero.
1902 .PP
1903 Different commercial ports of terminfo and curses support different subsets of
1904 the XSI Curses standard and (in some cases) different extension sets.
1905 Here
1906 is a summary, accurate as of October 1995:
1907 .bP
1908 \fBSVR4, Solaris, ncurses\fR \-\-
1909 These support all SVr4 capabilities.
1910 .bP
1911 \fBSGI\fR \-\-
1912 Supports the SVr4 set, adds one undocumented extended string
1913 capability (\fBset_pglen\fR).
1914 .bP
1915 \fBSVr1, Ultrix\fR \-\-
1916 These support a restricted subset of terminfo capabilities.
1917 The booleans end with \fBxon_xoff\fR;
1918 the numerics with \fBwidth_status_line\fR;
1919 and the strings with \fBprtr_non\fR.
1920 .bP
1921 \fBHP/UX\fR \-\-
1922 Supports the SVr1 subset, plus the SVr[234] numerics \fBnum_labels\fR,
1923 \fBlabel_height\fR, \fBlabel_width\fR, plus function keys 11 through 63, plus
1924 \fBplab_norm\fR, \fBlabel_on\fR, and \fBlabel_off\fR, plus some incompatible
1925 extensions in the string table.
1926 .bP
1927 \fBAIX\fR \-\-
1928 Supports the SVr1 subset, plus function keys 11 through 63, plus a number
1929 of incompatible string table extensions.
1930 .bP
1931 \fBOSF\fR \-\-
1932 Supports both the SVr4 set and the AIX extensions.
1933 .SH FILES
1934 .TP 25
1935 \*d/?/*
1936 files containing terminal descriptions
1937 .SH SEE ALSO
1938 \fB@INFOCMP@\fR(1M),
1939 \fB@TABS@\fR(1),
1940 \fB@TIC@\fR(1M),
1941 \fBcurses\fR(3X),
1942 \fBcurs_color\fR(3X),
1943 \fBcurs_variables\fR(3X),
1944 \fBprintf\fR(3),
1945 \fBterm_variables\fR(3X).
1946 \fBterm\fR(\*n).
1947 \fBuser_caps\fR(5).
1948 .SH AUTHORS
1949 Zeyd M. Ben-Halim, Eric S. Raymond, Thomas E. Dickey.
1950 Based on pcurses by Pavel Curtis.