Documented via
% man 5 termcap
Actually, termcap is documented in termcap(5), but it's so useful that
it's included as an example here.
See also setenv and eval.
The following line is placed in the .login file of user 'kemp':
setenv TERMCAP ~kemp/terms/termcap
At login time, instead of specifying a terminal type from one of those
found in /etc/termcap (the system terminal capability file), user kemp
will have to specify a terminal type from one of those found in the file
named ~kemp/terms/termcap. This is how to develop and debug termcap
definitions.
From James Frew, Computer Systems Laboratory, ucbvax!ucsbcsl!frew:
[Below is] the skeleton file I use to construct new termcap
entries on our 4.2BSD system. It is based partly on termcap(5), partly
on rooting around in the innards of some of the more prominent
termcap-using programs, and partly on hard knocks.
When I finished this I was surprised at the number of undocumented
capabilities that are used by existing software (e.g., AL and DL
really speed up vi on ANSI terminals).
For those of you who are new to termcap, I recommend the series of
articles by Bill Tuthill in UNIX/WORLD, beginning with the
January/February 1984 issue.
Termcap codes:
XX|visible name|aliases|full name
used by "vi"
AL= P* add N new blank lines (same syntax as "cm")
al= P* add new blank line (pad if using "sr")
am has automatic margins
bc= backspace (specify ONLY if not CTRL-H)
bs can backspace with CTRL-H
bt= P back tab
cd= P* clear to end of display
ce= P clear to end of line
cl= P* clear entire screen, leave cursor at home position
cm= P cursor motion
co# number of columns in a line
cr= P* carriage return (specify ONLY if not CTRL-M)
cs= P change scrolling region (e.g., vt100) (same syntax as "cm")
da display may be retained above
db display may be retained below
dc= P* delete character
DL= P* delete N lines (same syntax as "cm")
dl= P* delete line
dm= delete mode begin
DO= down N lines (same syntax as "cm")
do= down line
ed= end delete mode
ei= end insert mode (specify ":ei=:" if using "ic")
eo can erase overstrikes with a blank
hc hard copy terminal
ho= home cursor
hz Hazeltine: can't print ~'s
ic= P insert character
(NOTE: if both "ic" and "im","ei" are available,
specify "im","ei" and DON'T specify "ic")
im= insert mode (specify ":im=:" if using "ic")
in insert mode distinguishes nulls on display
ip= P* insert pad after character inserted using "im" + "ei"
k0= sent by function key 0
k1= sent by function key 1
k2= sent by function key 2
k3= sent by function key 3
k4= sent by function key 4
k5= sent by function key 5
k6= sent by function key 6
k7= sent by function key 7
k8= sent by function key 8
k9= sent by function key 9
kd= sent by keypad down arrow
ke= end keypad transmit mode
(NOTE: see "ks" below)
kh= sent by keypad home key
kl= sent by keypad left arrow
kr= sent by keypad right arrow
ks= start keypad transmit mode
(NOTE: DON'T specify "ks" and "ke" unless you want them
to be used by vi)
ku= keypad up arrow
LE= left N chars (same syntax as "cm")
li# number of lines on screen or page
ll= quick to last line, first column
mi safe to move while in insert mode
nc no cr: \r sends \r\n then eats \n (e.g., dm2500)
nd= non-destructive space
nl= newline (line feed) (specify ONLY if not CTRL-J)
ns terminal is a CRT but doesn't scroll
os terminal overstrikes
pc= pad character (specify ONLY if not '\0')
RI= right N spaces (same syntax as "cm")
rc= restore cursor from last "sc"
sc= save cursor
se= stand-out mode end (may leave space)
sf= P scroll forwards
so= stand-out mode begin (may leave space)
sr= P scroll reverse (backwards)
ta= P tab (specify ONLY if padded or not ^I)
te= terminal end sequence
ti= terminal initial sequence
UP= up N lines (same syntax as "cm")
ul terminal underlines even though it doesn't overstrike
up= upline (cursor up)
vb= visible bell (may not move cursor)
ve= visual mode end sequence
vs= visual mode start sequence
xb Beehive glitch: no escape key, simulate with f1
xn newline glitch: \n gets eaten after wrap (e.g., concept)
xt tab glitch: tabs are destructive
xx Tektronix glitch: special insert line
additional codes used by tset;
EP even parity
HD half duplex
LC lower case only
NL \n doesn't do a line feed
OP odd parity
UC upper case only
ch= P cursor horizontal move (same syntax as "cm")
ct= clear tabs
if= name of file containing "is"
is= terminal initialization string
kb= sent by backspace key
pb# pad baud (min baud rate at which padding is required)
pt has hardware tabs (may need to be set with "is")
rf= name of file containing "rs"
rs= terminal reset string (used instead of "is" by reset)
st= set tab at current cursor position
vt# virtual terminal number (UCB-specific)
additional codes used by "sysline"
ds= disable status line
es OK to use escape codes on status line ("se", "so", "cm", etc.)
fs= return from status line
hs has status line
i2= supplemental initialization string (like "is")
ts= go to status line
additional codes used by more
uc= underscore one character and move past it
ue= underscore mode end
us= underscore mode start
xs stand-out not erased by writing over it (e.g., HP264x)
additional codes used by "ul"
le= cursor left (default: "bc" or \b)
md= set mode to double intensity
me= restore "m?" modes to normal
mh= set mode to half-intensity
mr= set mode to reverse video
ri= cursor right (default: "nd")
additional codes documented but not used by any of the above
ae= P end alternate character set
as= P start alternate character set
bw backspace wraps from column 0 to last column
cv= P cursor vertical move (same syntax as "cm")
dB# number of millisec of "bs" delay needed
dC# number of millisec of "cr" delay needed
dF# number of millisec of "ff" delay needed
dN# number of millisec of "nl" delay needed
dT# number of millisec of "ta" delay needed
ff= P* hardcopy terminal page eject (specify ONLY if not CTRL-L)
hd= half-line down (forward 1/2 linefeed)
hu= half-line up (reverse 1/2 linefeed)
kn# number of function keys
ko= termcap entries for non-function keys
l0= label on function key 0, if not "f0"
l1= label on function key 1, if not "f1"
l2= label on function key 2, if not "f2"
l3= label on function key 3, if not "f3"
l4= label on function key 4, if not "f4"
l5= label on function key 5, if not "f5"
l6= label on function key 6, if not "f6"
l7= label on function key 7, if not "f7"
l8= label on function key 8, if not "f8"
l9= label on function key 9, if not "f9"
ma= arrow key map (vi version 2 only)
ml= memory lock on insert mode cursor
ms safe to move while in standout and underline mode
mu= memory unlock (inverse of "ml")
sg# number of blank characters left by "so" or "se"
ug# number of blank characters left by "us" or "ue"
xr \r acts like "ce"\r\n (e.g., Delta Data)
termcap versus terminfo conventions (source unknown):
terminfo termcap Description
......... ..... .............................
parm_insert_line, "il" "AL" Add #1 new blank lines (G*)
command_character, "cmdch" "CC" Term. settable cmd char in prototype
cursor_mem_address, "mrcup" "CM" Memory relative cursor addressing.
parm_dch, "dch" "DC" Delete #1 chars (G*)
parm_delete_line, "dl" "DL" Delete #1 lines (G*)
parm_down_cursor, "cud" "DO" Move cursor down #1 lines. (G*)
parm_ich, "ich" "IC" Insert #1 blank chars (G*)
key_a1, "ka1" "K1" Upper left of keypad
key_b2, "kb2" "K2" Center of keypad
key_a3, "ka3" "K3" Upper right of keypad
key_c1, "kc1" "K4" Lower left of keypad
key_c3, "kc3" "K5" Lower right of keypad
parm_left_cursor, "cub" "LE" Move cursor left #1 spaces (G)
num_labels, "nlab" "Nl" # of labels on screen (start at 1)
parm_right_cursor, "cuf" "RI" Move cursor right #1 spaces. (G*)
parm_index, "indn" "SF" Scroll forward #1 lines. (G)
parm_rindex, "rin" "SR" Scroll backward #1 lines. (G)
parm_up_cursor, "cuu" "UP" Move cursor up #1 lines. (G*)
acs_chars, "acsc" "ac" Graphics char
set pairs aAbBcC - defn =vt100.
exit_alt_charset_mode, "rmacs" "ae" End alternate character set
insert_line, "il1" "al" Add new blank line (*)
auto_right_margin, "am" "am" Terminal has automatic margins
enter_alt_charset_mode, "smacs" "as" Start alternate character set
bell, "bel" "bl" Audible signal (bell)
back_tab, "cbt" "bt" Back tab
auto_left_margin, "bw" "bw" cub1 wraps from col. 0 to last col.
clr_eos, "ed" "cd" Clear to end of display (*)
clr_eol, "el" "ce" Clear to end of line
column_address, "hpa" "ch" Set cursor column (G)
clear_screen, "clear" "cl" Clear screen (*)
cursor_address, "cup" "cm" Cursor motion to row #1 col #2 (G)
columns, "cols" "co" Number of columns in a line
carriage_return, "cr" "cr" Carriage return (*)
change_scroll_region, "csr" "cs" change to ln #1 thru #2 (vt100) (G)
clear_all_tabs, "tbc" "ct" Clear all tab stops.
row_address, "vpa" "cv" Like hpa but sets row. (G)
memory_above, "da" "da" Display may be retained above scr n
memory_below, "db" "db" Display may be retained below scr n
delete_character, "dch1" "dc" Delete character (*)
delete_line, "dl1" "dl" Delete line (*)
enter_delete_mode, "smdc" "dm" Delete mode (enter)
cursor_down, "cud1" "do" Down one line
dis_status_line, "dsl" "ds" Disable status line
erase_chars, "ech" "ec" Erase #1 characters (G)
exit_delete_mode, "rmdc" "ed" End delete mode
exit_insert_mode, "rmir" "ei" End insert mode;
erase_overstrike, "eo" "eo" Can erase overstrikes with a blank
status_line_esc_ok, "eslok" "es" Escape can be used on the status line
form_feed, "ff" "ff" Hardcopy terminal page eject (*)
from_status_line, "fsl" "fs" Return from status line
generic_type, "gn" "gn" Generic line type (eg dialup, switch)
down_half_line, "hd" "hd" Half-line down (forward 1/2 linefeed)
cursor_home, "home" "ho" Home cursor (if no cup)
has_status_line, "hs" "hs" Has extra "status line"
up_half_line, "hu" "hu" Half-line up (reverse 1/2 linefeed)
tilde_glitch, "hz" "hz" Hazeltine; can't print ~'s
init_1string, "is1" "i1" Terminal initialization string
init_3string, "is3" "i2" Terminal initialization string
init_prog, "iprog" "iP" Path name of program for init.
insert_character, "ich1" "ic" Insert character
init_file, "if" "if" Name of file containing is
enter_insert_mode, "smir" "im" Insert mode (enter);
insert_null_glitch, "in" "in" Insert mode distinguishes nulls
insert_padding, "ip" "ip" Insert pad after char inserted (*)
init_2string, "is2" "is" Terminal initialization string
init_tabs, "it" "it" Tabs initially every # spaces.
key_f0, "kf0" "k0" Sent by function key f0.
key_f1, "kf1" "k1" Sent by function key f1.
key_f2, "kf2" "k2" Sent by function key f2.
key_f3, "kf3" "k3" Sent by function key f3.
key_f4, "kf4" "k4" Sent by function key f4.
key_f5, "kf5" "k5" Sent by function key f5.
key_f6, "kf6" "k6" Sent by function key f6.
key_f7, "kf7" "k7" Sent by function key f7.
key_f8, "kf8" "k8" Sent by function key f8.
key_f9, "kf9" "k9" Sent by function key f9.
key_f10, "kf10" "k;" Sent by function key f10.
key_il, "kil1" "kA" Sent by insert line.
key_clear, "kclr" "kC" Sent by clear screen or erase key.
key_dc, "kdch1" "kD" Sent by delete character key.
key_eol, "kel" "kE" Sent by clear-to-end-of-line key.
key_sf, "kind" "kF" Sent by scroll-forward/down key
key_ll, "kll" "kH" Sent by home-down key
key_ic, "kich1" "kI" Sent by ins char/enter ins mode key.
key_dl, "kdl1" "kL" Sent by delete line key.
key_eic, "krmir" "kM" Sent by rmir or smir in insert mode.
key_npage, "knp" "kN" Sent by next-page key
key_ppage, "kpp" "kP" Sent by previous-page key
key_sr, "kri" "kR" Sent by scroll-backward/up key
key_eos, "ked" "kS" Sent by clear-to-end-of-screen key.
key_stab, "khts" "kT" Sent by set-tab key
key_catab, "ktbc" "ka" Sent by clear-all-tabs key.
key_backspace, "kbs" "kb" Sent by backspace key
key_down, "kcud1" "kd" Sent by terminal down arrow key
keypad_local, "rmkx" "ke" Out of "keypad transmit" mode
key_home, "khome" "kh" Sent by home key.
key_left, "kcub1" "kl" Sent by terminal left arrow key
has_meta_key, "km" "km" Has meta key (shift, sets parity bit)
key_right, "kcuf1" "kr" Sent by terminal right arrow key
keypad_xmit, "smkx" "ks" Set terminal "keypad transmit" mode
key_ctab, "kctab" "kt" Sent by clear-tab key
key_up, "kcuu1" "ku" Sent by terminal up arrow key
lab_f0, "lf0" "l0" Labels on function key f0 if not f0
lab_f1, "lf1" "l1" Labels on function key f1 if not f1
lab_f2, "lf2" "l2" Labels on function key f2 if not f2
lab_f3, "lf3" "l3" Labels on function key f3 if not f3
lab_f4, "lf4" "l4" Labels on function key f4 if not f4
lab_f5, "lf5" "l5" Labels on function key f5 if not f5
lab_f6, "lf6" "l6" Labels on function key f6 if not f6
lab_f7, "lf7" "l7" Labels on function key f7 if not f7
lab_f8, "lf8" "l8" Labels on function key f8 if not f8
lab_f9, "lf9" "l9" Labels on function key f9 if not f9
lab_f10, "lf10" "la" Labels on function key f10 if not f10
cursor_left, "cub1" "le" Move cursor left one space.
label_height, "lh" "lh" # rows in each label
lines, "lines" "li" Number of lines on screen or page
cursor_to_ll, "ll" "ll" Last line, first column (if no cup)
lines_of_memory, "lm" "lm" Lines of mem. if > lines. 0 => varies
label_width, "lw" "lw" # cols in each label
enter_blink_mode, "blink" "mb" Turn on blinking
enter_bold_mode, "bold" "md" Turn on bold (extra bright) mode
exit_attribute_mode, "sgr0" "me" Turn off all attributes
enter_dim_mode, "dim" "mh" Turn on half-bright mode
move_insert_mode, "mir" "mi" Safe to move while in insert mode
enter_secure_mode, "invis" "mk" Turn on blank mode (chars invisible)
meta_on, "smm" "mm" Turn on "meta mode" (8th bit)
meta_off, "rmm" "mo" Turn off "meta mode"
enter_protected_mode, "prot" "mp" Turn on protected mode
enter_reverse_mode, "rev" "mr" Turn on reverse video mode
move_standout_mode, "msgr" "ms" Safe to move in standout modes
cursor_right, "cuf1" "nd" Non-destructive space (cursor right)
newline, "nel" "nw" Newline (behaves like cr lf)
over_strike, "os" "os" Terminal overstrikes
prtr_non, "mc5p" "pO" Turn on the printer for #1 bytes.
padding_baud_rate, "pb" "pb" Lowest baud rate where padding needed
pad_char, "pad" "pc" Pad character (rather than null)
prtr_off, "mc4" "pf" Turn off the printer
pkey_key, "pfkey" "pk" Prog funct key #1 to type string #2
pkey_local, "pfloc" "pl" Prog funct key #1 to exec. string #2
plab_norm, "pln" "pn" Prog label #1 to show string #2
prtr_on, "mc5" "po" Turn on the printer
print_screen, "mc0" "ps" Print contents of the screen
pkey_xmit, "pfx" "px" Prog funct key #1 to xmit string #2
reset_1string, "rs1" "r1" Reset terminal completely
reset_2string, "rs2" "r2" Reset terminal completely
reset_3string, "rs3" "r3" Reset terminal completely
char_padding, "rmp" "rP" Like ip but when in replace mode
restore_cursor, "rc" "rc" Restore cursor to posit. of last sc.
reset_file, "rf" "rf" Name of file containing reset string.
repeat_char, "rep" "rp" Repeat char #1 #2 times. (G*)
set_attributes, "sgr" "sa" Define the video attributes (G9)
save_cursor, "sc" "sc" Save cursor position.
exit_standout_mode, "rmso" "se" End stand out mode
scroll_forward, "ind" "sf" Scroll text up
magic_cookie_glitch, "xmc" "sg" Num. blank chars left by smso or rmso
enter_standout_mode, "smso" "so" Begin stand out mode
scroll_reverse, "ri" "sr" Scroll text down
set_tab, "hts" "st" Set a tab in all rows, current col.
tab, "ht" "ta" Tab to next 8 space hardware tab stop
exit_ca_mode, "rmcup" "te" String to end programs that use cup
enter_ca_mode, "smcup" "ti" String to begin programs that use cup
to_status_line, "tsl" "ts" Go to status line
underline_char, "uc" "uc" Underscore one char and move past it
exit_underline_mode, "rmul" "ue" End underscore mode
transparent_underline, "ul" "ul" underline character overstrikes
cursor_up, "cuu1" "up" Upline (cursor up)
enter_underline_mode, "smul" "us" Start underscore mode
flash_screen, "flash" "vb" Visible bell (may not move cursor)
cursor_normal, "cnorm" "ve" Make cursor look normal (undo vs/vi)
cursor_invisible, "civis" "vi" Make cursor invisible
cursor_visible, "cvvis" "vs" Make cursor very visible
virtual_terminal, "vt" "vt" Virtual terminal number (CB/Unix)
set_window, "wind" "wi" Current window lines #1-#2 cols #3-#4
width_status_line, "wsl" "ws" # columns in status line
beehive_glitch, "xsb" "xb" Beehive (f1=escape, f2=ctrl C)
eat_newline_glitch, "xenl" "xn" ignore newline after 80 cols (Concept)
xon_xoff, "xon" "xo" Terminal uses xon/xoff handshaking
ceol_standout_glitch, "xhp" "xs" Standout not to erase overwriting (hp)
tteleray_glitch, "xt" "xt" Tabs destructive, magic so char(t1061)
# From gwyn@brl-vgr.ARPA (Doug Gwyn )
# Organization: Ballistics Research Lab
# Here is a cute trick for people who are writing termcap-driven programs;
# include the following dummy terminal type in /etc/termcap and set
# TERM=debug to see what your program is actually doing:
#
# Debugging entry -- all printing characters
sD|debug|debugging entry:\
:ae=:AL=:al=:am:as=:bc=:bt=:cd=:\
:ce=:ch=:cl=:cm=:co#80:cr=:cs=:\
:ct=:cv=:da:db:dc=:DL=:dl=:dm=:DO=:\
:do=:ed=:ei=:ff=:ho=:ic=:im=:ip=:\
:is=:k0=\E0:k1=\E1:kb=\Eb:kd=\Ed:ke=:kh=\Eh:kl=\El:kn=2:\
:ko=cl,ho,ll:kr=\Er:ks=:ku=\Eu:l0=ESC0:l1=ESC1:LE=:li#24:\
:ll=:mb=:md=:me=:mi:ml=:mr=:ms=:mu=:\
:nd=:nl=:pb#19200:pc=:pt:rc=:RI=:rs=:\
:sc=:se=:sf=:so=:sr=:st=:ta=:te=:\
:ti=:uc=:ue=:UP=:up=:us=:vb=:ve=:\
:vs=:vt#3: