BSD 3 development
[unix-history] / usr / man / man5 / termcap.5
CommitLineData
5698e3d1
BJ
1.TH TERMCAP 5 10/22/79 5
2.UC
3.SH NAME
4termcap \- terminal capability data base
5.SH SYNOPSIS
6/etc/termcap
7.SH DESCRIPTION
8.I Termcap
9is a data base describing terminals.
10Terminals are described in
11.I termcap
12by giving a set of capabilities which they have, and by describing
13how operations are performed.
14Padding requirements and initialization sequences
15are included in
16.I termcap.
17.PP
18Entries in
19.I termcap
20consist of a number of `:' separated fields.
21The first entry for each terminal gives the names which are known for the
22terminal, separated by `|' characters. The first name is always 2 characters
23long and is used by older version 6 systems which store the terminal type
24in a 16 bit word in a systemwide data base.
25The second name given is the most common abbreviation for the terminal, and the
26last name given should be a long name fully identifying the terminal.
27The second name should contain no blanks; the last name may well contain
28blanks for readability.
29.SH CAPABILITIES
30.nf
31(P) indicates padding may be specified
32(P*) indicates that padding may be based on no. lines affected
33
34.ta .7i 1.4i 2.1i
35\fBName Type Pad? Description\fR
36al str (P*) Add new blank line
37am bool Terminal has automatic margins
38bc str Backspace if not \fB^H\fR
39bs bool Terminal can backspace with \fB^H\fR
40cd str (P*) Clear to end of display
41co num Number of columns in a line
42ce str (P) Clear to end of line
43cl str (P*) Clear screen
44cm str (P) Cursor motion
45cr str (P*) Carriage return, (default \fB^M\fR)
46da bool Display may be retained above
47db bool Display may be retained below
48dc str (P*) Delete character
49dl str (P*) Delete line
50dm str Delete mode (enter)
51ed str End delete mode
52ei str End insert mode; give ``:ei=:'' if \fBic\fR
53eo str Can erase overstrikes with a blank
54ff str (P*) Hardcopy terminal page eject (default \fB^L\fR)
55hc bool Hardcopy terminal
56hd str Half-line down (forward 1/2 linefeed)
57ho str Home cursor (if no \fBcm\fR)
58hu str Half-line up (reverse 1/2 linefeed)
59hz str Hazeltine; can't print ~'s
60ic str (P) Insert character
61if str Name of file containing \fBis\fR
62im bool Insert mode (enter); give ``:im=:'' if \fBic\fR
63in bool Insert mode distinguishes nulls on display
64ip str (P*) Insert pad after character inserted
65is str Terminal initialization string
66k0-k9 str Sent by ``other'' function keys 0-9
67kd str Sent by terminal down arrow key
68ke str Out of ``keypad transmit'' mode
69kl str Sent by terminal left arrow key
70ko str Termcap entries for other non-function keys
71kr str Sent by terminal right arrow key
72ks str Put terminal in ``keypad transmit'' mode
73ku str Sent by terminal up arrow key
74l0-l9 str Labels on ``other'' function keys
75li num Number of lines on screen or page
76ll str Last line, first column (if no \fBcm\fR)
77mi bool Safe to move while in insert mode
78nc bool No correctly working carriage return (DM2500,H2000)
79nd str Non-destructive space (cursor right)
80nl str (P*) Newline character (default \fB\en\fR)
81ns bool Terminal is a \s-2CRT\s+2 but doesn't scroll.
82os bool Terminal overstrikes
83pc str Pad character (rather than null)
84pt bool Has hardware tabs (may need to be set with \fBis\fR)
85se str End stand out mode
86sf str (P) Scroll forwards
87so str Begin stand out mode
88sr str (P) Scroll reverse (backwards)
89ta str (P) Tab (other than \fB^I\fR or with padding)
90tc str Entry of similar terminal - must be last
91ti str String to begin programs that use \fBcm\fR
92te str String to end programs that use \fBcm\fP
93uc str Underscore one char and move past it
94ue str End underscore mode
95ul bool Terminal underlines even though it doesn't overstrike
96up str Upline (cursor up)
97us str Start underscore mode
98vb str Visible bell (may not move cursor)
99ve str Sequence to end open/visual mode
100vs str Sequence to start open/visual mode
101xn str A newline is ignored after a wrap (Concept)
102xt bool Tabs are destructive (Teleray 1061)
103.fi
104.PP
105The following entry, which describes the Concept\-100, is among the more
106complex entries in the
107.I termcap
108file as of this writing.
109(Note that this particular concept entry is outdated,
110and is used as an example only.)
111.PP
112.nf
113c1|c100|concept100:is=\eEU\eEf\eE7\eE5\eE8\eEl\eENH\eEK\eE\e200\eEo&\e200:\e
114 :al=3*\eE^R:am:bs:cd=16*\eE^C:ce=16\eE^S:cl=2*^L:cm=\eEa%+ %+ :co#80:\e
115 :dc=16\eE^A:dl=3*\eE^B:ei=\eE\e200:eo:im=\eE^P:in:ip=16*:li#24:mi:nd=\eE=:\e
116 :se=\eEd\eEe:so=\eED\eEE:ta=8\et:ul:up=\eE;:vb=\eEk\eEK:xn:
117.fi
118.PP
119Note that entries may continue onto multiple lines by giving a \e as the last
120character of a line, and that empty fields
121may be included for readability (here between the last field on a line
122and the first field on the next).
123Capabilities in
124.I termcap
125are of three types:
126Boolean capabilities which indicate that the terminal has
127some particular feature, numeric capabilities giving the size of the terminal
128or the size of particular delays, and string
129capabilities, which give a sequence which can be used to perform particular
130terminal operations.
131.PP
132All capabilities have two letter codes. For instance, the fact that
133the Concept has ``automatic margins'' (i.e. an automatic return and linefeed
134when the end of a line is reached) is indicated by the capability \fBam\fR.
135Hence the description of the Concept includes \fBam\fR.
136Numeric capabilities are followed by the character `#' and then the value.
137Thus \fBco\fR which indicates the number of columns the terminal has
138gives the value `80' for the Concept.
139.PP
140Finally, string valued capabilities, such as \fBce\fR (clear to end of line
141sequence) are given by the two character code, an `=', and then a string
142ending at the next following `:'. A delay in milliseconds may appear after
143the `=' in such a capability, and padding characters are supplied by the
144editor after the remainder of the string is sent to provide this delay.
145The delay can be either a integer, e.g. `20', or an integer followed by
146an `*', i.e. `3*'. A `*' indicates that the padding required is proportional
147to the number of lines affected by the operation, and the amount given is
148the per-affected-unit padding required.
149When a `*' is specified, it is sometimes useful to give a delay of the form
150`3.5' specify a delay per unit to tenths of milliseconds.
151.PP
152A number of escape sequences are provided in the string valued capabilities
153for easy encoding of characters there. A \fB\eE\fR maps to an \s-2ESCAPE\s0
154character, \fB^x\fR maps to a control-x for any appropriate x, and the sequences
155\fB\en \er \et \eb \ef\fR give a newline, return, tab, backspace and formfeed.
156Finally, characters may be given as three octal digits after a \fB\e\fR,
157and the characters \fB^\fR and \fB\e\fR may be given as \fB\e^\fR and \fB\e\e\fR.
158If it is necessary to place a \fB:\fR in a capability it must be escaped in
159octal as \fB\e072\fR.
160If it is necessary to place a null character in a string capability it
161must be encoded as \fB\e200\fR. The routines which deal with
162.I termcap
163use C strings, and strip the high bits of the output very late so that
164a \fB\e200\fR comes out as a \fB\e000\fR would.
165.PP
166We now outline how to prepare descriptions of terminals.
167The most effective way to prepare a terminal description is by imitating
168the description of a similar terminal in
169.I termcap
170and to build up a description gradually, using partial descriptions
171with
172.I ex
173to check that they are correct.
174Be aware that a very unusual terminal may expose deficiencies in
175the ability of the
176.I termcap
177file to describe it
178or bugs in
179.I ex.
180To easily test a new terminal description you can set the environment variable
181TERMCAP to a pathname of a file containing the description you are working
182on and the editor will look there rather than in
183.I /etc/termcap.
184TERMCAP can also be set to the termcap entry itself
185to avoid reading the file when starting up the editor.
186(This only works on version 7 systems.)
187.PP
188.B Basic capabilities
189.PP
190The number of columns on each line for the terminal is given by the
191\fBco\fR numeric capability. If the terminal is a \s-2CRT\s0, then the
192number of lines on the screen is given by the \fBli\fR capability.
193If the terminal wraps around to the beginning of the next line when
194it reaches the right margin, then it should have the \fBam\fR capability.
195If the terminal can clear its screen, then this is given by the
196\fBcl\fR string capability. If the terminal can backspace, then it
197should have the \fBbs\fR capability, unless a backspace is accomplished
198by a character other than \fB^H\fR (ugh) in which case you should give
199this character as the \fBbc\fR string capability. If it overstrikes
200(rather than clearing a position when a character is struck over)
201then it should have the \fBos\fR capability.
202.PP
203A very important point here is that the local cursor motions encoded
204in
205.I termcap
206are undefined at the left and top edges of a \s-2CRT\s0 terminal.
207The editor will never attempt to backspace around the left edge, nor
208will it attempt to go up locally off the top. The editor assumes that
209feeding off the bottom of the screen will cause the screen to scroll up,
210and the \fBam\fR capability tells whether the cursor sticks at the right
211edge of the screen. If the terminal has switch selectable automatic margins,
212the
213.I termcap
214file usually assumes that this is on, i.e. \fBam\fR.
215.PP
216These capabilities suffice to describe hardcopy and ``glass-tty'' terminals.
217Thus the model 33 teletype is described as
218.PP
219.DT
220 t3|33|tty33:co#72:os
221.PP
222while the Lear Siegler \s-2ADM\-3\s0 is described as
223.PP
224.DT
225 cl|adm3|3|lsi adm3:am:bs:cl=^Z:li#24:co#80
226.PP
227.B Cursor addressing
228.PP
229Cursor addressing in the terminal is described by a
230\fBcm\fR string capability, with
231.IR printf (3s)
232like escapes \fB%x\fR in it.
233These substitute to encodings of the current line or column position,
234while other characters are passed through unchanged.
235If the \fBcm\fR string is thought of as being a function, then its
236arguments are the line and then the column to which motion is desired,
237and the \fB%\fR encodings have the following meanings:
238.PP
239.DT
240.nf
241 %d as in \fIprintf\fR, 0 origin
242 %2 like %2d
243 %3 like %3d
244 %. like %c
245 %+x adds \fIx\fR to value, then %.
246 %<xy if value < x adds y; then in any case %.
247 %r reverses order of line and column, no output
248 %i increments line/column (for 1 origin)
249 %% gives a single %
250 %n exclusive or row and column with 0140 (DM2500)
251.fi
252.PP
253Consider the HP2645, which, to get to row 3 and column 12, needs
254to be sent \eE&a12c03Y padded for 6 milliseconds. Note that the order
255of the rows and columns is inverted here, and that the row and column
256are printed as two digits. Thus its \fBcm\fR capability is ``cm=6\eE&%r%2c%2Y''.
257The Microterm \s-2ACT-IV\s0 needs the current row and column sent
258preceded by a \fB^T\fR, with the row and column simply encoded in binary,
259``cm=^T%.%.''. Terminals which use ``%.'' need to be able to
260backspace the cursor (\fBbs\fR or \fBbc\fR),
261and to move the cursor up one line on the screen (\fBup\fR introduced below).
262This is necessary because it is not always safe to transmit \fB\et\fR, \fB\en\fR
263\fB^D\fR and \fB\er\fR, as the system may change or discard them.
264.PP
265A final example is the \s-2LSI ADM-3a\s0, which uses row and column
266offset by a blank character, thus ``cm=\eE=%+ %+ ''.
267.PP
268.B Cursor motions
269.PP
270If the terminal can move the cursor one position to the right, leaving
271the character at the current position unchanged, then this sequence should
272be given as \fBnd\fR (non-destructive space). If it can move the cursor
273up a line
274on the screen in the same column, this should be given as \fBup\fR.
275If the terminal has no cursor addressing capability, but can home the cursor
276(to very upper left corner of screen) then this can be given as
277\fBho\fR; similarly a fast way of getting to the lower left hand corner
278can be given as \fBll\fR; this may involve going up with \fBup\fR
279from the home position,
280but the editor will never do this itself (unless \fBll\fR does) because it
281makes no assumption about the effect of moving up from the home position.
282.PP
283.B Area clears
284.PP
285If the terminal can clear from the current position to the end of the
286line, leaving the cursor where it is, this should be given as \fBce\fR.
287If the terminal can clear from the current position to the end of the
288display, then this should be given as \fBcd\fR.
289The editor only uses
290\fBcd\fR from the first column of a line.
291.PP
292.B Insert/delete line
293.PP
294If the terminal can open a new blank line before the line where the cursor
295is, this should be given as \fBal\fR; this is done only from the first
296position of a line. The cursor must then appear on the newly blank line.
297If the terminal can delete the line which the cursor is on, then this
298should be given as \fBdl\fR; this is done only from the first position on
299the line to be deleted.
300If the terminal can scroll the screen backwards, then this can be given as
301\fBsb\fR, but just \fBal\fR suffices.
302If the terminal can retain display memory above then the
303\fBda\fR capability should be given; if display memory can be retained
304below then \fBdb\fR should be given. These let the editor understand
305that deleting a line on the screen may bring non-blank lines up from below
306or that scrolling back with \fBsb\fR may bring down non-blank lines.
307.PP
308.B Insert/delete character
309.PP
310There are two basic kinds of intelligent terminals with respect to
311insert/delete character which can be described using
312.I termcap.
313The most common insert/delete character operations affect only the characters
314on the current line and shift characters off the end of the line rigidly.
315Other terminals, such as the Concept 100 and the Perkin Elmer Owl, make
316a distinction between typed and untyped blanks on the screen, shifting
317upon an insert or delete only to an untyped blank on the screen which is
318either eliminated, or expanded to two untyped blanks. You can find out
319which kind of terminal you have by clearing the screen and then typing
320text separated by cursor motions. Type ``abc\ \ \ \ def'' using local
321cursor motions (not spaces) between the ``abc'' and the ``def''.
322Then position the cursor before the ``abc'' and put the terminal in insert
323mode. If typing characters causes the rest of the line to shift
324rigidly and characters to fall off the end, then your terminal does
325not distinguish between blanks and untyped positions. If the ``abc''
326shifts over to the ``def'' which then move together around the end of the
327current line and onto the next as you insert, you have the second type of
328terminal, and should give the capability \fBin\fR, which stands for
329``insert null''. If your terminal does something different and unusual
330then you may have to modify the editor to get it to use the insert
331mode your terminal defines. We have seen no terminals which have an insert
332mode not not falling into one of these two classes.
333.PP
334The editor can handle both terminals which have an insert mode, and terminals
335which send a simple sequence to open a blank position on the current line.
336Give as \fBim\fR the sequence to get into insert mode, or give it an
337empty value if your terminal uses a sequence to insert a blank position.
338Give as \fBei\fR the sequence to leave insert mode (give this, with
339an empty value also if you gave \fBim\fR so).
340Now give as \fBic\fR any sequence needed to be sent just before sending
341the character to be inserted. Most terminals with a true insert mode
342will not give \fBic\fR, terminals which send a sequence to open a screen
343position should give it here. (Insert mode is preferable to the sequence
344to open a position on the screen if your terminal has both.)
345If post insert padding is needed, give this as a number of milliseconds
346in \fBip\fR (a string option). Any other sequence which may need to be
347sent after an insert of a single character may also be given in \fBip\fR.
348.PP
349It is occasionally necessary to move around while in insert mode
350to delete characters on the same line (e.g. if there is a tab after
351the insertion position). If your terminal allows motion while in
352insert mode you can give the capability \fBmi\fR to speed up inserting
353in this case. Omitting \fBmi\fR will affect only speed. Some terminals
354(notably Datamedia's) must not have \fBmi\fR because of the way their
355insert mode works.
356.PP
357Finally, you can specify delete mode by giving \fBdm\fR and \fBed\fR
358to enter and exit delete mode, and \fBdc\fR to delete a single character
359while in delete mode.
360.PP
361.B "Highlighting, underlining, and visible bells"
362.PP
363If your terminal has sequences to enter and exit standout mode these
364can be given as \fBso\fR and \fBse\fR respectively.
365If there are several flavors of standout mode
366(such as inverse video, blinking, or underlining -
367half bright is not considered ``standout'')
368the prefered mode is inverse video by itself.
369It doesn't matter if the code to change into or out of standout
370mode leaves one or even two blank spaces on the screen,
371as the TVI 912 and Teleray 1061 do.
372.PP
373Codes to begin underlining and end underlining can be given as \fBus\fR
374and \fBue\fR respectively.
375If the terminal has a code to underline the current character and move
376the cursor one space to the right,
377such as the Microterm Mime,
378this can be given as \fBuc\fR.
379(If the underline code does not move the cursor to the right,
380give the code followed by a nondestructive space.)
381.PP
382If the terminal has
383a way of flashing the screen to indicate an error quietly (a bell replacement)
384then this can be given as \fBvb\fR; it must not move the cursor.
385If the terminal should be placed in a different mode during
386open and visual modes of
387.I ex,
388this can be given as
389\fBvs\fR and \fBve\fR, sent at the start and end of these modes
390respectively. These can be used to change, e.g., from a underline
391to a block cursor and back.
392.PP
393If the terminal needs to be in a special mode when running
394a program that addresses the cursor,
395the codes to enter and exit this mode can be given as \fBti\fR and \fBte\fR.
396This arises, for example, from terminals like the Concept with more than
397one page of memory.
398If the terminal has only memory relative cursor addressing and not screen
399relative cursor addressing, a one screen-sized window must be fixed into
400the terminal for cursor addressing to work properly.
401.PP
402If your terminal correctly generated underlined characters
403(with no special codes needed)
404enen though it does not overstrike,
405then you should give the capability \fBul\fR.
406If overstrikes are erasable with a blank,
407then this should be indicated by giving \fBeo\fR.
408.PP
409.B Keypad
410.PP
411If the terminal has a keypad that transmits codes when the keys are pressed,
412this information can be given. Note that it is not possible to handle
413terminals where the keypad only works in local (this applies, for example,
414to the unshifted HP 2621 keys).
415If the keypad can be set to transmit or not transmit,
416give these codes as \fBks\fR and \fBke\fR.
417Otherwise the keypad is assumed to always transmit.
418The codes sent by the left arrow, right arrow, up arrow, down arrow,
419and home keys can be given as \fBkl, kr, ku, kd, \fRand\fB kh\fR respectively.
420If there are function keys such as f0, f1, ..., f9, the codes they send
421can be given as \fBk0, k1, ..., k9\fR.
422If these keys have labels other than the default f0 through f9, the labels
423can be given as \fBl0, l1, ..., l9\fR.
424If there are other keys that transmit the same code as the terminal expects
425for the corresponding function, such as clear screen, the \fItermcap\fP
4262 letter codes can be given in the \fBko\fR capability,
427for example, ``:ko=cl,ll,sf,sb:'', which says that the terminal has
428clear, home down, scroll down, and scroll up keys that transmit
429the same thing as the cl, ll, sf, and sb entries.
430.PP
431.B Miscellaneous
432.PP
433If the terminal requires other than a null (zero) character as a pad,
434then this can be given as \fBpc\fR.
435.PP
436If tabs on the terminal require padding, or if the terminal uses a
437character other than \fB^I\fR to tab, then this can be given as \fBta\fR.
438.PP
439Hazeltine terminals, which don't allow `~' characters to be printed should
440indicate \fBhz\fR.
441Datamedia terminals, which echo carriage-return linefeed for carriage return
442and then ignore a following linefeed should indicate \fBnc\fR.
443Early Concept terminals, which ignore a linefeed immediately after an \fBam\fR
444wrap, should indicate \fBxn\fR.
445Teleray terminals, where tabs turn all characters moved over to blanks,
446should indicate \fBxt\fR.
447Other specific terminal problems may be corrected by adding more
448capabilities of the form \fBx\fIx\fR.
449.PP
450Other capabilities
451include \fBis\fR, an initialization string for the terminal,
452and \fBif\fR, the name of a file containing long initialization strings.
453These strings are expected to properly clear and then set the tabs
454on the terminal, if the terminal has settable tabs.
455If both are given, \fBis\fR will be printed before \fBif\fR.
456This is useful where \fBif\fR is /usr/lib/tabset/std but \fBis\fR
457clears the tabs first.
458.PP
459If there are two very similar terminals,
460one can be defined as being just like the other with certain exceptions.
461The string capability \fBtc\fR can be given
462with the name of the similar terminal.
463This capability must be \fIlast\fP and the combined length of the two entries
464must not exceed 1024. Since
465.I termlib
466routines search the entry from left to right, and since the tc capability is
467replaced by the corresponding entry, the capabilities given at the left
468override the ones in the similar terminal.
469A capability can be cancelled with \fBxx@\fR where xx is the capibility.
470For example, the entry
471.br
472 hn|2621nl:ks@:ke@:tc=2621:
473.br
474defines a 2621nl that does not have the \fBks\fR or \fBke\fR capabilities,
475and hence does not turn on the function key labels when in visual mode.
476This is useful for different modes for a terminal, or for different
477user preferences.
478.SH FILES
479.DT
480/etc/termcap file containing terminal descriptions
481.SH SEE ALSO
482ex(1), termlib(3), tset(1), vi(1), ul(1), more(1)
483.SH AUTHOR
484William Joy
485.br
486Mark Horton added underlining and keypad support
487.SH BUGS
488.I Ex
489allows only 256 characters for string capabilities, and the routines
490in
491.I termlib
492do not check for overflow of this buffer.
493The total length of a single entry (excluding only escaped newlines)
494may not exceed 1024.