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