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