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