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