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