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