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