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