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