Inside the Termcap File
The termcap file contains separate entries for each type of terminal. In the example below, some lines begin with a "#". These lines are ignored by termcap and may be used for comments and special notes. Also, blank lines may be used to enhance readability. For the actual terminal entries, the first entry is for a terminal called "vt100-w." There is also a longer entry for a terminal called "ansiex". Typically, an entry cannot fit on a single line and a backslash "\" must be used at the end of each line, except the last. The continuation lines for the entry are indented for readability, though the indenting is not required. Comments and blank lines must not be embedded in a multi-line entry.
# entry for wide screen vt100
vt100-w:co#132:li#24:rs=\E>\E[?4l\E[?5l\E[?8h:tc=vt100-am:
# ansi-type terminal
ansiex:al=\E[L:am:bs:cd=\E[J:ce=\E[K:cl=\E[2J\E[H:\
:cm=\E[%i%d;%dH:co#80:li#25:ic=\E[@:im=:\
:dc=\E[P:dl=\E[M:bt=\E[Z:ei=:ho=\E[H:\
:ms:pt:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\
:kh=\E[H:kb=^h:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:eo:\
:up=\E[A:do=\E[B:nd=\E[C:bc=\E[D:
If there is more than one entry with the same name, then the first one encountered will be used.
Each entry in the termcap file is made up of several "fields." The fields in an entry are delimited by colons ":". The first field in each entry is the name of the entry. Several names may be given for an entry. The names are separated by a vertical bar "|". For example:
wyse60|wy60|Wyse 60 with 24 lines:am:li#24:cd=\EY:
The above entry has three names - "wyse60", "wy60", and "Wyse 60 with 24 lines." Any of these names may be used to reference this entry. However, the last name serves as a brief description and would never be used to reference the entry. Historically, the first name was limited to two characters. While this is no longer a requirement, some applications still expect the first name to be two characters. The examples here do not follow that convention.
Following the names in the above example are three fields:
:am:li#24:cd=\EY:
Notice that a colon follows the last field on each line.
NOTE: In a multi-line entry, each line should end with a ":" (not counting the "\") and each continuation line should begin with a ":". This is a safeguard to avoid unexpected interpretation of the actual wrap from one line to the next.
Each field describes some aspect of the terminal called a capability. There are three different kinds of fields in a termcap entry. Each type of field is represented in the above example.
Field |
Description |
:am: |
Boolean field. Think of a Boolean field as a flag that gets raised to indicate the presence (or absence) of a particular feature on a terminal. In this case, the presence of the :am: field means that the terminal has "automatic margins." |
:li#24: |
Numeric field. This is indicated by the "#." Numeric fields are used to describe quantities. This example indicates that the terminal can display 24 lines of text. |
:cd=\EY: |
String field (indicated by the "="). String fields are normally used to provide the necessary escape sequence to perform some function on the terminal. In this case, the "cd" stands for the "clear to end of display" function, and the "\EY" is the escape sequence the application program must send for that function to occur. |