xref: /freebsd/share/termcap/termcap.5 (revision 952d112864d8008aa87278a30a539d888a8493cd)
1.\" Copyright (c) 1985, 1991, 1993, 1994
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)termcap.5	8.3 (Berkeley) 4/16/94
33.\"	$Id$
34.\"
35.Dd April 16, 1994
36.Dt TERMCAP 5
37.Os BSD 3
38.Sh NAME
39.Nm termcap
40.Nd terminal capability data base
41.Sh SYNOPSIS
42.Nm termcap
43.Sh DESCRIPTION
44The
45.Nm Termcap
46file
47is a data base describing terminals,
48used,
49for example,
50by
51.Xr \&vi 1
52and
53.Xr curses 3 .
54Terminals are described in
55.Nm termcap
56by giving a set of capabilities that they have and by describing
57how operations are performed.
58Padding requirements and initialization sequences
59are included in
60.Nm termcap .
61.Pp
62Entries in
63.Nm termcap
64consist of a number of `:'-separated fields.
65The first entry for each terminal gives the names that are known for the
66terminal, separated by `|' characters.
67The first name given is the most common abbreviation for the terminal.
68The last name given should be a long name fully identifying the terminal,
69and all others are understood as synonyms for the terminal name.
70All names but the last should be in lower case and contain no blanks;
71the last name may well contain upper case characters and blanks for
72readability.
73.Pp
74Terminal names (except for the last, verbose entry)
75should be chosen using the following conventions.
76The particular piece of hardware making up the terminal
77should have a root name chosen, thus
78.Dq hp2621
79This name should not contain hyphens.
80Modes that the hardware can be in
81or user preferences
82should be indicated by appending a hyphen and an indicator of the mode.
83Therefore, a
84.Dq vt100
85in 132-column mode would be
86.Dq vt100-w .
87The following suffixes should be used where possible:
88.Pp
89.Bd -filled -offset indent
90.Bl -column indent "With automatic margins (usually default)xx"
91.Sy Suffix	Meaning	Example
92-w	Wide mode (more than 80 columns)	vt100-w
93-am	With automatic margins (usually default)	vt100-am
94-nam	Without automatic margins	vt100-nam
95.Pf \- Ar n Ta No "Number of lines on screen	aaa-60"
96-na	No arrow keys (leave them in local)	concept100-na
97.Pf \- Ar \&np Ta No "Number of pages of memory	concept100-4p"
98-rv	Reverse video	concept100-rv
99.El
100.Ed
101.Sh CAPABILITIES
102The characters in the
103.Em Notes
104function
105field in the table have the following meanings
106(more than one may apply to a capability):
107.Pp
108.Bd -unfilled -offset indent
109N	indicates numeric parameter(s)
110P	indicates that padding may be specified
111*	indicates that padding may be based on the number of lines affected
112o	indicates capability is obsolete
113.Ed
114.Pp
115.Dq Obsolete
116capabilities have no
117.Em terminfo
118equivalents,
119since they were considered useless,
120or are subsumed by other capabilities.
121New software should not rely on them at all.
122.Pp
123.Bl -column indent indent indent
124.Sy Name	Type	Notes	Description
125functions
126.It "ae	str	(P)	End alternate character set."
127.It AL	str	(NP*)	Add"
128.Em n
129new blank lines
130.It "al	str	(P*)	Add new blank line."
131.It "am	bool		Terminal has automatic margins."
132.It "as	str	(P)	Start alternate character set."
133.It "bc	str	(o)	Backspace if not."
134.Sy \&^H .
135.It "bl	str	(P)	Audible signal (bell)."
136.It "bs	bool	(o)	Terminal can backspace with"
137.Sy \&^H .
138.It "bt	str	(P)	Back tab."
139.It "bw	bool	" Ta Sy \&le
140(backspace) wraps from column 0 to last column.
141.It "CC	str		Terminal settable command character in prototype."
142.It "cd	str	(P*)	Clear to end of display."
143.It "ce	str	(P)	Clear to end of line."
144.It "ch	str	(NP)	Set cursor column (horizontal position)."
145.It "cl	str	(P*)	Clear screen and home cursor."
146.It "CM	str	(NP)	Memory-relative cursor addressing."
147.It "cm	str	(NP)	Screen-relative cursor motion."
148.It "co	num		Number of columns in a line (See"
149.Sx BUGS
150section below).
151.It "cr	str	(P)	Carriage return."
152.It "cs	str	(NP)	Change scrolling region (VT100)."
153.It "ct	str	(P)	Clear all tab stops."
154.It "cv	str	(NP)	Set cursor row (vertical position)."
155.It "da	bool		Display may be retained above the screen."
156.It "dB	num	(o)	Milliseconds of"
157.Sy \&bs
158delay needed (default 0).
159.It "db	bool		Display may be retained below the screen."
160.It "DC	str	(NP*)	Delete"
161.Em n
162characters.
163.It "dC	num	(o)	Milliseconds of"
164.Sy \&cr
165delay needed (default 0).
166.It "dc	str	(P*)	Delete character."
167.It "dF	num	(o)	Milliseconds of"
168.Sy \&ff
169delay needed (default 0).
170.It "DL	str	(NP*)	Delete"
171.Ar n
172lines.
173.It "dl	str	(P*)	Delete line."
174.It "dm	str		Enter delete mode."
175.It "dN	num	(o)	Milliseconds of
176.Sy \&nl
177delay needed (default 0).
178.It "DO	str	(NP*)	Move cursor down:
179.Ar n
180lines.
181.It "do	str		Down one line."
182.It "ds	str		Disable status line."
183.It "dT	num	(o)	Milliseconds of horizontal tab delay needed (default 0)."
184.It "dV	num	(o)	Milliseconds of vertical tab delay needed (default 0)."
185.It "ec	str	(NP)	Erase"
186.Ar n
187characters.
188.It "ed	str		End delete mode."
189.It "ei	str		End insert mode."
190.It "eo	bool		Can erase overstrikes with a blank."
191.It "EP	bool	(o)	Even parity."
192.It "es	bool		Escape can be used on the status line."
193.It "ff	str	(P*)	Hardcopy terminal page eject."
194.It "fs	str		Return from status line."
195.It "gn	bool		Generic line type, for example dialup, switch)."
196.It "hc	bool		Hardcopy terminal."
197.It "HD	bool	(o)	Half-duplex."
198.It "hd	str		Half-line down (forward 1/2 linefeed)."
199.It "ho	str	(P)	Home cursor."
200.It "hs	bool		Has extra"
201.Dq status line .
202.It "hu	str		Half-line up (reverse 1/2 linefeed)."
203.It "hz	bool		Cannot print ``~'' (Hazeltine)."
204.It "i1-i3	str		Terminal initialization strings"
205.Pf ( Xr terminfo
206only)
207.It "IC	str	(NP*)	Insert"
208.Ar n
209blank characters.
210.It "ic	str	(P*)	Insert character."
211.It "if	str		Name of file containing initialization string."
212.It "im	str		Enter insert mode."
213.It "in	bool		Insert mode distinguishes nulls."
214.It "iP	str		Pathname of program for initialization"
215.Pf ( Xr terminfo
216only).
217.It "ip	str	(P*)	Insert pad after character inserted."
218.It "is	str		Terminal initialization string"
219.Pf ( Nm termcap
220only).
221.It "it	num		Tabs initially every"
222.Ar n
223positions.
224.It "K1	str		Sent by keypad upper left."
225.It "K2	str		Sent by keypad upper right."
226.It "K3	str		Sent by keypad center."
227.It "K4	str		Sent by keypad lower left."
228.It "K5	str		Sent by keypad lower right."
229.It "k0-k9	str		Sent by function keys 0-9."
230.It "kA	str		Sent by insert-line key."
231.It "ka	str		Sent by clear-all-tabs key."
232.It "kb	str		Sent by backspace key."
233.It "kC	str		Sent by clear-screen or erase key."
234.It "kD	str		Sent by delete-character key."
235.It "kd	str		Sent by down-arrow key."
236.It "kE	str		Sent by clear-to-end-of-line key."
237.It "ke	str		Out of"
238.Dq keypad transmit
239mode.
240.It "kF	str		Sent by scroll-forward/down key."
241.It "kH	str		Sent by home-down key."
242.It "kh	str		Sent by home key."
243.It "kI	str		Sent by insert-character or enter-insert-mode key."
244.It "kL	str		Sent by delete-line key."
245.It "kl	str		Sent by left-arrow key."
246.It "kM	str		Sent by insert key while in insert mode."
247.It "km	bool		Has a"
248.Dq meta
249key (shift, sets parity bit).
250.It "kN	str		Sent by next-page key."
251.It "kn	num	(o)	Number of function"
252.Pq Sy \&k\&0 Ns \- Sy \&k\&9
253keys (default 0).
254.It "ko	str	(o)	Termcap entries for other non-function keys."
255.It "kP	str		Sent by previous-page key."
256.It "kR	str		Sent by scroll-backward/up key."
257.It "kr	str		Sent by right-arrow key."
258.It "kS	str		Sent by clear-to-end-of-screen key."
259.It "ks	str		Put terminal in"
260.Dq keypad transmit
261mode.
262.It "kT	str		Sent by set-tab key."
263.It "kt	str		Sent by clear-tab key."
264.It "ku	str		Sent by up-arrow key."
265.It "l0-l9	str		Labels on function keys if not"
266.Dq \&f Ns Em n .
267.It "LC	bool	(o)	Lower-case only."
268.It "LE	str	(NP)	Move cursor left"
269.Ar n
270positions.
271.It "le	str	(P)	Move cursor left one position."
272.It "li	num		Number of lines on screen or page (See"
273.Sx BUGS
274section below)
275.It "ll	str		Last line, first column
276.It "lm	num		Lines of memory if >" Sy \&li
277(0 means varies).
278.It "ma	str	(o)	Arrow key map (used by"
279.Xr \&vi
280version 2 only).
281.It "mb	str		Turn on blinking attribute."
282.It "md	str		Turn on bold (extra bright) attribute."
283.It "me	str		Turn off all attributes."
284.It "mh	str		Turn on half-bright attribute."
285.It "mi	bool		Safe to move while in insert mode."
286.It "mk	str		Turn on blank attribute (characters invisible)."
287.It "ml	str	(o)	Memory lock on above cursor."
288.It "mm	str		Turn on"
289.Dq meta mode
290(8th bit).
291.It "mo	str		Turn off"
292.Dq meta mode .
293.It "mp	str		Turn on protected attribute."
294.It "mr	str		Turn on reverse-video attribute."
295.It "ms	bool		Safe to move in standout modes."
296.It "mu	str	(o)	Memory unlock (turn off memory lock)."
297.It "nc	bool	(o)	No correctly-working"
298.Sy \&cr
299(Datamedia 2500, Hazeltine 2000).
300.It "nd	str		Non-destructive space (cursor right)."
301.It "NL	bool	(o)" Ta Sy \&\en No "is newline, not line feed."
302.It "nl	str	(o)	Newline character if not" Sy \en .
303.It "ns	bool	(o)	Terminal is a" Tn CRT No "but doesn't scroll."
304.It "nw	str	(P)	Newline (behaves like"
305.Sy \&cr
306followed by
307.Sy \&do ).
308.It "OP	bool	(o)	Odd parity."
309.It "os	bool		Terminal overstrikes."
310.It "pb	num		Lowest baud where delays are required."
311.It "pc	str		Pad character (default" Tn NUL ).
312.It "pf	str		Turn off the printer."
313.It "pk	str		Program function key"
314.Em n
315to type string
316.Em s
317.Pf ( Xr terminfo
318only).
319.It "pl	str		Program function key"
320.Em n
321to execute string
322.Em s
323.Pf ( Xr terminfo
324only).
325.It "pO	str	(N)	Turn on the printer for"
326.Em n
327bytes.
328.It "po	str		Turn on the printer."
329.It "ps	str		Print contents of the screen."
330.It "pt	bool	(o)	Has hardware tabs (may need to be set with"
331.Sy \&is ).
332.It "px	str		Program function key"
333.Em n
334to transmit string
335.Em s
336.Pf ( Xr terminfo
337only).
338.It "r1-r3	str		Reset terminal completely to sane modes"
339.Pf ( Xr terminfo
340only).
341.It "rc	str	(P)	Restore cursor to position of last"
342.Sy \&sc .
343.It "rf	str		Name of file containing reset codes."
344.It "RI	str	(NP)	Move cursor right"
345.Em n
346positions.
347.It "rp	str	(NP*)	Repeat character"
348.Em c n
349times.
350.It "rs	str		Reset terminal completely to sane modes"
351.Pf ( Nm termcap
352only).
353.It "sa	str	(NP)	Define the video attributes."
354.It "sc	str	(P)	Save cursor position."
355.It "se	str		End standout mode."
356.It "SF	str	(NP*)	Scroll forward"
357.Em n
358lines.
359.It "sf	str	(P)	Scroll text up."
360.It "sg	num		Number of garbage chars left by"
361.Sy \&so
362or
363.Sy \&se
364(default 0).
365.It "so	str		Begin standout mode."
366.It "SR	str	(NP*)	Scroll backward"
367.Em n
368lines.
369.It "sr	str	(P)	Scroll text down."
370.It "st	str		Set a tab in all rows, current column."
371.It "ta	str	(P)	Tab to next 8-position hardware tab stop."
372.It "tc	str		Entry of similar terminal \- must be last."
373.It "te	str		String to end programs that use"
374.Nm termcap .
375.It "ti	str		String to begin programs that use"
376.Nm termcap .
377.It "ts	str	(N)	Go to status line, column"
378.Em n .
379.It "UC	bool	(o)	Upper-case only."
380.It "uc	str		Underscore one character and move past it."
381.It "ue	str		End underscore mode."
382.It "ug	num		Number of garbage chars left by"
383.Sy \&us
384or
385.Sy \&ue
386(default 0).
387.It "ul	bool		Underline character overstrikes."
388.It "UP	str	(NP*)	Move cursor up"
389.Em n
390lines.
391.It "up	str		Upline (cursor up)."
392.It "us	str		Start underscore mode."
393.It "vb	str		Visible bell (must not move cursor)."
394.It "ve	str		Make cursor appear normal (undo"
395.Sy \&vs Ns / Sy \&vi ) .
396.It "vi	str		Make cursor invisible."
397.It "vs	str		Make cursor very visible."
398.It "vt	num		Virtual terminal number (not supported on all systems)."
399.It "wi	str	(N)	Set current window."
400.It "ws	num		Number of columns in status line."
401.It "xb	bool		Beehive"
402.Pf ( "f1=" Dv ESC ,
403.Pf "f2=" Sy \&^C ) .
404.It "xn	bool		Newline ignored after 80 cols (Concept)."
405.It "xo	bool		Terminal uses xoff/xon"
406.Pq Dv DC3 Ns / Ns Dv DC1
407handshaking.
408.It "xr	bool	(o)	Return acts like"
409.Sy "ce cr nl"
410(Delta Data).
411.It "xs	bool		Standout not erased by overwriting (Hewlett-Packard)."
412.It "xt	bool		Tabs ruin, magic"
413.SY \&so
414char (Teleray 1061).
415.It "xx	bool	(o)	Tektronix 4025 insert-line."
416.El
417.Ss A Sample Entry
418The following entry, which describes the Concept\-100, is among the more
419complex entries in the
420.Nm termcap
421file as of this writing.
422.Pp
423.Bd -literal
424ca\||\|concept100\||\|c100\||\|concept\||\|c104\||\|concept100-4p\||\|HDS Concept\-100:\e
425	:al=3*\eE^R:am:bl=^G:cd=16*\eE^C:ce=16\eE^U:cl=2*^L:cm=\eEa%+ %+ :\e
426	:co#80:.cr=9^M:db:dc=16\eE^A:dl=3*\eE^B:do=^J:ei=\eE\e200:eo:im=\eE^P:in:\e
427	:ip=16*:is=\eEU\eEf\eE7\eE5\eE8\eEl\eENH\eEK\eE\e200\eEo&\e200\eEo\e47\eE:k1=\eE5:\e
428	:k2=\eE6:k3=\eE7:kb=^h:kd=\eE<:ke=\eEx:kh=\eE?:kl=\eE>:kr=\eE=:ks=\eEX:\e
429	:ku=\eE;:le=^H:li#24:mb=\eEC:me=\eEN\e200:mh=\eEE:mi:mk=\eEH:mp=\eEI:\e
430	:mr=\eED:nd=\eE=:pb#9600:rp=0.2*\eEr%.%+ :se=\eEd\eEe:sf=^J:so=\eEE\eED:\e
431	:.ta=8\et:te=\eEv    \e200\e200\e200\e200\e200\e200\eEp\er\en:\e
432	:ti=\eEU\eEv  8p\eEp\er:ue=\eEg:ul:up=\eE;:us=\eEG:\e
433	:vb=\eEk\e200\e200\e200\e200\e200\e200\e200\e200\e200\e200\e200\e200\e200\e200\eEK:\e
434	:ve=\eEw:vs=\eEW:vt#8:xn:\e
435	:bs:cr=^M:dC#9:dT#8:nl=^J:ta=^I:pt:
436.Ed
437.Pp
438Entries may continue onto multiple lines by giving a \e as the last
439character of a line, and empty fields
440may be included for readability (here between the last field on a line
441and the first field on the next).
442Comments may be included on lines beginning with
443.Dq # .
444.Ss Types of Capabilities
445Capabilities in
446.Nm termcap
447are of three types: Boolean capabilities,
448which indicate particular features that the terminal has;
449numeric capabilities,
450giving the size of the display or the size of other attributes;
451and string capabilities,
452which give character sequences that can be used to perform particular
453terminal operations.
454All capabilities have two-letter codes.
455For instance, the fact that
456the Concept has
457.Em automatic margins
458(an automatic return and linefeed
459when the end of a line is reached) is indicated by the Boolean capability
460.Sy \&am .
461Hence the description of the Concept includes
462.Sy \&am .
463.Pp
464Numeric capabilities are followed by the character `#' then the value.
465In the example above
466.Sy \&co ,
467which indicates the number of columns the display has,
468gives the value `80' for the Concept.
469.Pp
470Finally, string-valued capabilities, such as
471.Sy \&ce
472(clear-to-end-of-line
473sequence) are given by the two-letter code, an `=', then a string
474ending at the next following `:'.
475A delay in milliseconds may appear after
476the `=' in such a capability,
477which causes padding characters to be supplied by
478.Xr tputs
479after the remainder of the string is sent to provide this delay.
480The delay can be either a number,
481such as `20', or a number followed by
482an `*',
483such as `3*'.
484An `*' indicates that the padding required is proportional
485to the number of lines affected by the operation, and the amount given is
486the per-affected-line padding required.
487(In the case of insert-character,
488the factor is still the number of
489.Em lines
490affected;
491this is always 1 unless the terminal has
492.Sy \&in
493and the software uses it.)
494When an `*' is specified, it is sometimes useful to give a delay of the form
495`3.5' to specify a delay per line to tenths of milliseconds.
496(Only one decimal place is allowed.)
497.Pp
498A number of escape sequences are provided in the string-valued capabilities
499for easy encoding of control characters there.
500.Sy \&\eE
501maps to an
502.Dv ESC
503character,
504.Sy \&^X
505maps to a control-X for any appropriate X,
506and the sequences
507.Sy \&\en
508.Sy \&\er
509.Sy \&\et
510.Sy \&\eb
511.Sy \&\ef
512map to linefeed, return, tab, backspace, and formfeed, respectively.
513Finally, characters may be given as three octal digits after a
514.Sy \&\e ,
515and the characters
516.Sy \&^
517and
518.Sy \&\e
519may be given as
520.Sy \&\e^
521and
522.Sy \&\e\e .
523If it is necessary to place a
524.Sy \&:
525in a capability it must be escaped in
526octal as
527.Sy \&\e072 .
528If it is necessary to place a
529.Dv NUL
530character in a string capability it
531must be encoded as
532.Sy \&\e200 .
533(The routines that deal with
534.Nm termcap
535use C strings and strip the high bits of the output very late, so that
536a
537.Sy \&\e200
538comes out as a
539.Sy \&\e000
540would.)
541.Pp
542Sometimes individual capabilities must be commented out.
543To do this, put a period before the capability name.
544For example, see the first
545.Sy \&cr
546and
547.Sy \&ta
548in the example above.
549.Ss Preparing Descriptions
550The most effective way to prepare a terminal description is by imitating
551the description of a similar terminal in
552.Nm termcap
553and to build up a description gradually, using partial descriptions
554with
555.Xr \&vi
556to check that they are correct.
557Be aware that a very unusual terminal may expose deficiencies in
558the ability of the
559.Nm termcap
560file to describe it
561or bugs in
562.Xr \&vi .
563To easily test a new terminal description you are working on
564you can put it in your home directory in a file called
565.Pa .termcap
566and programs will look there before looking in
567.Pa /usr/share/misc/termcap .
568You can also set the environment variable
569.Ev TERMPATH
570to a list of absolute file pathnames (separated by spaces or colons),
571one of which contains the description you are working on,
572and programs will search them in the order listed, and nowhere else.
573See
574.Xr termcap 3 .
575The
576.Ev TERMCAP
577environment variable is usually set to the
578.Nm termcap
579entry itself
580to avoid reading files when starting up a program.
581.Pp
582To get the padding for insert-line right
583(if the terminal manufacturer did not document it),
584a severe test is to use
585.Xr \&vi
586to edit
587.Pa /etc/passwd
588at 9600 baud, delete roughly 16 lines from the middle of the screen,
589then hit the `u' key several times quickly.
590If the display messes up, more padding is usually needed.
591A similar test can be used for insert-character.
592.Ss Basic Capabilities
593The number of columns on each line of the display is given by the
594.Sy \&co
595numeric capability.
596If the display is a
597.Tn CRT ,
598then the
599number of lines on the screen is given by the
600.Sy \&li
601capability.
602If the display wraps around to the beginning of the next line when
603the cursor reaches the right margin, then it should have the
604.Sy \&am
605capability.
606If the terminal can clear its screen,
607the code to do this is given by the
608.Sy \&cl
609string capability.
610If the terminal overstrikes
611(rather than clearing the position when a character is overwritten),
612it should have the
613.Sy \&os
614capability.
615If the terminal is a printing terminal,
616with no soft copy unit,
617give it both
618.Sy \&hc
619and
620.Sy \&os .
621.Pf ( Sy \&os
622applies to storage scope terminals,
623such as the Tektronix 4010 series,
624as well as to hard copy and
625.Tn APL
626terminals.)
627If there is a code to move the cursor to the left edge of the current row,
628give this as
629.Sy \&cr .
630(Normally this will be carriage-return,
631.Sy \&^M . )
632If there is a code to produce an audible signal (bell, beep,
633etc. ) ,
634give this as
635.Sy \&bl .
636.Pp
637If there is a code (such as backspace)
638to move the cursor one position to the left,
639that capability should be given as
640.Sy \&le .
641Similarly,
642codes to move to the right, up, and down
643should be given as
644.Sy \&nd ,
645.Sy \&up ,
646and
647.Sy \&do ,
648respectively.
649These
650.Em local cursor motions
651should not alter the text they pass over;
652for example, you would not normally use
653.Dq nd=\ \&
654unless the terminal has the
655.Sy \&os
656capability,
657because the space would erase the character moved over.
658.Pp
659A very important point here is that the local cursor motions encoded
660in
661.Nm termcap
662have undefined behavior at the left and top edges of a
663.Tn CRT
664display.
665Programs should never attempt to backspace around the left edge,
666unless
667.Sy \&bw
668is given, and never attempt to go up off the top
669using local cursor motions.
670.Pp
671In order to scroll text up,
672a program goes to the bottom left corner of the screen and sends the
673.Sy \&sf
674(index) string.
675To scroll text down,
676a program goes to the top left corner of the screen and sends the
677.Sy \&sr
678(reverse index) string.
679The strings
680.Sy \&sf
681and
682.Sy \&sr
683have undefined behavior
684when not on their respective corners of the screen.
685Parameterized versions of the scrolling sequences are
686.Sy \&SF
687and
688.Sy \&SR ,
689which have the same semantics as
690.Sy \&sf
691and
692.Sy \&sr
693except that they take one parameter
694and scroll that many lines.
695They also have undefined behavior
696except at the appropriate corner of the screen.
697.Pp
698The
699.Sy \&am
700capability tells whether the cursor sticks at the right
701edge of the screen when text is output there,
702but this does not necessarily apply to
703.Sy \&nd
704from the last column.
705Leftward local motion is defined from the left edge only when
706.Sy \&bw
707is given; then an
708.Sy \&le
709from the left edge will move to the right edge of the previous row.
710This is useful for drawing a box around the edge of the screen,
711for example.
712If the terminal has switch-selectable automatic margins,
713the
714.Nm termcap
715description usually assumes that this feature is on,
716.Em i.e . ,
717.Sy \&am .
718If the terminal has a command
719that moves to the first column of the next line,
720that command can be given as
721.Sy \&nw
722(newline).
723It is permissible for this to clear the remainder of the current line,
724so if the terminal has no correctly-working
725.Tn \&CR
726and
727.Tn \&LF
728it may still be possible to craft a working
729.Sy \&nw
730out of one or both of them.
731.Pp
732These capabilities suffice to describe hardcopy and
733.Dq glass-tty
734terminals.
735Thus the Teletype model 33 is described as
736.Bd -literal -offset indent
737T3\||\|tty33\||\|33\||\|tty\||\|Teletype model 33:\e
738	:bl=^G:co#72:cr=^M:do=^J:hc:os:
739.Ed
740.Pp
741and the Lear Siegler
742.Tn ADM Ns \-3
743is described as
744.Bd -literal -offset indent
745l3\||\|adm3\||\|3\||\|LSI \s-1ADM\s0-3:\e
746:am:bl=^G:cl=^Z:co#80:cr=^M:do=^J:le=^H:li#24:sf=^J:
747.Ed
748.Ss Parameterized Strings
749Cursor addressing and other strings requiring parameters
750are described by a
751parameterized string capability, with
752.Xr printf 3 Ns \-like
753escapes
754.Sy \&%x
755in it,
756while other characters are passed through unchanged.
757For example, to address the cursor the
758.Sy \&cm
759capability is given, using two parameters: the row and column to move to.
760(Rows and columns are numbered from zero and refer to the physical screen
761visible to the user, not to any unseen memory.
762If the terminal has memory-relative cursor addressing,
763that can be indicated by an analogous
764.Sy \&CM
765capability.)
766.Pp
767The
768.Sy \&%
769encodings have the following meanings:
770.Bl -column xxxxx
771.It "%%	output `%'"
772.It "%d	output value as in"
773.Xr printf
774%d
775.It "%2	output value as in"
776.Xr printf
777%2d
778.It "%3	output value as in"
779.Xr printf
780%3d
781.It "%.	output value as in"
782.Xr printf
783%c
784.It "%+" Ns Em x Ta No add
785.Em x
786to value, then do %.
787.It "%>" Ns Em \&xy Ta No if
788value >
789.Em x
790then add
791.Em y ,
792no output
793.It "%r	reverse order of two parameters, no output"
794.It "%i	increment by one, no output"
795.It "%n	exclusive-or all parameters with 0140 (Datamedia 2500)"
796.It "%B" Ta Tn BCD No "(16*(value/10)) + (value%10), no output"
797.It "%D	Reverse coding (value \- 2*(value%16)), no output (Delta Data)."
798.El
799.Pp
800Consider the Hewlett-Packard 2645, which, to get to row 3 and column 12, needs
801to be sent
802.Dq \eE&a12c03Y
803padded for 6 milliseconds.
804Note that the order
805of the row and column coordinates is reversed here
806and that the row and column
807are sent as two-digit integers.
808Thus its
809.Sy \&cm
810capability is
811.Dq Li cm=6\eE&%r%2c%2Y .
812.Pp
813The Datamedia 2500 needs the current row and column sent
814encoded in binary using
815.Dq \&%. .
816Terminals that use
817.Dq \&%.
818need to be able to
819backspace the cursor
820.Po Sy \&le Pc
821and to move the cursor up one line on the screen
822.Po Sy \&up Pc .
823This is necessary because it is not always safe to transmit
824.Sy \&\en ,
825.Sy \&^D ,
826and
827.Sy \&\er ,
828as the system may change or discard them.
829(Programs using
830.Nm termcap
831must set terminal modes so that tabs are not expanded, so
832.Sy \&\et
833is safe to send.
834This turns out to be essential for the Ann Arbor 4080.)
835.Pp
836A final example is the Lear Siegler
837.Tn ADM Ns \-3a,
838which offsets row and column
839by a blank character, thus
840.Dq Li cm=\eE=%+ %+\ \& .
841.Pp
842Row or column absolute cursor addressing
843can be given as single parameter capabilities
844.Sy \&ch
845(horizontal position absolute) and
846.Sy \&cv
847(vertical position absolute).
848Sometimes these are shorter than the more general two-parameter sequence
849(as with the Hewlett-Packard 2645) and can be used in preference to
850.Sy \&cm .
851If there are parameterized local motions
852.Pf ( Em e.g . ,
853move
854.Ar n
855positions to the right)
856these can be given as
857.Sy \&DO ,
858.Sy \&LE ,
859.Sy \&RI ,
860and
861.Sy \&UP
862with a single parameter indicating how many positions to move.
863These are primarily useful if the terminal does not have
864.Sy \&cm ,
865such as the Tektronix 4025.
866.Ss Cursor Motions
867.Pp
868If the terminal has a fast way to home the cursor
869(to the very upper left corner of the screen), this can be given as
870.Sy \&ho .
871Similarly, a fast way of getting to the lower left-hand corner
872can be given as
873.Sy \&ll ;
874this may involve going up with
875.Sy \&up
876from the home position,
877but a program should never do this itself (unless
878.Sy \&ll
879does), because it can
880make no assumption about the effect of moving up from the home position.
881Note that the home position is the same as
882cursor address (0,0): to the top left corner of the screen, not of memory.
883(Therefore, the
884.Dq \eEH
885sequence on Hewlett-Packard terminals
886cannot be used for
887.Sy \&ho . )
888.Ss Area Clears
889If the terminal can clear from the current position to the end of the
890line, leaving the cursor where it is, this should be given as
891.Sy \&ce .
892If the terminal can clear from the current position to the end of the
893display, this should be given as
894.Sy \&cd .
895.Sy \&cd
896must only be invoked from the first column of a line.
897(Therefore,
898it can be simulated by a request to delete a large number of lines,
899if a true
900.Sy \&cd
901is not available.)
902.Ss Insert/Delete Line
903If the terminal can open a new blank line
904before the line containing the cursor,
905this should be given as
906.Sy \&al ;
907this must be invoked only from the first
908position of a line.
909The cursor must then appear at the left of the newly blank line.
910If the terminal can delete the line that the cursor is on, this
911should be given as
912.Sy \&dl ;
913this must only be used from the first position on
914the line to be deleted.
915Versions of
916.Sy \&al
917and
918.Sy \&dl
919which take a single parameter
920and insert or delete that many lines
921can be given as
922.Sy \&AL
923and
924.Sy \&DL .
925If the terminal has a settable scrolling region
926(like the VT100),
927the command to set this can be described with the
928.Sy \&cs
929capability,
930which takes two parameters: the top and bottom lines of the scrolling region.
931The cursor position is, alas, undefined after using this command.
932It is possible to get the effect of insert or delete line
933using this command \(em the
934.Sy \&sc
935and
936.Sy \&rc
937(save and restore cursor) commands are also useful.
938Inserting lines at the top or bottom of the screen can also be done using
939.Sy \&sr
940or
941.Sy \&sf
942on many terminals without a true insert/delete line,
943and is often faster even on terminals with those features.
944.Pp
945If the terminal has the ability to define a window as part of memory
946which all commands affect, it should be given as the parameterized string
947.Sy \&wi .
948The four parameters are the starting and ending lines in memory
949and the starting and ending columns in memory, in that order.
950(This
951.Xr terminfo
952capability is described for completeness.
953It is unlikely that any
954.Nm termcap Ns \- using
955program will support it.)
956.Pp
957If the terminal can retain display memory above the screen, then the
958.Sy \&da
959capability should be given;
960if display memory can be retained
961below, then
962.Sy \&db
963should be given.
964These indicate
965that deleting a line or scrolling may bring non-blank lines up from below
966or that scrolling back with
967.Sy \&sr
968may bring down non-blank lines.
969.Ss Insert/Delete Character
970There are two basic kinds of intelligent terminals with respect to
971insert/delete character that can be described using
972.Nm termcap .
973The most common insert/delete character operations affect only the characters
974on the current line and shift characters off the end of the line rigidly.
975Other terminals, such as the Concept\-100 and the Perkin Elmer Owl, make
976a distinction between typed and untyped blanks on the screen, shifting
977upon an insert or delete only to an untyped blank on the screen which is
978either eliminated or expanded to two untyped blanks.
979You can determine
980the kind of terminal you have by clearing the screen then typing
981text separated by cursor motions.
982Type
983.Dq Li abc\ \ \ \ def
984using local
985cursor motions (not spaces) between the
986.Dq abc
987and the
988.Dq def .
989Then position the cursor before the
990.Dq abc
991and put the terminal in insert
992mode.
993If typing characters causes the rest of the line to shift
994rigidly and characters to fall off the end, then your terminal does
995not distinguish between blanks and untyped positions.
996If the
997.Dq abc
998shifts over to the
999.Dq def
1000which then move together around the end of the
1001current line and onto the next as you insert, then you have the second type of
1002terminal and should give the capability
1003.Sy \&in ,
1004which stands for
1005.Dq insert null .
1006While these are two logically separate attributes
1007(one line
1008.Em \&vs .
1009multi-line insert mode,
1010and special treatment of untyped spaces),
1011we have seen no terminals whose insert
1012mode cannot be described with the single attribute.
1013.Pp
1014.Nm Termcap
1015can describe both terminals that have an insert mode and terminals
1016that send a simple sequence to open a blank position on the current line.
1017Give as
1018.Sy \&im
1019the sequence to get into insert mode.
1020Give as
1021.Sy \&ei
1022the sequence to leave insert mode.
1023Now give as
1024.Sy \&ic
1025any sequence that needs to be sent just before
1026each character to be inserted.
1027Most terminals with a true insert mode
1028will not give
1029.Sy \&ic ;
1030terminals that use a sequence to open a screen
1031position should give it here.
1032(If your terminal has both,
1033insert mode is usually preferable to
1034.Sy \&ic .
1035Do not give both unless the terminal actually requires both to be used
1036in combination.)
1037If post-insert padding is needed, give this as a number of milliseconds
1038in
1039.Sy \&ip
1040(a string option).
1041Any other sequence that may need to be
1042sent after insertion of a single character can also be given in
1043.Sy \&ip .
1044If your terminal needs to be placed into an `insert mode'
1045and needs a special code preceding each inserted character,
1046then both
1047.Sy \&im Ns / Sy \&ei
1048and
1049.Sy \&ic
1050can be given, and both will be used.
1051The
1052.Sy \&IC
1053capability, with one parameter
1054.Em n ,
1055will repeat the effects of
1056.Sy \&ic
1057.Em n
1058times.
1059.Pp
1060It is occasionally necessary to move around while in insert mode
1061to delete characters on the same line
1062.Pf ( Em e.g . ,
1063if there is a tab after
1064the insertion position).
1065If your terminal allows motion while in
1066insert mode, you can give the capability
1067.Sy \&mi
1068to speed up inserting
1069in this case.
1070Omitting
1071.Sy \&mi
1072will affect only speed.
1073Some terminals
1074(notably Datamedia's) must not have
1075.Sy \&mi
1076because of the way their
1077insert mode works.
1078.Pp
1079Finally, you can specify
1080.Sy \&dc
1081to delete a single character,
1082.Sy \&DC
1083with one parameter
1084.Em n
1085to delete
1086.Em n
1087characters,
1088and delete mode by giving
1089.Sy \&dm
1090and
1091.Sy \&ed
1092to enter and exit delete mode
1093(which is any mode the terminal needs to be placed in for
1094.Sy \&dc
1095to work).
1096.Ss Highlighting, Underlining, and Visible  Bells
1097If your terminal has one or more kinds of display attributes,
1098these can be represented in a number of different ways.
1099You should choose one display form as
1100.Em standout mode ,
1101representing a good high-contrast, easy-on-the-eyes format
1102for highlighting error messages and other attention getters.
1103(If you have a choice, reverse video plus half-bright is good,
1104or reverse video alone.)
1105The sequences to enter and exit standout mode
1106are given as
1107.Sy \&so
1108and
1109.Sy \&se ,
1110respectively.
1111If the code to change into or out of standout
1112mode leaves one or even two blank spaces or garbage characters on the screen,
1113as the
1114.Tn TVI
1115912 and Teleray 1061 do,
1116then
1117.Sy \&sg
1118should be given to tell how many characters are left.
1119.Pp
1120Codes to begin underlining and end underlining can be given as
1121.Sy \&us
1122and
1123.Sy \&ue ,
1124respectively.
1125Underline mode change garbage is specified by
1126.Sy \&ug ,
1127similar to
1128.Sy \&sg .
1129If the terminal has a code to underline the current character and move
1130the cursor one position to the right,
1131such as the Microterm Mime,
1132this can be given as
1133.Sy \&uc .
1134.Pp
1135Other capabilities to enter various highlighting modes include
1136.Sy \&mb
1137(blinking),
1138.Sy \&md
1139(bold or extra bright),
1140.Sy \&mh
1141(dim or half-bright),
1142.Sy \&mk
1143(blanking or invisible text),
1144.Sy \&mp
1145(protected),
1146.Sy \&mr
1147(reverse video),
1148.Sy \&me
1149(turn off
1150.Em all
1151attribute modes),
1152.Sy \&as
1153(enter alternate character set mode), and
1154.Sy \&ae
1155(exit alternate character set mode).
1156Turning on any of these modes singly may or may not turn off other modes.
1157.Pp
1158If there is a sequence to set arbitrary combinations of mode,
1159this should be given as
1160.Sy \&sa
1161(set attributes), taking 9 parameters.
1162Each parameter is either 0 or 1,
1163as the corresponding attributes is on or off.
1164The 9 parameters are, in order: standout, underline, reverse, blink,
1165dim, bold, blank, protect, and alternate character set.
1166Not all modes need be supported by
1167.Sy \&sa ,
1168only those for which corresponding attribute commands exist.
1169(It is unlikely that a
1170.Nm termcap Ns \-using
1171program will support this capability, which is defined for compatibility
1172with
1173.Xr terminfo . )
1174.Pp
1175Terminals with the
1176.Dq magic cookie
1177glitches
1178.Pf ( Sy \&sg
1179and
1180.Sy \&ug ) ,
1181rather than maintaining extra attribute bits for each character cell,
1182instead deposit special
1183.Dq cookies ,
1184or
1185.Dq garbage characters ,,
1186when they receive mode-setting sequences,
1187which affect the display algorithm.
1188.Pp
1189Some terminals,
1190such as the Hewlett-Packard 2621,
1191automatically leave standout
1192mode when they move to a new line or when the cursor is addressed.
1193Programs using standout mode
1194should exit standout mode on such terminals
1195before moving the cursor or sending a newline.
1196On terminals where this is not a problem,
1197the
1198.Sy \&ms
1199capability should be present
1200to say that this overhead is unnecessary.
1201.Pp
1202If the terminal has
1203a way of flashing the screen to indicate an error quietly
1204(a bell replacement),
1205this can be given as
1206.Sy \&vb ;
1207it must not move the cursor.
1208.Pp
1209If the cursor needs to be made more visible than normal
1210when it is not on the bottom line
1211(to change, for example, a non-blinking underline into an easier-to-find
1212block or blinking underline),
1213give this sequence as
1214.Sy \&vs .
1215If there is a way to make the cursor completely invisible, give that as
1216.Sy \&vi .
1217The capability
1218.Sy \&ve ,
1219which undoes the effects of both of these modes,
1220should also be given.
1221.Pp
1222If your terminal correctly displays underlined characters
1223(with no special codes needed)
1224even though it does not overstrike,
1225then you should give the capability
1226.Sy \&ul .
1227If overstrikes are erasable with a blank,
1228this should be indicated by giving
1229.Sy \&eo .
1230.Ss Keypad
1231If the terminal has a keypad that transmits codes when the keys are pressed,
1232this information can be given.
1233Note that it is not possible to handle
1234terminals where the keypad only works in local mode
1235(this applies, for example, to the unshifted Hewlett-Packard 2621 keys).
1236If the keypad can be set to transmit or not transmit,
1237give these codes as
1238.Sy \&ks
1239and
1240.Sy \&ke .
1241Otherwise the keypad is assumed to always transmit.
1242The codes sent by the left-arrow, right-arrow, up-arrow, down-arrow,
1243and home keys can be given as
1244.Sy \&kl ,
1245.Sy \&kr ,
1246.Sy \&ku ,
1247.Sy \&kd ,
1248and
1249.Sy \&kh ,
1250respectively.
1251If there are function keys such as f0, f1, ..., f9, the codes they send
1252can be given as
1253.Sy \&k0 ,
1254.Sy \&k1 ,
1255...,
1256.Sy \&k9 .
1257If these keys have labels other than the default f0 through f9, the labels
1258can be given as
1259.Sy \&l0 ,
1260.Sy \&l1 ,
1261...,
1262.Sy \&l9 .
1263The codes transmitted by certain other special keys can be given:
1264.Sy \&kH
1265(home down),
1266.Sy \&kb
1267(backspace),
1268.Sy \&ka
1269(clear all tabs),
1270.Sy \&kt
1271(clear the tab stop in this column),
1272.Sy \&kC
1273(clear screen or erase),
1274.Sy \&kD
1275(delete character),
1276.Sy \&kL
1277(delete line),
1278.Sy \&kM
1279(exit insert mode),
1280.Sy \&kE
1281(clear to end of line),
1282.Sy \&kS
1283(clear to end of screen),
1284.Sy \&kI
1285(insert character or enter insert mode),
1286.Sy \&kA
1287(insert line),
1288.Sy \&kN
1289(next page),
1290.Sy \&kP
1291(previous page),
1292.Sy \&kF
1293(scroll forward/down),
1294.Sy \&kR
1295(scroll backward/up), and
1296.Sy \&kT
1297(set a tab stop in this column).
1298In addition, if the keypad has a 3 by 3 array of keys
1299including the four arrow keys, then the other five keys can be given as
1300.Sy \&K1 ,
1301.Sy \&K2 ,
1302.Sy \&K3 ,
1303.Sy \&K4 ,
1304and
1305.Sy \&K5 .
1306These keys are useful when the effects of a 3 by 3 directional pad are needed.
1307The obsolete
1308.Sy \&ko
1309capability formerly used to describe
1310.Dq other
1311function keys has been
1312completely supplanted by the above capabilities.
1313.Pp
1314The
1315.Sy \&ma
1316entry is also used to indicate arrow keys on terminals that have
1317single-character arrow keys.
1318It is obsolete but still in use in
1319version 2 of
1320.Sy \&vi
1321which must be run on some minicomputers due to
1322memory limitations.
1323This field is redundant with
1324.Sy \&kl ,
1325.Sy \&kr ,
1326.Sy \&ku ,
1327.Sy \&kd ,
1328and
1329.Sy \&kh .
1330It consists of groups of two characters.
1331In each group, the first character is what an arrow key sends, and the
1332second character is the corresponding
1333.Sy \&vi
1334command.
1335These commands are
1336.Ar h
1337for
1338.Sy \&kl ,
1339.Ar j
1340for
1341.Sy \&kd ,
1342.Ar k
1343for
1344.Sy \&ku ,
1345.Ar l
1346for
1347.Sy \&kr ,
1348and
1349.Ar H
1350for
1351.Sy \&kh .
1352For example, the Mime would have
1353.Dq Li ma=^Hh^Kj^Zk^Xl
1354indicating arrow keys left (^H), down (^K), up (^Z), and right (^X).
1355(There is no home key on the Mime.)
1356.Ss Tabs and Initialization
1357If the terminal needs to be in a special mode when running
1358a program that uses these capabilities,
1359the codes to enter and exit this mode can be given as
1360.Sy \&ti
1361and
1362.Sy \&te .
1363This arises, for example, from terminals like the Concept with more than
1364one page of memory.
1365If the terminal has only memory-relative cursor addressing and not
1366screen-relative cursor addressing,
1367a screen-sized window must be fixed into
1368the display for cursor addressing to work properly.
1369This is also used for the Tektronix 4025, where
1370.Sy \&ti
1371sets the command character to be the one used by
1372.Nm termcap .
1373.Pp
1374Other capabilities
1375include
1376.Sy \&is ,
1377an initialization string for the terminal,
1378and
1379.Sy \&if ,
1380the name of a file containing long initialization strings.
1381These strings are expected to set the terminal into modes
1382consistent with the rest of the
1383.Nm termcap
1384description.
1385They are normally sent to the terminal by the
1386.Xr tset
1387program each time the user logs in.
1388They will be printed in the following order:
1389.Sy \&is ;
1390setting tabs using
1391.Sy \&ct
1392and
1393.Sy \&st ;
1394and finally
1395.Sy \&if .
1396.Pf ( Xr Terminfo
1397uses
1398.Sy \&i\&1-i2
1399instead of
1400.Sy \&is
1401and runs the program
1402.Sy \&iP
1403and prints
1404.Sy "\&i\&3"
1405after the other initializations.)
1406A pair of sequences that does a harder reset from a totally unknown state
1407can be analogously given as
1408.Sy \&rs
1409and
1410.Sy \&if .
1411These strings are output by the
1412.Xr reset
1413program, which is used when the terminal gets into a wedged state.
1414.Pf ( Xr Terminfo
1415uses
1416.Sy "\&r1-r3"
1417instead of
1418.Sy \&rs . )
1419Commands are normally placed in
1420.Sy \&rs
1421and
1422.Sy \&rf
1423only if they produce annoying effects on the screen and are not necessary
1424when logging in.
1425For example, the command to set the VT100 into 80-column mode
1426would normally be part of
1427.Sy \&is ,
1428but it causes an annoying glitch of the screen and is not normally needed
1429since the terminal is usually already in 80-column mode.
1430.Pp
1431If the terminal has hardware tabs,
1432the command to advance to the next tab stop can be given as
1433.Sy \&ta
1434(usually
1435.Sy \&^I ) .
1436A
1437.Dq backtab
1438command which moves leftward to the previous tab stop
1439can be given as
1440.Sy \&bt .
1441By convention,
1442if the terminal driver modes indicate that tab stops are being expanded
1443by the computer rather than being sent to the terminal,
1444programs should not use
1445.Sy \&ta
1446or
1447.Sy \&bt
1448even if they are present,
1449since the user may not have the tab stops properly set.
1450If the terminal has hardware tabs that are initially set every
1451.Ar n
1452positions when the terminal is powered up, then the numeric parameter
1453.Sy \&it
1454is given, showing the number of positions between tab stops.
1455This is normally used by the
1456.Xr tset
1457command to determine whether to set the driver mode for hardware tab
1458expansion, and whether to set the tab stops.
1459If the terminal has tab stops that can be saved in nonvolatile memory, the
1460.Nm termcap
1461description can assume that they are properly set.
1462.Pp
1463If there are commands to set and clear tab stops, they can be given as
1464.Sy \&ct
1465(clear all tab stops) and
1466.Sy \&st
1467(set a tab stop in the current column of every row).
1468If a more complex sequence is needed to set the tabs than can be
1469described by this, the sequence can be placed in
1470.Sy \&is
1471or
1472.Sy \&if .
1473.Ss Delays
1474Certain capabilities control padding in the terminal driver.
1475These are primarily needed by hardcopy terminals and are used by the
1476.Xr tset
1477program to set terminal driver modes appropriately.
1478Delays embedded in the capabilities
1479.Sy \&cr ,
1480.Sy \&sf ,
1481.Sy \&le ,
1482.Sy \&ff ,
1483and
1484.Sy \&ta
1485will cause the appropriate delay bits to be set in the terminal driver.
1486If
1487.Sy \&pb
1488(padding baud rate) is given, these values can be ignored at baud rates
1489below the value of
1490.Sy \&pb .
1491For
1492.Bx 4.2
1493.Xr tset ,
1494the delays are given as numeric capabilities
1495.Sy \&dC ,
1496.Sy \&dN ,
1497.Sy \&dB ,
1498.Sy \&dF ,
1499and
1500.Sy \&dT
1501instead.
1502.Ss Miscellaneous
1503If the terminal requires other than a
1504.Dv NUL
1505(zero) character as a pad,
1506this can be given as
1507.Sy \&pc .
1508Only the first character of the
1509.Sy \&pc
1510string is used.
1511.Pp
1512If the terminal has commands to save and restore the position of the
1513cursor, give them as
1514.Sy \&sc
1515and
1516.Sy \&rc .
1517.Pp
1518If the terminal has an extra
1519.Dq status line
1520that is not normally used by
1521software, this fact can be indicated.
1522If the status line is viewed as an extra line below the bottom line,
1523then the capability
1524.Sy \&hs
1525should be given.
1526Special strings to go to a position in the status line and to return
1527from the status line can be given as
1528.Sy \&ts
1529and
1530.Sy \&fs .
1531.Pf ( Xr \&fs
1532must leave the cursor position in the same place that it was before
1533.Sy \&ts .
1534If necessary, the
1535.Sy \&sc
1536and
1537.Sy \&rc
1538strings can be included in
1539.Sy \&ts
1540and
1541.Sy \&fs
1542to get this effect.)
1543The capability
1544.Sy \&ts
1545takes one parameter, which is the column number of the status line
1546to which the cursor is to be moved.
1547If escape sequences and other special commands such as tab work while in
1548the status line, the flag
1549.Sy \&es
1550can be given.
1551A string that turns off the status line (or otherwise erases its contents)
1552should be given as
1553.Sy \&ds .
1554The status line is normally assumed to be the same width as the
1555rest of the screen,
1556.Em i.e . ,
1557.Sy \&co .
1558If the status line is a different width (possibly because the terminal
1559does not allow an entire line to be loaded), then its width in columns
1560can be indicated with the numeric parameter
1561.Sy \&ws .
1562.Pp
1563If the terminal can move up or down half a line, this can be
1564indicated with
1565.Sy \&hu
1566(half-line up) and
1567.Sy \&hd
1568(half-line down).
1569This is primarily useful for superscripts and subscripts on hardcopy
1570terminals.
1571If a hardcopy terminal can eject to the next page (form feed),
1572give this as
1573.Sy \&ff
1574(usually
1575.Sy \&^L ) .
1576.Pp
1577If there is a command to repeat a given character a given number of times
1578(to save time transmitting a large number of identical characters),
1579this can be indicated with the parameterized string
1580.Sy \&rp .
1581The first parameter is the character to be repeated and the second is
1582the number of times to repeat it.
1583(This is a
1584.Xr terminfo
1585feature that is unlikely to be supported by a program that uses
1586.Nm termcap . )
1587.Pp
1588If the terminal has a settable command character, such as the
1589Tektronix 4025, this can be indicated with
1590.Sy \&CC .
1591A prototype command character is chosen which is used in all capabilities.
1592This character is given in the
1593.Sy \&CC
1594capability to identify it.
1595The following convention is supported on some
1596.Ux
1597systems:
1598The environment is to be searched for a
1599.Ev \&CC
1600variable,
1601and if found,
1602all occurrences of the prototype character are replaced by the character
1603in the environment variable.
1604This use of the
1605.Ev \&CC
1606environment variable
1607is a very bad idea, as it conflicts with
1608.Xr make 1 .
1609.Pp
1610Terminal descriptions that do not represent a specific kind of known
1611terminal, such as
1612.Em switch ,
1613.Em dialup ,
1614.Em patch ,
1615and
1616.Xr network ,
1617should include the
1618.Sy \&gn
1619(generic) capability so that programs can complain that they do not know
1620how to talk to the terminal.
1621(This capability does not apply to
1622.Em virtual
1623terminal descriptions for which the escape sequences are known.)
1624.Pp
1625If the terminal uses xoff/xon
1626.Pq Tn DC3 Ns / Ns Tn DC1
1627handshaking for flow control, give
1628.Sy \&xo .
1629Padding information should still be included so that routines can make
1630better decisions about costs, but actual pad characters will not be
1631transmitted.
1632.Pp
1633If the terminal has a
1634.Dq meta key
1635which acts as a shift key, setting the
16368th bit of any character transmitted, then this fact can be indicated with
1637.Sy \&km .
1638Otherwise, software will assume that the 8th bit is parity and it will
1639usually be cleared.
1640If strings exist to turn this
1641.Dq meta mode
1642on and off, they can be given as
1643.Sy \&mm
1644and
1645.Sy \&mo .
1646.Pp
1647If the terminal has more lines of memory than will fit on the screen at once,
1648the number of lines of memory can be indicated with
1649.Sy \&lm .
1650An explicit value of 0 indicates that the number of lines is not fixed,
1651but that there is still more memory than fits on the screen.
1652.Pp
1653If the terminal is one of those supported by the
1654.Ux
1655system virtual
1656terminal protocol, the terminal number can be given as
1657.Sy \&vt .
1658.Pp
1659Media copy strings which control an auxiliary printer
1660connected to the terminal can be given as
1661.Sy \&ps :
1662print the contents of the screen;
1663.Sy \&pf :
1664turn off the printer; and
1665.Sy \&po :
1666turn on the printer.
1667When the printer is on, all text sent to the terminal will be sent to the
1668printer.
1669It is undefined whether the text is also displayed on the terminal screen
1670when the printer is on.
1671A variation
1672.Sy \&pO
1673takes one parameter and leaves the printer on for as many characters as the
1674value of the parameter, then turns the printer off.
1675The parameter should not exceed 255.
1676All text, including
1677.Sy \&pf ,
1678is transparently passed to the printer while
1679.Sy \&pO
1680is in effect.
1681.Pp
1682Strings to program function keys can be given as
1683.Sy \&pk ,
1684.Sy \&pl ,
1685and
1686.Sy \&px .
1687Each of these strings takes two parameters: the function key number
1688to program (from 0 to 9) and the string to program it with.
1689Function key numbers out of this range may program undefined keys
1690in a terminal-dependent manner.
1691The differences among the capabilities are that
1692.Sy \&pk
1693causes pressing the given key to be the same as the user typing the given
1694string;
1695.Sy \&pl
1696causes the string to be executed by the terminal in local mode;
1697and
1698.Sy \&px
1699causes the string to be transmitted to the computer.
1700Unfortunately, due to lack of a definition for string parameters in
1701.Nm termcap ,
1702only
1703.Xr terminfo
1704supports these capabilities.
1705.Ss Glitches and Braindamage
1706Hazeltine terminals, which do not allow `~' characters to be displayed,
1707should indicate
1708.Sy \&hz .
1709.Pp
1710The
1711.Sy \&nc
1712capability, now obsolete, formerly indicated Datamedia terminals,
1713which echo
1714.Sy \&\er \en
1715for
1716carriage return then ignore a following linefeed.
1717.Pp
1718Terminals that ignore a linefeed immediately after an
1719.Sy \&am
1720wrap, such as the Concept, should indicate
1721.Sy \&xn .
1722.Pp
1723If
1724.Sy \&ce
1725is required to get rid of standout
1726(instead of merely writing normal text on top of it),
1727.Sy \&xs
1728should be given.
1729.Pp
1730Teleray terminals, where tabs turn all characters moved over to blanks,
1731should indicate
1732.Sy \&xt
1733(destructive tabs).
1734This glitch is also taken to mean that it is not possible
1735to position the cursor on top of a \*(lqmagic cookie\*(rq, and that
1736to erase standout mode it is necessary to use delete and insert line.
1737.Pp
1738The Beehive Superbee, which is unable to correctly transmit the
1739.Dv ESC
1740or
1741.Sy \&^C
1742characters, has
1743.Sy \&xb ,
1744indicating that the
1745.Dq \&f\&1
1746key is used for
1747.Dv ESC
1748and
1749.Dq \&f\&2
1750for ^C.
1751(Only certain Superbees have this problem, depending on the
1752.Tn ROM . )
1753.Pp
1754Other specific terminal problems may be corrected by adding more
1755capabilities of the form
1756.Sy x Em x .
1757.Ss Similar Terminals
1758If there are two very similar terminals,
1759one can be defined as being just like the other with certain exceptions.
1760The string capability
1761.Sy \&tc
1762can be given
1763with the name of the similar terminal.
1764This capability must be
1765.Em last ,
1766and the combined length of the entries
1767must not exceed 1024.
1768The capabilities given before
1769.Sy \&tc
1770override those in the terminal type invoked by
1771.Sy \&tc .
1772A capability can be canceled by placing
1773.Sy \&xx@
1774to the left of the
1775.Sy \&tc
1776invocation, where
1777.Sy \&xx
1778is the capability.
1779For example, the entry
1780.Bd -literal -offset indent
1781hn\||\|2621\-nl:ks@:ke@:tc=2621:
1782.Ed
1783.Pp
1784defines a
1785.Dq 2621\-nl
1786that does not have the
1787.Sy \&ks
1788or
1789.Sy \&ke
1790capabilities,
1791hence does not turn on the function key labels when in visual mode.
1792This is useful for different modes for a terminal, or for different
1793user preferences.
1794.Sh FILES
1795.Bl -tag -width /usr/share/misc/termcap.db -compact
1796.It Pa /usr/share/misc/termcap
1797File containing terminal descriptions.
1798.It Pa /usr/share/misc/termcap.db
1799Hash database file containing terminal descriptions (see
1800.Xr cap_mkdb 1 ) .
1801.El
1802.Sh SEE ALSO
1803.Xr cap_mkdb 1 ,
1804.Xr ex 1 ,
1805.Xr more 1 ,
1806.Xr tset 1 ,
1807.Xr ul 1 ,
1808.Xr vi 1 ,
1809.Xr curses 3 ,
1810.Xr printf 3 ,
1811.Xr termcap 3 ,
1812.Xr term 5
1813.Sh CAVEATS AND BUGS
1814The
1815.Em Note :
1816.Nm termcap
1817functions
1818were replaced by
1819.Xr terminfo
1820in
1821.At V
1822Release 2.0.
1823The transition will be relatively painless if capabilities flagged as
1824.Dq obsolete
1825are avoided.
1826.Pp
1827Lines and columns are now stored by the kernel as well as in the termcap
1828entry.
1829Most programs now use the kernel information primarily; the information
1830in this file is used only if the kernel does not have any information.
1831.Pp
1832.Xr \&Vi
1833allows only 256 characters for string capabilities, and the routines
1834in
1835.Xr termlib 3
1836do not check for overflow of this buffer.
1837The total length of a single entry (excluding only escaped newlines)
1838may not exceed 1024.
1839.Pp
1840Not all programs support all entries.
1841.Sh HISTORY
1842The
1843.Nm
1844file format appeared in
1845.Bx 3 .
1846