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