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