NAME
termcap - 终端功能数据库
描述 DESCRIPTION
termcap 数据库是一个过时 (obsolete) 工具,用来描述以字符为单位的终端和打印机的功能。它之所以被保留,是为了兼容古老的程序;新程序应当使用 terminfo(5) 数据库和相关的库。
/etc/termcap 是一个 ASCII 文件 (数据库主控文件),列出了许多不同类型终端的功能。程序可以读取它,来找到控制实际使用的终端的可视化属性的特定的脱逸字符 (escape code)。(终端的其他方面是 stty 处理的。)termcap 数据库按照 TERM 环境变量进行索引。
Termcap 条目必须以单个逻辑行定义,在新行符处应当用 `\' 来续行。字段以 `:' 分隔。每个条目的***个字段从左边起始,包含一系列终端的名称,以 '|' 分隔。
***个子字段可能 (在 4.3 及以前的 BSD termcap 条目中) 包含由两个字符组成的简称。这个简称可以由大写或小写字母组成。在 4.4BSD termcap 条目中,这个字段被忽略。
第二个子字段 (在较新的 4.4BSD 格式中是***个字段) 包括环境变量 TERM 使用的名字。只能使用小写字母。可选的硬件功能应当通过附加一个连字符 (hyphen) 和后缀来标记。参见下面的范例。一般使用的后缀是 w (行宽超过 80 个字符),am (自动加边),nam (不自动加边),和 rv (反转视频显示)。
第三个子字段包含一个对这个 termcap 条目的长的描述性的名字。
接下来的字段包含终端功能。任何连续的功能行必须从左边缩进一个指标符 (tab) 位置。
尽管没有定义顺序,建议你将布尔值写在***,然后是数字值,***是字符串值;按照字母排序,没有大小写之分。类似功能可以写在同一行。
例如: Head line: vt|vt101|DEC VT 101 terminal in 80 character mode:\ Head line: Vt|vt101-w|DEC VT 101 terminal in (wide) 132 character mode:\ Boolean: :bs:\ Numeric: :co#80:\ String: :sr=\E[H:\
布尔值 Boolean Capabilities
5i 打印机不在屏幕上回显 am 自动加边,意味着自动卷行 bs Control-H (8 dec.) 执行一个退格 (backspace) bw 在行的左边退格回到上一行的右边 da 显示保留在屏幕上方 db 显示保留在屏幕下方 eo 一个空格删除光标所在位置的所有字符 es 工作在状态行的转义顺序 (escape sequence) 和特殊字符 gn 普通设备 hc 这是一个硬拷贝终端 HC 光标不在底线时几乎看不见 hs 有一个状态线 hz Hazeltine bug, 终端不能打印 ~ 符号 in 终端插入空字符,不是空格,来填充空白 km 终端有一个meta键 mi 光标移动是工作在插入模式下 ms 光标移动是工作在突出/下划线 (standout/underline) 模式 NP 无填充字符 NR ti 不能反转为 te nx 无填充,必须使用 XON/XOFF os 终端能重击 (将光标置于要改变的字符下面,再通过键盘输入一个字符来替换原来的字符。) ul 终端不能被重击,只能下划线 xb 蜂窝信号,f1 发射 ESCAPE, f2 发射 ^C xn 换行/返转信号 xo 终端使用xon/xoff协议 xs 打印的文字超过突出的文本,将显示在突出的位置 xt Teleray 信号,破坏tabs 和奇数化突出模式(standout mode)
数字值 Numeric Capabilities
co 列数 dB 硬拷贝终端上退格 (backspace) 延时,以毫秒为单位 dC 硬拷贝终端上回车 (carriage return) 延时,以毫秒为单位 dF 硬拷贝终端上打印纸进纸 (form feed) 延时,以毫秒为单位 dN 硬拷贝终端上新行符 (new line) 的延时,以毫秒为单位 dT 硬拷贝终端上制表符停止位 (tabulator stop) 的延时,以毫秒为单位 dV 硬拷贝终端上垂直制表符停止位的延时,以毫秒为单位 it tab 位置间的差分 lh 软标签高度 lm 内存线(Lines of memory) lw 软标签的宽度 li 行数 Nl 软标签的数目 pb 需要填充的***波特率 sg 突出信号 ug 下划线信号 vt 虚拟终端数目 ws 若状态线宽度与屏幕宽度不同时的大小
字符串值 String Capabilities
!1 转义为保存键 !2 转义为挂起键 !3 转义为撤消键 #1 转义为帮助键 #2 转义为 home 键 #3 转义为输入键 #4 转义为光标左移键 %0 重做 (redo) 键 %1 帮助键 %2 标记键 %3 信息 (message) 键 %4 转移键 %5 下一对象 (next-object) 键 %6 打开键 %7 选项键 %8 上一对象键 %9 打印键 %a 转义为信息 (message) 键 %b 转义为转移键 %c 转义为next键 %d 转义为options键 %e 转义为previous键 %f 转义为打印键 %g 转义为redo键 %h 转义为替换键 %i 转义为光标右移键 %j 转义为恢复键 &0 转义为取消键 &1 参考键 &2 刷新键 &3 替换键 &4 重新开始键 &5 恢复键 &6 保存键 &7 挂起键 &8 撤销键 &9 转义为开始键 *0 转义为查找键 *1 转义为命令键 *2 转义为拷贝键 *3 转义为创建键 *4 转义为删除字符 *5 转义为删除行 *6 选择键 *7 转义为结束键 *8 转义为清除行键 *9 转义为退出键 @0 查找键 @1 开始键 @2 取消键 @3 关闭键 @4 命令键 @5 拷贝键 @6 创建键 @7 结束键 @8 回车/发送键 @9 退出键 al 插入新行 AL 缩进 %1 行 ac 成对的图形字符块,映射替代的字符集 ae 结束替代的字符集 as 为图形字符块开始替代的字符集 bc 退格,如果没有 ^H bl 铃声 bt 移动到前一个tab停止位 cb 从行的开始处清除到光标处 cc 虚设命令字符 cd 清除到屏幕的末端 ce 清除到行末 ch 水平移动光标到 %1列 cl 清除屏幕并将光标置位 cm 光标移动到%1行,%2列 (屏幕中) CM 光标移动到%1行,%2列 (内存中) cr 回车 cs 翻滚区域,从%1行到%2行 ct 清除tab cv 垂直移动光标到%1行 dc 删除一个字符 DC 删除%1个字符 dl 删除一行 DL 删除%1行 dm 开始delete模式 do 光标下移一行 DO 光标下移#1行 ds 使状态行不可用 eA 激活替代的字符集 ec 从光标处开始,删除%1个字符 ed 结束delete模式 ei 结束insert模式 ff 硬拷贝终端上的走纸符 fs 在进入状态行之前返回字符到他的位置 F1 由功能键F11发送的字符串 F2 由功能键F12发送的字符串 F3 由功能键F14发送的字符串 ... ... F9 由功能键F19发送的字符串 FA 由功能键F20发送的字符串 FB 由功能键F21发送的字符串 ... ... FZ 由功能键F45发送的字符串 Fa 由功能键F46发送的字符串 Fb 由功能键F47发送的字符串 ... ... Fr 由功能键F63发送的字符串 hd 移动光标到下一行的中间 ho 光标置初始位 hu 移动光标到上一行的中间 i1 登录时,初始化的字符串1 i3 登录时,初始化的字符串3 is 登录时,初始化的字符串2 ic 插入一个字符 IC 插入%1个字符 if 初始化文件 im 开始插入模式 ip 插入填充时间和插入后所需要的特殊字符 iP 初始化程序 K1 辅助键盘的上左键 K2 辅助键盘的center键 K3 辅助键盘的上右键 K4 辅助键盘的底部左键 K5 辅助键盘的底部右键 k0 功能键0 k1 功能键1 k2 功能键2 k3 功能键3 k4 功能键4 k5 功能键5 k6 功能键6 k7 功能键7 k8 功能键8 k9 功能键9 k; 功能键10 ka 清除所有的tab键 kA 插入行键 kb 退格键 kB 退回tab停止位 kC 清屏键 kd 光标下移键 kD 删除光标下的字符键 ke 关闭辅助键盘 kE 清除到行末 kF 向前/后滚卷 kh 光标置初始位键 kH 光标hown down键 kI 插入字符/插入模式键 kl 光标左移键 kL 整行删除键 kM 退出插入模式 kN 下一页 kP 上一页 kr 光标右移键 kR 向后/前滚卷键 ks 开辅助键盘 kS 清除到屏幕末端 kt 清除这个tab键 kT 设置这儿的tab键 ku 光标向上键 l0 如果没有f0,第零个标签功能键 l1 如果没有f1,***个标签功能键 l2 如果没有f2,第二个标签功能键 ... ... la 如果没有f10,第十个标签功能键 le 光标左移一个字符 ll 移动光标到左底角 LE 光标左移%1个字符 LF 关闭软标签 LO 开启软标签 mb 开始闪烁 MC 清除软标记 md 开始粗体模式 me 开始所有的模式如so, us, mb, md 和 mr mh 开始半闪烁模式 mk 暗模式 (看不见字符) ML 设置左软标记 mm 使终端为meta模式 mo 使终端离开meta模式 mp 打开保护属性 mr 开始反亮模式 MR 设置右软标记 nd 光标右移一个字符 nw 回车命令 pc 填充字符 pf 关闭打印机 pk 对键%1编程,如同用户打印一样发送字符串%2 pl 对键%1编程,以本地模式执行字符串%2 pn 对软标签%1编程来显示字符串%2 po 打开打印机 pO 打开打印机%1 (<256)字节 ps 在打印机上打印屏幕内容 px 对键%1编程来发送字符串%2给计算机 r1 向设定的终端重置字符串1到sane模式 r2 向设定的终端重置字符串2到sane模式 r3 向设定的终端重置字符串3到sane模式 RA 取消自动标记功能 rc 恢复存储的光标位置 rf 重设字符串文件名 RF 终端输入请求 RI 光标右移%1个字符 rp 重复字符%1,共%2次 rP 替换模式中,在字符发送后填充 rs 重设字符串 RX 关闭XON/XOFF流量控制 sa 设置 %1 %2 %3 %4 %5 %6 %7 %8 %9属性 SA 激活自动标记功能 sc 保存光标位置 se 结束突出模式 sf 正常滚卷一行 SF 正常滚卷%1行 so 开始突出模式 sr 反向滚卷 SR 向上滚卷%1行 st 设置所有行的制表符的停止位到当前列 SX 打开XON/XOFF流量控制 ta 移动到下一个硬件tab tc 从另一个登记项读取终端描述 te 结束使用光标动作的程序 ti 开始光标动作的程序 ts 移动光标到状态行的%1列 uc 光标下方字符下划线,并向右移动光标 ue 结束下划线 up 光标向上一行 UP 光标向上%1行 us 开始下划线 vb 可视化闹铃 ve 正常的可见光标 vi 光标不可见 vs 突出光标 wi 设置窗口,从%1行到%2行,从3%列到4%列 XF XOFF字符,如果没有 ^S
还有一些方法定义字符串值功能的控制代码:
通常的字符表示它们自己,除了 '^','' 和 '%' 。
一个 '^x' 表示Control-x. Control-A等于 1 个10进制数。
表示一个特殊的代码。x 可以是以下的一个字符:
- E 转义符 Escape (27)
n 换行 Linefeed (10)
r 回车 Carriage return (13)
t 制表符 Tabulation (9)
b 退格 Backspace (8)
f 走纸符 Form feed (12)
0 空字符 Null character. \xxx 指定八进制为 xxx 的字符.
- i
- 逐一增加参数
- r
- 单个参数功能
- +
- 增加下一个字符的值到这个参数并以二进制输出
- 2
- 对于2,用一个字段将参数以ASCII输出
- d
- 对于3,用一个字段将参数以ASCII输出
- %
- 打印一个 '%'
如果你使用二进制输出,那么你应该避免空字符,因为它是字符串的终止符。如果Tab键能够成为一个参数的二进制输出,你应该重新设置Tab键长度。
- 警告:
- 以上参数的元字符是针对 Minix 系统的 termcap,可能有一些问题,因为可能不是完全与 Linux 的 termcap 兼容的。
图形字符块通过三个字符串值功能来指定:
- as
- 开始替代的字符集
- ae
- 结束
- ac
- 字符对。***个字符是图形字符块的名称,第二个字符是它的定义。
可以用下面这些名称:
+ 右箭头 right arrow (>) , 左箭头 left arrow (<) . 下箭头 down arrow (v) 0 全直角 full square (#) I 上箭头 latern (#) - 上箭头 upper arrow (^) ' 菱形 rhombus (+) a 棋板 chess board (:) f 度数 degree (') g 加-减 plus-minus (#) h 正方形 square (#) j 右下角 right bottom corner (+) k 右上角 right upper corner (+) l 左上角 left upper corner (+) m 左下角 left bottom corner (+) n 十字 cross (+) o 顶线 upper horizontal line (-) q 中线 middle horizontal line (-) s 下划线 bottom horizontal line (_) t 左侧T型 left tee (+) u 右侧T型 right tee (+) v 底部T型 bottom tee (+) w 常规T型 normal tee (+) x 垂直线 vertical line (|) ~ 段落 paragraph (???)
如果缺少相应功能,将缺省使用圆括号中的值,那是 curses 库使用的值。
参见 SEE ALSO
termcap(3), curses(3), terminfo(5)
#p#
NAME
termcap - terminal capability database
DESCRIPTION
The termcap database is an obsolete facility for describing the capabilities of character-cell terminals and printers. It is retained only for capability with old programs; new ones should use the terminfo(5) database and associated libraries.
/etc/termcap is an ASCII file (the database master) that lists the capabilities of many different types of terminals. Programs can read termcap to find the particular escape codes needed to control the visual attributes of the terminal actually in use. (Other aspects of the terminal are handled by stty.) The termcap database is indexed on the TERM environment variable.
Termcap entries must be defined on a single logical line, with `\' used to suppress the newline. Fields are separated by `:'. The first field of each entry starts at the left-hand margin, and contains a list of names for the terminal, separated by '|'.
The first subfield may (in BSD termcap entries from versions 4.3 and prior) contain a short name consisting of two characters. This short name may consist of capital or small letters. In 4.4BSD termcap entries this field is omitted.
The second subfield (first, in the newer 4.4BSD format) contains the name used by the environment variable TERM. It should be spelled in lowercase letters. Selectable hardware capabilities should be marked by appending a hyphen and a suffix to this name. See below for an example. Usual suffixes are w (more than 80 characters wide), am (automatic margins), nam (no automatic margins), and rv (reverse video display). The third subfield contains a long and descriptive name for this termcap entry.
Subsequent fields contain the terminal capabilities; any continued capability lines must be indented one tab from the left margin.
Although there is no defined order, it is suggested to write first boolean, then numeric, and then string capabilities, each sorted alphabetically without looking at lower or upper spelling. Capabilities of similar functions can be written in one line.
Example for: Head line: vt|vt101|DEC VT 101 terminal in 80 character mode:\ Head line: Vt|vt101-w|DEC VT 101 terminal in (wide) 132 character mode:\ Boolean: :bs:\ Numeric: :co#80:\ String: :sr=\E[H:\
Boolean Capabilities
5i Printer will not echo on screen am Automatic margins which means automatic line wrap bs Control-H (8 dec.) performs a backspace bw Backspace on left margin wraps to previous line and right margin da Display retained above screen db Display retained below screen eo A space erases all characters at cursor position es Escape sequences and special characters work in status line gn Generic device hc This is a hardcopy terminal HC The cursor is hard to see when not on bottom line hs Has a status line hz Hazeltine bug, the terminal can not print tilde characters in Terminal inserts nulls, not spaces, to fill whitespace km Terminal has a meta key mi Cursor movement works in insert mode ms Cursor movement works in standout/underline mode NP No pad character NR ti does not reverse te nx No padding, must use XON/XOFF os Terminal can overstrike ul Terminal underlines although it can not overstrike xb Beehive glitch, f1 sends ESCAPE, f2 sends ^C xn Newline/wraparound glitch xo Terminal uses xon/xoff protocol xs Text typed over standout text will be displayed in standout xt Teleray glitch, destructive tabs and odd standout mode
Numeric Capabilities
co Number of columns dB Delay in milliseconds for backspace on hardcopy terminals dC Delay in milliseconds for carriage return on hardcopy terminals dF Delay in milliseconds for form feed on hardcopy terminals dN Delay in milliseconds for new line on hardcopy terminals dT Delay in milliseconds for tabulator stop on hardcopy terminals dV Delay in milliseconds for vertical tabulator stop on hardcopy terminals it Difference between tab positions lh Height of soft labels lm Lines of memory lw Width of soft labels li Number of lines Nl Number of soft labels pb Lowest baud rate which needs padding sg Standout glitch ug Underline glitch vt virtual terminal number ws Width of status line if different from screen width
String Capabilities
!1 shifted save key !2 shifted suspend key !3 shifted undo key #1 shifted help key #2 shifted home key #3 shifted input key #4 shifted cursor left key %0 redo key %1 help key %2 mark key %3 message key %4 move key %5 next-object key %6 open key %7 options key %8 previous-object key %9 print key %a shifted message key %b shifted move key %c shifted next key %d shifted options key %e shifted previous key %f shifted print key %g shifted redo key %h shifted replace key %i shifted cursor right key %j shifted resume key &0 shifted cancel key &1 reference key &2 refresh key &3 replace key &4 restart key &5 resume key &6 save key &7 suspend key &8 undo key &9 shifted begin key *0 shifted find key *1 shifted command key *2 shifted copy key *3 shifted create key *4 shifted delete character *5 shifted delete line *6 select key *7 shifted end key *8 shifted clear line key *9 shifted exit key @0 find key @1 begin key @2 cancel key @3 close key @4 command key @5 copy key @6 create key @7 end key @8 enter/send key @9 exit key al Insert one line AL Indert %1 lines ac Pairs of block graphic characters to map alternate character set ae End alternative character set as Start alternative character set for block graphic characters bc Backspace, if not ^H bl Audio bell bt Move to previous tab stop cb Clear from beginning of line to cursor cc Dummy command character cd Clear to end of screen ce Clear to end of line ch Move cursor horizontally only to column %1 cl Clear screen and cursor home cm Cursor move to row %1 and column %2 (on screen) CM Move cursor to row %1 and column %2 (in memory) cr Carriage return cs Scroll region from line %1 to %2 ct Clear tabs cv Move cursor vertically only to line %1 dc Delete one character DC Delete %1 characters dl Delete one line DL Delete %1 lines dm Begin delete mode do Cursor down one line DO Cursor down #1 lines ds Disable status line eA Enable alternate character set ec Erase %1 characters starting at cursor ed End delete mode ei End insert mode ff Formfeed character on hardcopy terminals fs Return character to its position before going to status line F1 The string sent by function key f11 F2 The string sent by function key f12 F3 The string sent by function key f13 ... ... F9 The string sent by function key f19 FA The string sent by function key f20 FB The string sent by function key f21 ... ... FZ The string sent by function key f45 Fa The string sent by function key f46 Fb The string sent by function key f47 ... ... Fr The string sent by function key f63 hd Move cursor a half line down ho Cursor home hu Move cursor a half line up i1 Initialization string 1 at login i3 Initialization string 3 at login is Initialization string 2 at login ic Insert one character IC Insert %1 characters if Initialization file im Begin insert mode ip Insert pad time and needed special characters after insert iP Initialization program K1 upper left key on keypad K2 center key on keypad K3 upper right key on keypad K4 bottom left key on keypad K5 bottom right key on keypad k0 Function key 0 k1 Function key 1 k2 Function key 2 k3 Function key 3 k4 Function key 4 k5 Function key 5 k6 Function key 6 k7 Function key 7 k8 Function key 8 k9 Function key 9 k; Function key 10 ka Clear all tabs key kA Insert line key kb Backspace key kB Back tab stop kC Clear screen key kd Cursor down key kD Key for delete character under cursor ke turn keypad off kE Key for clear to end of line kF Key for scolling forward/down kh Cursor home key kH Cursor hown down key kI Insert character/Insert mode key kl Cursor left key kL Key for delete line kM Key for exit insert mode kN Key for next page kP Key for previous page kr Cursor right key kR Key for scolling backward/up ks Turn keypad on kS Clear to end of screen key kt Clear this tab key kT Set tab here key ku Cursor up key l0 Label of zeroth function key, if not f0 l1 Label of first function key, if not f1 l2 Label of first function key, if not f2 ... ... la Label of tenth function key, if not f10 le Cursor left one character ll Move cursor to lower left corner LE Cursor left %1 characters LF Turn soft labels off LO Turn soft labels on mb Start blinking MC Clear soft margins md Start bold mode me End all mode like so, us, mb, md and mr mh Start half bright mode mk Dark mode (Characters invisible) ML Set left soft margin mm Put terminal in meta mode mo Put terminal out of meta mode mp Turn on protected attribute mr Start reverse mode MR Set right soft margin nd Cursor right one character nw Carriage return command pc Padding character pf Turn printer off pk Program key %1 to send string %2 as if typed by user pl Program key %1 to execute string %2 in local mode pn Program soft label %1 to to show string %2 po Turn the printer on pO Turn the printer on for %1 (<256) bytes ps Print screen contents on printer px Program key %1 to send string %2 to computer r1 Reset string 1 to set terminal to sane modes r2 Reset string 2 to set terminal to sane modes r3 Reset string 3 to set terminal to sane modes RA disable automatic margins rc Restore saved cursor position rf Reset string file name RF Request for input from terminal RI Cursor right %1 characters rp Repeat character %1 for %2 times rP Padding after character sent in replace mode rs Reset string RX Turn off XON/XOFF flow control sa Set %1 %2 %3 %4 %5 %6 %7 %8 %9 attributes SA enable automatic margins sc Save cursor position se End standout mode sf Normal scroll one line SF Normal scroll %1 lines so Start standout mode sr Reverse scroll SR scroll back %1 lines st Set tabulator stop in all rows at current column SX Turn on XON/XOFF flow control ta move to next hardware tab tc Read in terminal description from another entry te End program that uses cursor motion ti Begin program that uses cursor motion ts Move cursor to column %1 of status line uc Underline character under cursor and move cursor right ue End underlining up Cursor up one line UP Cursor up %1 lines us Start underlining vb Visible bell ve Normal cursor visible vi Cursor unvisible vs Standout cursor wi Set window from line %1 to %2 and column %3 to %4 XF XOFF character if not ^S
There are several ways of defining the control codes for string capabilities:
Normal Characters except '^','\' and '%' repesent themself.
A '^x' means Control-x. Control-A equals 1 decimal.
\x means a special code. x can be one of the following charaters:
- E Escape (27)
n Linefeed (10)
r Carriage return (13)
t Tabulation (9)
b Backspace (8)
f Form feed (12)
0 Null character. A \xxx specifies the octal character xxx.
- i
- Increments paramters by one.
- r
- Single parameter capability
- +
- Add value of next character to this parameter and do binary output
- 2
- Do ASCII output of this parameter with a field with of 2
- d
- Do ASCII output of this parameter with a field with of 3
- %
- Print a '%'
If you use binary output, then you should avoid the null character because it terminates the string. You should reset tabulator expansion if a tabulator can be the binary output of a parameter.
- Warning:
- The above metacharacters for parameters may be wrong, they document Minix termcap which may not be compatible with Linux termcap.
The block graphic characters can be specified by three string capabilities:
- as
- start the alternative charset
- ae
- end it
- ac
- pairs of characters. The first character is the name of the block graphic symbol and the second characters is its definition.
The following names are available:
+ right arrow (>) , left arrow (<) . down arrow (v) 0 full square (#) I latern (#) - upper arrow (^) ' rhombus (+) a chess board (:) f degree (') g plus-minus (#) h square (#) j right bottom corner (+) k right upper corner (+) l left upper corner (+) m left bottom corner (+) n cross (+) o upper horizontal line (-) q middle horizontal line (-) s bottom horizontal line (_) t left tee (+) u right tee (+) v bottom tee (+) w normal tee (+) x vertical line (|) ~ paragraph (???)
The values in parentheses are suggested defaults which are used by curses, if the capabilities are missing.
SEE ALSO
termcap(3), curses(3), terminfo(5)