terminfo Directory
Purpose
Contains compiled terminfo source files.
Description
Terminfo is a compiled database describing the capabilities of terminals. Terminals are described in the terminfo source files via entries. Each entry contains information about the capabilities for a particular terminal or set of common terminals. Capabilities include the operations that can be performed, the padding requirements, cursor positioning, command sequences, and initialization sequences.
The compiled terminfo database is used by applications such as curses and vi that must have knowledge of the terminal but do not want to be terminal-dependent.
This article describes the terminfo source file format and covers the following topics:
- Source File Entries
- Types of Capabilities
- Preparing Descriptions
- Basic Capabilities
- Parameterized Strings
- Cursor Motions
- Area Clears
- Scrolling
- Insert or Delete Character
- Highlighting, Underlining, and Visual Bells
- Keypad
- Tabs and Initialization
- Miscellaneous Strings
- Status Lines
- Line Graphics
- Color Manipulation
- Special Cases
- Similar Terminals
- Printer Capabilities
- Database File Names
An example of a terminfo source file is provided.
This article explains the terminfo source file format. Before a terminfo description can be used by applications, the terminfo source file it resides in must be compiled using the tic command. Using the tic command results in the creation of one or more binaries, one for each terminal. The collection of terminfo binaries in a directory (usually /usr/share/lib/terminfo) is known as the terminfo database, or terminfo.
Source File Entries
You can edit or modify source files. A source file can contain one or more terminal descriptions or entries. A terminfo source file has a .ti suffix. Examples of source files are the /usr/share/lib/terminfo/ibm.ti file, which describes IBM® terminals, and the /usr/share/lib/terminfo/dec.ti file, which describes DEC terminals.
See the infocmp command for obtaining the source description for a terminal when only the binary is available.
Each entry in a terminfo source file consists of a number of fields separated by commas. White space between commas is ignored. The following example shows a source file entry:
ibm6155-113|IBM 6155 Black & White display,
font0=\E[10m, font1=\E[11m, font2=\E[12m,
bold=\E[12m, sgr0=\E[0;10m,
cols#113, lines#38,
sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;12%;m,
blink@, use=ibm5151,
Entries can continue onto multiple lines by placing white space at the beginning of each subsequent line. To create a comment line, begin the line with a # (pound sign) character. To comment out an individual terminal capability, put a period before the capability name.
The first field (or line) for each terminal gives the various names by which the terminal is known, separated by | (pipe symbol) characters. The first given name should be the most common abbreviation for the terminal. (This name is the one most commonly used when setting the TERM environment variable.) The last name given should be a long name fully identifying the terminal. All other names are understood as synonyms for the terminal name. All names but the last should contain no blanks. The last name may contain blanks for readability. All names should be unique.
The remaining fields identify the terminal 's capabilities.
When choosing terminal names, there are some conventions you should follow. The root name should represent the particular hardware class of the terminal. Do not use hyphens in the root name, except to avoid synonyms that conflict with other names. To indicate possible modes for the hardware or user preferences, append a - (minus sign) and one of the following suffixes:
Suffix | Meaning | Example |
---|---|---|
-am | With automatic margins (usually default) | Terminal-am |
-m | Monochrome mode | Terminal-m |
-w | Wide mode (more than 80 columns) | Terminal-w |
-nam | Without automatic margins | Terminal-nam |
-n | Number of lines on the screen | Terminal-60 |
-na | No arrow keys (leave them in local) | Terminal-na |
-np | Number of pages of memory | Terminal-4p |
-rv | Reverse video | Terminal-rv |
-s | Status line simulation. The terminal allows for one or more lines that are normally part of the screen to be used for the status line. This is not the same as terminals that have permanently dedicated status lines. | Terminal-s |
-unk | Unknown mode. This entry can be used to define a general description of a terminal that has several of the modes described above. The other entries would use the unknown entry as a base description and add the appropriate customization. See the use= field. | Terminal-unk |
A terminal in 132-column mode would be Terminal-w.
Types of Capabilities
A terminfo entry can define any number of capabilities. All capabilities belong to one of three types:
Item | Description |
---|---|
Boolean | Indicates that the terminal has a particular feature. Boolean capabilities are true if the corresponding name is contained in the terminal description. |
Numeric | Gives the size of the terminal or the size of particular delays. |
String | Gives a sequence that can be used to perform particular terminal operations. |
This article provides tables that document the capability types. All the tables list the following:
Item | Description |
---|---|
Variable | The name the application uses to access a capability. |
Cap Name | The short capability name. This name is used in the terminfo database text and by the person creating or editing a source file entry. You can use the tput command to output the value of a capability for a particular terminal. |
I.Code | The 2-letter internal code used in the compiled database. This code always corresponds to a termcap capability name. |
Description | A description of the capability. |
Capability names have no absolute length limit. An informal limit of five characters is adopted to keep them short and to allow the tabs in the caps source file to be aligned. Whenever possible, names are chosen to be the same as or similar to the ANSI X3.64 standard of 1979.
For a detailed description of the various capabilities according to function, read:
- Basic Capabilities
- Parameterized Strings
- Cursor Motions
- Area Clears
- Insert or Delete Line
- Insert or Delete Line Character
- Highlighting, Underlining, and Visual Bells
- Keypad
- Tabs and Initialization
- Miscellaneous Strings
Boolean Capabilities
A Boolean capability indicates that the terminal has some particular feature. For instance, the am capability in a terminal description indicates that the terminal has automatic margins (such as an automatic new line when the end of a line is reached). The following are the Boolean capabilities:
Variable | Cap Name | I.Code |
---|---|---|
|
bw | bw |
|
am | am |
|
bce | ut |
|
ccc | cc |
|
xhp | xs |
|
xhpa | YA |
|
cpix | YF |
|
crxm | YB |
|
xt | xt |
|
xenl | xn |
|
eo | eo |
|
gn | gn |
|
hc | hc |
|
chts | HC |
|
km | km |
|
daisy | YC |
|
hs | hs |
|
hls | hl |
|
in | in |
|
lpix | YG |
|
da | da |
|
db | db |
|
mir | mi |
|
msgr | ms |
|
nxon | nx |
|
xsb | xb |
|
npc | NP |
|
ndscr | ND |
|
nrrmc | NR |
|
os | os |
|
mc5i | 5i |
|
xvpa | YD |
|
sam | YE |
|
eslok | es |
|
hz | hz |
|
ul | ul |
|
xon | xo |
Numeric Capabilities
Numeric capabilities are followed by the # (pound sign) character and a numeric value. The cols#80 capability indicates the terminal has 80 columns. The following are the numeric capabilities:
Variable | Cap Name | I.Code |
---|---|---|
|
bufsz | Ya |
|
cols | co |
|
spinh | Yc |
|
spinv | Yb |
|
it | it |
|
lh | lh |
|
lw | lw |
|
lines | li |
|
lm | lm |
|
xmc | sg |
|
ma | ma |
|
colors | Co |
|
maddr | Yd |
|
mjump | Ye |
|
pairs | pa |
|
wnum | MW |
|
mcs | Yf |
|
mls | Yg |
|
ncv | NC |
|
nlab | Nl |
|
npins | Yh |
|
orc | Yi |
|
orhi | Yk |
|
orl | Yj |
|
orvi | Yl |
|
pb | pb |
|
cps | Ym |
|
vt | vt |
|
widcs | Yn |
|
wsl | ws |
String Capabilities
el=\EK$<3>
The tputs subroutine provides padding characters for a delay. A delay can be a number, such as 20, or a number followed by an * (asterisk), such as 3*. An asterisk indicates that the required padding is proportional to the number of lines affected by the operation. The number given represents the required padding for each affected unit. (For insert character, the factor is the number of lines affected, which is always 1, unless the terminal has the xenl capability and the software supports it). If you specify an asterisk, it is sometimes useful to give a delay of the form a.b, such as 3.5, to specify a delay for each unit to tenths of milliseconds. You can only specify one decimal place.
The terminfo database provides several escape sequences in the string-valued capabilities for easy encoding of characters. The following escape codes are recognized:
Escape Code | Meaning |
---|---|
\E,\e | Escape |
\n | New line |
\l | Line feed |
\r | Carriage return |
\t | Tab |
\b | Backspace |
\f | Form feed |
\s | Space |
\^ | Caret |
\\ | Backslash |
\, | Comma |
\: | Colon |
\nnn | Character with octal value nnn |
^x | Ctrl-x for any appropriate x |
\0 | Null character. \0 actually produces \200, which does not end a string but behaves as a null character on most terminals. |
The following conventions are used in the String Capabilities table:
- (G)
- Indicates that the string is passed through tparm, with parameters as given (#i).
- (*)
- Indicates that padding can be based on the number of lines affected.
- (#i)
- Indicates the ith parameter.
Table 4. String Capabilities Variable Cap Name I.Code - appl_defined_str
- Application-defined terminal string.
apstr za - asc_chars
- Alternate character set mapping of glyph to characters.
acsc ac - back_tab
- Back tab.
cbt bt - bell
- Produces an audible signal (bell).
bel bl - box_chars_1
- Box characters, primary set.
box1 bx - box_chars_2
- Box characters, alternate set.
box2 by - box_attr_1
- Attributes for box_chars_1.
batt1 Bx - box_attr_2
- Attributes for box_chars_2.
batt2 By - carriage_return
- Indicates carriage return. (*)
cr cr - change_char_pitch
- Change number of characters per inch.
cpi ZA - change_line_pitch
- Change number of lines per inch.
lpi ZB - change_res_horz
- Change horizontal resolution.
chr ZC - change_res_vert
- Change vertical resolution.
cvr XD - char_padding
- Specifies character padding when in replace mode.
rmp rP - change_scroll_region
- Changes scroll region to lines #1 through #2. (G)
csr cs - char_set_names
- List of character set names.
csnm Zy - clear_all_tabs
- Clears all tab stops.
tbc ct - clear_margins
- Clear left and right soft margins.
mgc MC - clear_screen
- Clears screen and puts cursor in home position. (*)
clear cl - clr_bol
- Clear to beginning of line, inclusive.
el1 cb - clr_eol
- Clears to end of line.
el ce - clr_eod
- Clears to end of the display.(*)
ed cd - color_bg_0
- Background color 0, black.
colb0 d0 - color_bg_1
- Background color 1, red.
colb1 d1 - color_bg_2
- Background color 2, green.
colb2 d2 - color_bg_3
- Background color 3, brown.
colb3 d3 - color_bg_4
- Background color 4, blue.
colb4 d4 - color_bg_5
- Background color 5, magenta.
colb5 d5 - color_bg_6
- Background color 6, cyan.
colb6 d6 - color_bg_7
- Background color 7, white.
colb7 d7 - color_fg_0
- Foreground color 0, black.
colf0 c0 - color_fg_1
- Foreground color 1, red.
colf1 c1 - color_fg_2
- Foreground color 2, green.
colf2 c2 - color_fg_3
- Foreground color 3, brown.
colf3 c3 - color_fg_4
- Foreground color 4, blue.
colf4 c4 - color_fg_5
- Foreground color 5, magenta.
colf5 c5 - color_fg_6
- Foreground color 6, cyan.
colf6 c6 - color_fg_7
- Foreground color 7, white.
colf7 c7 - column_address
- Sets cursor column. (G)
hpa ch - command_character
- Indicates that a terminal command-prototype character can be set.
cmdch CC - create_window
- Define win #1 to go from #2, #3 to #4, #5.
cwin CW - cursor_address
- Indicates screen-relative cursor motion row #1, col #2. (G)
cup cm - cursor_down
- Moves cursor down one line.
cud1 do - cursor_home
- Moves cursor to home position (if no cup addressing).
home ho - cursor_invisible
- Makes cursor invisible.
civis vi - cursor_left
- Moves cursor left one space.
cub1 le - cursor_mem_address
- Indicates memory relative cursor addressing. (G)
mrcup CM - cursor_normal
- Makes cursor appear normal (undo vs or vi).
cnorm ve - cursor_right
- Indicates nondestructive space (cursor right).
cuf1 nd - cursor_to_ll
- Moves cursor to first column of last line (if no cup addressing).
ll ll - cursor_up
- Moves cursor up one line.
cuu1 up - cursor_visible
- Makes cursor very visible.
cvvis vs - define char
- Define a character in a character set.
defc ZE - delete_character
- Deletes character. (*)
dch1 dc - delete_line
- Deletes line. (*)
dl1 dl - dial_phone
- Dial phone number #1.
dial DI - dis_status_line
- Disables status line.
dsl ds - display_clock
- Display time-of-day clock.
dclk DK - down_half_line
- Indicates subscript (forward 1/2 line feed).
hd hd - ena_acs
- Enable alternate character set.
enacs eA - enter_alt_charset_mode
- Starts alternate character set.
smacs as - enter_am_mode
- Turn on automatic margins.
smam SA - enter_blink_mode
- Enables blinking.
blink mb - enter_bold_mode
- Enables bold (extra bright)mode.
bold md - enter_bottom_mode
- Starts bottom line mode. This string capability is an aid for drawing tables and is valid only for aixterm and aixterm-m terminal definitions.
btml bm - enter_ca_mode
- Begins programs that use cup addresing.
smcup ti - enter_delete_mode
- Starts delete mode.
smdc dm - enter_dim_mode
- Enables half-bright mode.
dim mh - enter_doublewide_mode
- Enable double-wide printing.
swidm ZF - enter_draft_quality
- Set draft quality print.
sdrfq ZG - enter_insert_mode
- Starts insert mode.
smir im - enter_italics_mode
- Enable italics.
sitm ZH - enter_leftward_mode
- Enable leftward carrige motion.
slm Zl - enter_lvert_mode
- Starts left vertical line mode. This string capability is an aid for drawing tables. Valid only for aixterm and aixterm-m terminal definitions.
lvert lv - enter_micro_mode
- Enable micro motion capabilities.
smicm ZJ - enter_near_letter_quality
- Set near-letter quality print.
snlq ZK - enter_normal_quality
- Set normal quality print.
snrmq ZL - enter_protected_mode
- Enables protected mode.
prot mp - enter_reverse_mode
- Enables reverse video mode.
rev mr - enter_rvert_mode
- Starts right vertical line mode. This string capability is an aid for drawing tables and is valid only for aixterm and aixterm-m terminal definitions.
rvert rv - enter_secure_mode
- Enables blank mode (characters are invisible).
invis mk - enter_shadow_mode
- Enable shadow printing.
sshm ZM - enter_standout_mode
- Begins standout mode.
smso so - enter_subscript_mode
- Enable subscript printing.
ssubm ZN - enter_superscript_mode
- Enable superscript printing.
ssupm ZO - enter_topline_mode
- Starts top line mode. This string capability is an aid for drawing tables and is valid only for aixterm and aixterm-m terminal definitions.
topl tp - enter_underline_mode
- Starts underscore mode.
smul us - enter_upward_mode
- Enable upward carriage motion.
sum ZP - enter_xon_mode
- Turn on xon/xoff handshaking.
smxon SX - erase_chars
- Erases #1 characters. (G)
ech ec - exit_alt_charset_mode
- Ends alternate character set.
rmacs ae - exit_am_mode
- Turn off automatic margins.
rmam RA - exit_attribute_mode
- Disables all attributes.
sgr0 me - exit_ca_mode
- Ends programs that use cup addressing.
rmcup te - exit_delete_mode
- Ends delete mode.
rmdc ed - exit_doublewide_mode
- Disable double-wide printing.
rwidm ZQ - exit_insert_mode
- Ends insert mode.
rmir ei - exit_italics_mode
- Disable italics.
ritm ZR - exit_leftward_mode
- Enable rightward (normal) carriage motion.
rlm ZS - exit_micro_mode
- Disable micro motion capabilities.
micm ZT - exit_shadow_mode
- Disable shadow printing.
rshm ZU - exit_standout_mode
- Ends standout mode.
rmso se - exit_subscript_mode
- Disable subscript printing.
rsubm ZV - exit_superscript_mode
- Disable superscript printing.
rsupm ZW - exit_underline_mode
- Ends underscore mode.
rmul ue - exit_upward_mode
- Enable downard (normal) carrige motion.
rum ZX - exit_xon_mode
- Turn off xon/xoff handshaking.
rmxon RX - flash_screen
- Indicates visual bell (may not move cursor).
flash vb - fixed_pause
- Pause for 2-3 seconds.
pause PA - flash_hook
- Flash the switch hook.
hook fh - font_0
- Select font 0.
font0 f0 - font_1
- Select font 1.
font1 f1 - font_2
- Select font 2.
font2 f2 - font_3
- Select font 3.
font3 f3 - font_4
- Select font 4.
font4 f4 - font_5
- Select font 5.
font5 f5 - font_6
- Select font 6.
font6 f6 - font_7
- Select font 7.
font7 f7 - form_feed
- Ejects page (hardcopy terminal). (*)
ff ff - from_status_line
- Returns from status line.
fsl fs - goto_window
- Go to window #1.
wingo WG - hangup
- Hang-up phone.
hup HU - init_1string
- Initializes terminal.
is1 i1 - init_2string
- Initializes terminal.
is2 is - init_3string
- Initializes terminal.
is3 i3 - init_file
- Identifies file containing is long initialization strings.
if if - init_prog
- Locates the program for initialization.
iprog iP - initialize_color
- Initialize the color definition.
initc Ic - initialize_pair
- Initialize color pair.
initp Ip - insert_character
- Inserts character.
ich1 ic - insert_line
- Adds new blank line. (*)
il1 al - insert_padding
- Inserts pad after character inserted. (*)
ip ip - key_a1
- Specifies upper left of keypad.
ka1 K1 - key_a3
- Specifies upper right of keypad.
ka3 K3 - key_action
- Sent by action key.
kact kJ - key_b2
- Specifies center of keypad.
kb2 K2 - key_backspace
- Sent by backspace key.
kbs kb - key_beg
- Beginning key. KEY_BEG
kbeg @1 - key_btab
- Sent by backtab key. KEY_BTAB
kcbt kB - key_c1
- Specifies lower left of keypad.
kc1 K4 - key_c3
- Specifies lower right of keypad.
kc3 K5 - key_cancel
- Cancel key. KEY_CANCEL
kcan @2 - key_catab
- Sent by clear-all-tabs key.
ktbc ka - key_clear
- Sent by clear screen or erase key.
kclr kC - key_close
- Close key. KEY_CLOSE
kclo @3 - key_command
- Command-request key.
kcmd @4 - key_command_pane
- Command-pane key.
kcpn @7 - key_copy
- Copy key. KEY_COPY
kcpy @5 - key_create
- Create key. KEY_CREATE
kcrt @6 - key_ctab
- Sent by clear tab key.
kctab kt - key_dc
- Sent by delete-character key.
kdch1 kD - key_dl
- Sent by delete-line key.
kdl1 kL - key_do
- Do request key.
kdo ki - key_down
- Sent by terminal down-arrow key.
kcud1 kd - key_eic
- Sent by rmir or smir in insert mode.
krmir kM - key_end
- End key. KEY_END
kend @7 - key_enter
- Enter/send (unreliable). KEY_ENTER.
kent @8 - key_eol
- Sent by clear-to-end-of-line key.
kel kE - key_eos
- Sent by clear-to-end-of-screen key.
ked kS - key_exit
- Exit key. KEY_EXIT.
kext @9 - key_f0
- Sent by function key F0.
kf0 k0 - key_f1
- Sent by function key F1.
kf1 k1 - key_f2
- Sent by function key F2.
kf2 k2 - key_f3
- Sent by function key F3.
kf3 k3 - key_f4
- Sent by function key F4.
kf4 k4 - key_f5
- Sent by function key F5.
kf5 k5 - key_f6
- Sent by function key F6.
kf6 k6 - key_f35
- Sent by function key 35. KEY_F(35)
kf35 FP - key_f36
- Sent by function key 36. KEY_F(36)
kf36 FP - key_f37
- Sent by function key 37. KEY_F(37)
kf37 FQ - key_f38
- Sent by function key 38. KEY_F(38)
kf38 FR - key_f39
- Sent by function key 39. KEY_F(39)
kf39 FS - key_f40
- Sent by function key 40. KEY_F(40)
kf40 FT - key_f41
- Sent by function key 41. KEY_F(41)
kf41 FU - key_f42
- Sent by function key 42. KEY_F(42)
kf42 FV - key_f43
- Sent by function key 43. KEY_F(43)
kf43 FW - key_f44
- Sent by function key 44. KEY_F(44)
kf44 FX - key_f45
- Sent by function key 45. KEY_F(45)
kf45 FY - key_f46
- Sent by function key 46. KEY_F(46)
kf46 FZ - key_f47
- Sent by function key 47. KEY_F(47)
kf47 Fa - key_f48
- Sent by function key 48. KEY_F(48)
kf48 Fb - key_f49
- Sent by function key 49. KEY_F(49)
kf49 Fc - key_f50
- Sent by function key 50. KEY_F(50)
kf50 Fd - key_f51
- Sent by function key f51. KEY_F(51)
kf51 Fe - key_f52
- Sent by function key f52. KEY_F(52)
kf52 Ff - key_f53
- Sent by function key f53. KEY_F(53)
kf53 Fg - key_f54
- Sent by function key f54. KEY_F(54)
kf54 Fi - key_f55
- Sent by function key f55. KEY_F(55)
kf55 Fj - key_f56
- Sent by function key f56. KEY_F(56)
kf56 Fk - key_f57
- Sent by function key f57. KEY_F(57)
kf57 Fl - key_f58
- Sent by function key f58. KEY_F(58)
kf58 Fm - key_f59
- Sent by function key f59. KEY_F(59)
kf59 Fn - key_f60
- Sent by function key f60. KEY_F(60)
kf60 Fo - key_f61
- Sent by function key f61. KEY_F(61)
kf61 Fp - key_f62
- Sent by function key f62. KEY_F(62)
kf62 Fq - key_f63
- Sent by function key f63. KEY_F(63)
kf63 Fr - key_find
- Find key. KEY_FIND
kfnd @0 - key_help
- Help key.
khlp kq - key_home
- Sent by home key.
khome kh - key_ic
- Sent by insert-character/ enter-insert-mode key.
kich1 kI - key_il
- Sent by insert line key.
kil1 kA - key_left
- Sent by terminal left-arrow key.
kcub1 kl - key_ll
- Sent by home-down key.
kll kH - key_mark
- Mark key. KEY_MARK
kmrk %2 - key_message
- Message key. KEY_MESSAGE
kmsg %3 - key_move
- Move key. KEY_MOVE
kmov %4 - key_newline
- New-line key.
knl kn - key_next
- Next object key. KEY_NEXT
knxt %5 - key_next_pane
- Next-pane key.
knpn kv - key_npage
- Sent by next-page key.
knp kN - key_open
- Open key. KEY_OPEN
kopn %6 - key_options
- Options key. KEY_OPTIONS
kopt %7 - key_ppage
- Sent by previous-page key.
kpp kP - key_prev_pane
- Sent by previous-pane key.
kppn kV - key_prev_cmd
- Sent by previous-command key.
kpcmd kp - key_previous
- Previous object key. KEY_PREVIOUS
kprv %8 - key_print
- Print or copy. KEY_PRINT
kprt %9 - key_quit
- Quit key.
kquit kQ - key_redo
- Redo key. KEY_REDO
krdo %0 - key_reference
- Reference key. KEY_REFERENCE
kref &1 - key_refresh
- Refresh key. KEY_REFRESH
krfr &2 - key_replace
- Replace key. KEY_REPLACE
krpl &3 - key_restart
- Restart key. KEY_RESTART
krst &4 - key_resume
- Resume key. KEY_RESUME
kres &5 - key_right
- Sent by terminal right-arrow key.
kcuf1 kr - key_save
- Save key. KEY_SAVE
ksav &6 - key_sbeg
- Shifted beginning key. KEY_SBEG
kBEG &9 - key_scancel
- Shifted cancel key. KEY_SCANCEL
kCAN &0 - key_scommand
- Shifted command key. KEY_SCOMMAND
kCMD *1 - key_scopy
- Shifted copy key. KEY_SCOPY
kCPY *2 - key_screate
- Shifted create key. KEY_SCREATE
kCRT *3 - key_scroll_left
- Scroll left.
kscl kz - key_scroll_right
- Scroll right.
kscr kZ - key_sdc
- Shifted delete-character key. KEY_SDC
kDC *4 - key_sdl
- Shifted delete-line key. KEY_SDL
kDL *5 - key_select
- Select key.
kslt *6 - key_send
- Shifted end key. KEY_SEND
kEND *7 - key_seol
- Shifted clear-line key. KEY_SEOL
kEOL *8 - key_sexit
- Shifted exit key. KEY_SEXIT
kEXT *9 - key_sf
- Sent by scroll-forward/ scroll-down key.
kind kF - key_sf1
- Special function key 1.
ksf1 S1 - key_sf2
- Special function key 2.
ksf2 S2 - key_sf3
- Special function key 3.
ksf3 S3 - key_sf4
- Special function key 4.
ksf4 S4 - key_sf5
- Special function key 5.
ksf5 S5 - key_sf6
- Special function key 6.
ksf6 S6 - key_sf7
- Special function key 7.
ksf7 S7 - key_sf8
- Special function key 8.
ksf8 S8 - key_sf9
- Special function key 9.
ksf9 S9 - key_sf10
- Special function key 10.
ksf10 S0 - key_sfind
- Shifted find key. KEY_SFIND
kFND *0 - key_shelp
- Shifted help key. KEY_SHELP
kHLP #1 - key_shome
- Shifted home key. KEY_SHOME
kHOM #2 - key_sic
- Shifted input key. KEY_SIC
kIC #3 - key_sleft
- Shifted left-arrow key. KEY_SLEFT
kLFT #4 - key_smap_in1
- Input for special mapped key 1.
kmpf1 Kv - key_smap_in2
- Input for special mapped key 2.
kmpf2 Kw - key_smap_in3
- Input for special mapped key 3.
kmpf3 Kx - key_smap_in4
- Input for special mapped key 4.
kmpf4 Ky - key_smap_in5
- Input for special mapped key 5.
kmpf5 Kz - key_smap_in6
- Input for special mapped key 6.
kmpf6 Kr - key_smap_in7
- Input for special mapped key 7.
kmpf7 Ks - key_smap_in8
- Input for special mapped key 8.
kmpf8 Kt - key_smap_in9
- Input for special mapped key 9.
kmpf9 Ku - key_smap_out1
- Output for mapped key 1.
kmpt1 KV - key_smap_out2
- Output for mapped key 2.
kmpt2 KW - key_smap_out3
- Output for mapped key 3.
kmpt3 KX - key_smap_out4
- Output for mapped key 4.
kmpt4 KY - key_smap_out5
- Output for mapped key 5.
kmpt5 KZ - key_smap_out6
- Output for mapped key 6.
kmpt6 KR - key_smap_out7
- Output for mapped key 7.
kmpt7 KS - key_smap_out8
- Output for mapped key 8.
kmpt8 KT - key_smap_out9
- Output for mapped key 9.
kmpt9 KU - key_smessage
- Shifted message key. KEY_SMESSAGE
kMSG %a - key_smove
- Shifted move key. KEY_SMOVE
kMOV %b - key_snext
- Shifted next key. KEY_SNEXT
kNXT %c - key_soptions
- Shifted options key. KEY_SOPTIONS
kOPT %d - key_sprevious
- Shifted previous key. KEY_SPREVIOUS
kPRV %e - key_sprint
- Shifted print key. KEY_SPRINT
kPRT %f - key_sr
- Sent by scroll-backward key.
kri kR - key_redo
- Shifted redo key. KEY_SREDO
kRDO %g - key_replace
- Shifted replace key. KEY_REPLACE
kRPL %h - key_sright
- Shifted right-arrow key. KEY_SRIGHT
kRIT %i - key_srsume
- Shifted resume key. KEY_SRSUME
kRES %j - key_ssave
- Shifted save key. KEY_SSAVE
kSAV !1 - key_ssuspend
- Shifted suspend key. KEY_SSUPEND
kSPD !2 - key_stab
- Sent by set-tab key.
khts kT - key_sundo
- Shifted undo key. KEY_SUNDO
kUND !3 - key_suspend
- Suspend key. KEY_SUSPEND
kspd &7 - key_tab
- Tab key.
ktab ko - key_undo
- Undo key. KEY_UNDO
kund &8 - key_up
- Sent by terminal up-arrow key.
kcuu1 ku - keypad_local
- Ends keypad transmit mode.
rmkx ke - keypad_xmit
- Puts terminal in keypad transmit mode.
smkx ks - lab_f0
- Labels function key F0, if not F0.
lf0 l0 - lab_f1
- Labels function key F1, if not F1.
lf1 l1 - lab_f2
- Labels function key F2, if not F2.
lf2 l2 - lab_f3
- Labels function key F3, if not F3.
lf3 l3 - lab_f4
- Labels function key F4, if not F4.
lf4 l4 - lab_f5
- Labels function key F5, if not F5.
lf5 l5 - lab_f6
- Labels function key F6, if not F6.
lf6 l6 - lab_f7
- Labels function key F7, if not F7.
lf7 l7 - lab_f8
- Labels function key F8, if not F8.
lf8 l8 - lab_f9
- Labels function key F9, if not F9.
lf9 l9 - lab_f10
- Labels function key F10, if not F10.
lf10 la - label_format
- Label format.
fln Lf - label_off
- Turn off soft labels.
rmln LF - label_on
- Turn on soft labels.
smln LO - meta_on
- Enables meta mode (8th bit).
smm mm - meta_off
- Disables meta mode.
rmm mo - micro_column_address
- Move N steps from the left.
mhpa ZY - micro_down
- Move 1 step down.
mcud1 ZZ - micro_left
- Move 1 step left.
mcub1 Za - micro_right
- Move 1 step right.
mcuf1 Zb - micro_row_address
- Move N steps from the top.
mvpa Zc - micro_up
- Move 1 step up.
mcuu1 Zd - newline
- Performs new-line function (behaves like carriage return followed by line feed).
nel nw - order_of_pins
- Matches software bits to print-head pins.
porder Ze - orig_colors
- Original colors.
oc oc - orig_pair
- Original color-pair.
op op - pad_char
- Pads character (instead of NULL).
pad pc - parm_dch
- Deletes #1 characters. (G)
dch DC - parm_delete_line
- Deletes #1 lines. (G)
dl DL - parm_down_cursor
- Moves cursor down #1 lines. (G*)
cud DO - parm_down_micro
- Move N steps down. (G*)
mcud Zf - parm_ich
- Inserts #1 blank characters. (G*)
ich IC - parm_index
- Scrolls forward #1 lines. (G)
indn SF - parm_insert_line
- Adds #1 new blank lines. (G*)
il AL - parm_left_cursor
- Moves cursor left #1 spaces. (G)
cub LE - parm_left_micro
- Move N steps left.
mcub Zg - parm_right_cursor
- Moves cursor right #1 spaces. (G*)
cuf RI - parm_right_micro
- Move N steps right.
mcuf Zh - parm_rindex
- Scrolls backward #1 lines. (G)
rin SR - parm_up_cursor
- Moves cursor up #1 lines. (G*)
cuu UP - parm_up_micro
- Move N steps up.
mcuu Zi - pkey_key
- Programs function key #1 to type string #2.
pfkey pk - pkey_local
- Programs function key #1 to execute string #2.
pfloc pl - pkey_xmit
- Programs function key #1 to transmit string #2.
pfx px - plab_norm
- Program label #1 to show string #2.
pln pn - print_screen
- Prints contents of the screen.
mc0 ps - prtr_non
- Enables the printer for #1 bytes.
mc5p pO - prtr_off
- Disables the printer.
mc4 pf - prtr_on
- Enables the printer.
mc5 po - pulse
- Select pulse dialing.
pulse PU - quick_dial
- Dial phone number #1, without progress detection.
qdial QD - remove_clock
- Remove time-of-day clock.
rmclk RC - repeat_char
- Repeats #1 character #2 times. (G*)
rep rp - req_for_input
- Send next input char (for pty's).
rfi RF - reset_1string
- Resets terminal to known modes.
rs1 r1 - reset_2string
- Resets terminal to known modes.
rs2 r2 - reset_3string
- Resets terminal to known modes.
rs3 r3 - reset_file
- Identifies the file containing reset string.
rf rf - restore_cursor
- Restores cursor to position of last sc (save_cursor).
rc rc - row_address
- Positions cursor to an absolute vertical position (set row). (G)
vpa cv - save_cursor
- Saves cursor position.
sc sc - scroll_forward
- Scrolls text up.
ind sf - scroll_reverse
- Scrolls text down.
ri sr - select_char_set
- Select character set.
scs Zj - set_attributes
- Defines the video attributes. (G) #1-#9
sgr sa - set_background
- Set background color.
setb Sb - set_bottom_margin
- Set soft bottojm margin at current line.
smgb Zk - set_bottom_margin_parm
- Set soft bottom margin.
smgbp Zl - set_clock
- Set time-of-day clock.
sclk SC - set_color_pair
- Set color pair.
scp sp - set_foreground
- Set foreground color.
setf Sf - set_left_margin
- Set soft left margin.
smgl ML - set_left_margin_parm
- Set soft left margin.
smglp Zm - set_right_margin
- Set soft right margin.
smgr MR - set_right_margin_parm
- Set soft right margin.
smgrp Zn - set_tab
- Sets a tab in every row of the current column.
hts st - set_top_margin
- Set top margin at current line.
smgt Zo - set_top_margin_parm
- Set soft top margin.
smgtp Zp - set_window
- Indicates current window is lines #1-#2, columns #3-#4. (G)
wind wi - start_bit_image
- Start printing bit-image graphics.
sbim Zq - start_char_set_def
- Start definition of a character set.
scsd Zr - stop_bit_image
- End printing bit image graphics.
rbim Zs - stop_char_set_def
- End definition of a character set.
rcsd Zt - subscript_characters
- List of charcters that can appear in subscript.
subcs Zu - superscript_characters
- List of characters that can appear in superscript.
supcs Zv - tab
- Tabs to next 8-space hardware tab stop.
ht ta - these_cause_cr
- Printing any of these characters cause a carrige return.
docr Zw - tone
- Select touch-tone dialing.
tone TO - to_status_line
- Moves to status line, column #1. (G)
tsl ts - underline_char
- Underscores one character and moves beyond it.
uc uc - up_half_line
- Indicates superscript (reverse 1/2 line-feed)
hu hu - user0
- User string 0.
u0 u0 - user1
- User string 1.
u1 u1 - user2
- User string 2.
u2 u2 - user3
- User string 3.
u3 u3 - user4
- User string 4.
u4 u4 - user5
- User string 5.
u5 u5 - user6
- User string 6.
u6 u6 - user7
- User string 7.
u7 u7 - user8
- User string 8.
u8 u8 - user9
- User string 9.
u9 u9 - wait_tone
- Wait for dial tone.
wiat WA - xoff_character
- X-off character.
xoffc XF - xon_character
- X-on character.
xonc XN - zero_motion
- No motion for the subsequent character.
zerom Zx
Preparing Descriptions
You can create a terminal description by copying and then modifying the description of a similar terminal. You can check the accuracy of your partial descriptions with the vi editor. Some terminals may reveal bugs in the vi editor as well as deficiencies in the ability of the terminfo database to provide a terminal description.
To test a new terminal description, set the TERMINFO environment variable to the path name of the directory containing the compiled description on which you are working. Programs then check that directory instead of the /usr/share/lib/terminfo directory.
To test for correct padding (if known), do the following:
- Edit the /etc/passwd file at 9600 baud.
- Delete about 16 lines from the middle of the screen.
- Press the u key several times quickly. If the terminal fails to display the result properly, more padding is usually needed. You can perform a similar test for insert character.Note: Excessive padding slows down the terminal.
Basic Capabilities
This section describes some basic terminal capabilities. If a terminal supports one of these capabilities, the terminal's terminfo source file entry indicates it. The following list is a list of basic capabilities:
Item | Description |
---|---|
am | Indicates that the cursor moves to the beginning of the next line when it reaches the right margin. This capability also indicates whether the cursor can move beyond the bottom right corner of the screen. |
bel | Produces an audible signal (such as a bell or a beep). |
bw | Indicates that a backspace from the left edge of the terminal moves the cursor to the last column of the previous row. |
clear | Clears the screen, leaving the cursor in the home position. |
cols | Specifies the number of columns on each line for the terminal. |
cr | Moves the cursor to the left edge of the current row. This code is usually carriage return (Ctrl-M). |
cub1 | Moves the cursor one space to the left, such as backspace. |
cuf1 | Moves the cursor to the right one space. |
cuu1 | Moves the cursor up one space. |
cud1 | Move the cursor down one space. |
hc | Specifies a printing terminal with no softcopy unit. You should also specify the os capability. |
ind | Scrolls text up. |
lf | Specifies a line-feed. |
lines | Specifies the number of lines on a cathode ray tube (CRT) terminal. |
nel | Specifies a newline. The terminal behaves as if it received a carriage return followed by a line feed. |
os | Indicates that when a character is displayed or printed in a position already occupied by another character, the terminal overstrikes the existing character, rather than replacing it with the new character. The os capability applies to storage scope, printing, and APL terminals. |
ri | Scrolls text down. |
If the LINES and COLUMNS environment variables are set, these variables override the values in the terminfo database.
The local cursor motions encoded in the terminfo database files are undefined at the left and top edges of a CRT terminal. Programs should never attempt to backspace around the left edge (unless the bw string is given) or to go up locally off the top.
To scroll text up, a program should go to the bottom left corner of the screen and send the index string. To scroll text down, a program goes to the top left corner of the screen and sends the reverse index string. The index string is specified by the ind capability and the reverse index string is specified by the ri capability. The index string and the reverse index string are undefined when not on their respective corners of the screen.
The am capability determines whether the cursor sticks at the right edge of the screen when text is output, but this does not necessarily apply when the cursor is moved to the right (the cuf1 capability) from the last column. A terminal has local motion from the left edge only if the bw capability is defined. The cursor then goes to the right edge of the previous row when moved to the left (the cub1 capability) from the left edge. If the terminal does not have the bw capability, the effect is undefined, which is useful for drawing a box around the edge of the screen, for example.
A terminal has switch-selectable automatic margins if the am capability is specified. If the terminal has a command that moves to the first column of the next line, you can define the nel (new-line) capability. It does not matter whether the command clears the remainder of the current line. Therefore, if the terminal has no cr and lf, a working nel can still be crafted out of one or both of them.
33 | tty33 | tty | Model 33 Teletype
bel=^G, cols#72, cr=^M, cud1=^J, hc, ind=^J, os, xon,
xxxx | x | xxxxxxxx,
am, bel=^G, clear=^Z, cols#80, cr=^M, cub1=^H, cud1=^J,
ind=^J, lines#24,
Parameterized Strings
Cursor-addressing and other strings requiring parameters are described by parameterized string capabilities. These strings have escape sequences similar to the printf %x format. For example, to address the cursor, you specify the cup capability using the row and column parameters.
The parameterized capabilities include:
Item | Description |
---|---|
cub1 | Backspaces the cursor one space. |
cup | Addresses the cursor using the row and column parameters. Rows and columns are numbered starting with 0 and refer to the physical screen visible to the user, not to memory. |
hpa and vpa | Indicates the cursor has row or column absolute cursor addressing:
horizontal position absolute (hpa) or vertical absolute (vpa).
Sometimes the hpa and vpa capabilities are shorter than the more general two-parameter sequence and you can use them in preference to the cup capability. Parameterized local motions (such as, a move of n spaces to the right) are defined with the cud, cub, cuf, and cuu capabilities, with a single parameter indicating how many spaces to move. These capabilities are primarily useful if the terminal does not have cup capability. |
indn and rin | Scrolls text. These are parameterized versions of the basic ind and ri capabilities. The n value is a number of lines. |
mrcup | Indicates the terminal has memory-relative cursor addressing. |
The parameter mechanism uses a stack and has special % (percent sign) codes to manipulate the stack. Typically, a sequence pushes one of the parameters onto the stack and then prints it in some format. Often, more complex operations are necessary. The encodings have the following meanings:
Item | Description |
---|---|
%% | Outputs a % (percent sign). |
%[ [:] Flags] [Width [.Precision] ] [doxXs] | As in the printf command, flags are the [- + # ] and space. |
%d | Prints pop() as in the printf command (numeric string from stack). |
%2d | Prints pop() like %2d (minimum 2 digits output from stack). |
%3d | Prints pop() like %3d (minimum 3 digits output from stack). |
%02d | Prints as in the printf command (2 digits output). |
%03d | Prints as in the printf command (3 digits output). |
%c | Prints pop() gives %c (character output from stack). |
%s | Prints pop() gives %s (string output from stack). |
%p[i] | Pushes the ith parameter onto the stack where i is a number between 1 and 9. |
%P[a-z] | Sets variable [a-z] to pop() (variable output from stack). |
%g[a-z] | Gets variable [a-z] and pushes it onto the stack. |
%'c' | Character constant c. |
%{nn} | Integer constant nn. |
%l | Push strlen (pop( )) |
%+ %- %* %/ %m | Arithmetic operators (%m is modulus): push (pop() operation pop()). |
%& %| %^ | Bit operations: push (pop() operation pop()). |
%= %> %< | Logical operations: push (pop() operation pop()). |
%! %~ | Unary operations: push (operation pop()). |
%i | Add 1 to first two parameters (for ANSI terminals). |
%?expr %t thenpart %e elsepart %; | If-then-else. The %e elsepart is optional.
You can make an else-if construct as with Algol 68 in the following
example, where ci denotes conditions and bi bodies.
|
Binary operations are in postfix form with the operands in the usual order. That is, to get x - 5 use %gx%{5}%-.
If you use the - (minus sign) flag with %[doxXs], then you must place a colon between the % (percent sign) and the - (minus sign) to differentiate the flag from the %- binary operation, for example, %:-16.16s.
Consider a terminal that needs to be sent \E&a12c03Y padded for 6 milliseconds to get to row 3 and column 12. Here the order of the rows and columns is inverted, and the row and column are zero-padded as two digits. Thus, the cup capability of this terminal is cup=\E&a%p2%2.2dc%p1%2.2dY$<6>.
A final example is a terminal that uses row and column offset by a blank character: cup=\E=%p1%'\s'%+%c%p2'\s'%+%c. After sending \E=, this operation pushes the first parameter, pushes the ASCII value for a space (32), adds them (pushing the sum on the stack in place of the two previous values), and outputs that value as a character. Then the same is done for the second parameter. More complex arithmetic is possible using the stack.
Cursor Motions
The top left corner of the screen is the home position. If the terminal has a fast way to get the cursor to the home position, specify the home capability. Specify, a fast way of getting to the bottom left corner with the ll capability. This method may involve going up (cuu1) from the home position, but a program should never do this itself (unless ll does) because the effect of moving up from the home position is not certain.
If the terminal has row or column absolute-cursor addressing, you should specify the single hpa capability (horizontal position above) and the vpa capability (vertical position absolute). Sometimes these are shorter than the more general two parameter sequence and you can use them instead of the cup capability.
If the terminal has parameterized local motions for example, it is capable of moving the cursor n spaces right, you can specify the cud, cub, cuf, and cuu capabilities with a single parameter indicating how many spaces to move. These capabilities are useful if the terminal does not have the cup capability.
Area Clears
The following capabilities clear large areas of the terminal:
Item | Description |
---|---|
ed | Clears from the current position to the end of the display. This is defined only from the first column of a line. (Thus, it can be simulated by a request to delete a large number of lines, if a true ed is not available.) |
el | Clears from the current cursor position to the end of the line without moving the cursor. |
el1 | Clears from the beginning of the line to the current position, inclusive. The cursor is not moved. |
Scrolling
The following insert-line and delete-line capabilities are used to indicate a terminal can:
Item | Description |
---|---|
csr | Change the scrolling region. This capability takes two parameters: the top and bottom lines of the scrolling region. The top line of the screen is 0. After using this capability, the cursor position is undefined. See the sc and rc capabilities in this section. |
da | Retain the display above the screen. If a line is deleted or the screen is scrolled, non-blank lines can be brought in at the top. This capability is usually defined for multipage terminals. |
db | Retain the display below the screen. If a line is deleted or the screen is reverse scrolled, the terminal can bring the non-blank lines at the bottom. This capability is usually defined for multipage terminals. |
dl1 | Delete the line the cursor is on. This is done only from the first position on the line to be deleted. Additionally, the dl capability takes a single parameter indicating the number of lines to be deleted. |
il1 | Create a new blank line before the line where the cursor is currently located and scrolls the rest of the screen down. This is done only from the first position of a line. The cursor then appears on the newly blank line. Additionally, the il capability can take a single parameter indicating the number of lines to insert. |
ind | Index or scroll forward. A terminal with this capability can shift the display up one line by deleting the top line and adding a blank line at the bottom. |
indn | Specify the number of lines to scroll forward. This capability has meaning only if the ind capability is also defined. |
rc | Restore the cursor. This capability is useful with the csr and sc capabilities. |
ri | Reverse scrolling. With this capability, the terminal can shift the screen down by deleting the bottom line and adding a blank line at the top. |
rin | Specify the number of lines to reverse scroll. This capability has meaning only if the ri capability also is defined. |
sc | Save the cursor. If defined, you can use the sc capability to save the cursor before using the csr capability. Saving the cursor is necessary because the cursor position is undefined after you use the csr capability. Use the rc capability to restore the cursor to the position it held before you used the csr capability. |
wind | Indicates the terminal has the ability to define a window as part of memory. This is a parameterized string capability with four parameters: the starting and ending lines in memory and the starting and ending columns in memory, in that order. |
A terminal that has the csr capability can scroll part of its screen while leaving other lines above and below the region untouched. A forward scroll applied to a region deletes the top of the region, shifts, and adds a line to the bottom of the region. When finished with the scrolling region, you should use the csr capability to restore the scrolling region to the full screen.
Terminals that have csr defined have a destructive scrolling region. Once a line is scrolled off the screen, the terminal cannot retrieve it. A terminal with a non-destructive scrolling region can restore scrolled lines by reversing the scrolling. Unless the ind, ri, indn, rin, dl, and dl1 all simulate destructive scrolling, do not specify the csr capability if the terminal has non-destructive scrolling regions.
On multipage terminals, scrolling can put a line onto another page and scrolling in the opposite direction brings the line back. Similarly, deleting a line can cause a line from another page to appear on the screen. Multipage terminals should have the da and db capabilities defined so that program that use scrolling can adjust their behavior.
A few terminals can define a window as part of memory. For these types of terminals, all clearing, deletion, insertion, and wrapping commands affect the area in memory where the window is defined.
Insert or Delete Character
Generally, terminals handle insert/delete character operations in one of two ways. The most common insert/delete character operations affect only the characters on the current line and shift characters to the right and off the line. Other terminals make a distinctions between typed and untyped blanks on the screen. When inserting a character, the displayed data is shifted and an untyped blank is eliminated. Once all the untyped blanks are eliminated, the displayed data wraps to the next line if you continue to insert characters. When deleting a character, an untyped blank is added to the line to compensate for the deleted character.
Generally, terminals insert/delete characters in one-line mode or multiline mode. The two types of terminals also handle untyped spaces differently. One-line mode is the most common mode. In one-line mode, insert/delete character operations affect only the characters on the current line. Insertions shift characters to the right and off the line.
Multiline mode terminals can affect more than one line. In this mode, the terminal makes a distinction between typed and untyped blanks on the screen. Inserting a character on a multiline mode terminal shifts the displayed data and eliminates untyped blanks. If all the untyped blanks are eliminated and you continue to insert characters, the display wraps to the next line. When deleting a character, multiline terminals add an untyped blank to the line to compensate for the deleted character.
Determining Your Terminal's Type
Clearing a screen and then typing text separated by cursor motions helps you determine the type of insert/delete operations your terminal performs. Clear the screen, then proceed as follows:
- Type abc def using local cursor movements, not spaces, between the abc and the def.
- Position the cursor before the abc.
- Place the terminal in insert mode.
- Type a line of text. If your typing causes the abc def characters
to shift right and exit the right side of the display, the terminal
does not distinguish between blanks and untyped positions.
If the abc moves to positions to the immediate left of the def and the characters move to the right on the line, around the end, and to the next line, the terminal is the second type. This is described by the in capability, which signifies insert null.
Although these two attributes (one-line versus multiline insert mode, and different treatment of untyped spaces) are logically separate, there are no known terminals whose insert mode cannot be described with a single attribute.
Insert or Delete Character Capabilities
The terminfo database describes terminals that have an insert mode as well as terminals that send a simple sequence to open a blank position on the current line. The following are used to describe insert/delete character capabilities:
Item | Description |
---|---|
dch1 | Deletes a single character. The dch capability with one parameter, n, deletes n characters. |
ech | Replaces the specified number of characters, starting at the cursor, with blanks. The cursor position remains unchanged. |
ich1 | Opens a space in a line for a character to be inserted. This sequence precedes the actual character insertion. Terminals with a true insert mode would not use this capability. |
ip | Indicates post-padding needed. This is given as a number of milliseconds. Any other sequence that may need to be sent after inserting a single character can be given in this capability. |
mir | Allows cursor movement while in insert mode. It is sometimes necessary to move the cursor while in insert mode to delete characters on the same line. Some terminals may not have this capability due to their handling of insert mode. |
rmdc | Exits delete mode. |
rmir | Ends insert mode. |
rmp | Indicates that padding is necessary between characters typed while not in insert mode. This capability is used in replace mode. |
smdc | Enters delete mode. |
smir | Begins insert mode. |
If you are creating a terminfo description for a terminal that requires an insert mode and also needs a special code to precede each inserted character, then define the smir/rmr, and ich1 capabilities. The ich capability, with the one parameter n, opens up n spaces so that n characters can be inserted.
Highlighting, Underlining, and Visual Bells
If your terminal has one or more kinds of display attributes, such as highlighting, underlining, and visual bells, you can present these in a number of ways. Highlighting, such as standout mode, presents a high-contrast, easy-to-read format that adds emphasis to error messages and other important messages. Underlining is another method to focus attention on a particular portion of the terminal. Visual bells include methods such as flashing the screen. The following capabilities describe highlighting, underlining, and visual bells:
- blink
- Indicates terminal has blink highlighting mode.
- bold
- Indicates terminal has extra bright highlighting mode.
- civis
- Makes the cursor invisible.
- cnorm
- Displays a normal cursor. This capability reverses the effects of the civis and cvvis capabilities.
- cvvis
- Makes the cursor more visible than normal when it is not on the bottom line.
- dim
- Indicates the terminal has half-bright highlighting modes.
- eo
- Indicates that blanks erase overstrikes.
- enacs
- Specifies a command string that enables alternate character set mode. Some terminals cannot enter alternate character set mode without first receiving a specific command. The enacs capability defines the command.
- flash
- Indicates the terminal has a way of making the screen flash (as a bell replacement) for errors, without moving the cursor.
- invis
- Indicates the terminal has blanking or invisible-text highlighting modes.
- msgr
- Indicates it is safe to move the cursor in standout mode. Otherwise, programs using standout mode should exit this mode before moving the cursor or sending a new-line. Some terminals automatically leave standout mode when they move to a new line or when the cursor is addressed.
- nrrmc
- Indicates that the smcup sequence does not restore the screen after a rmcup sequence is output. This means that you cannot restore the screen to the state prior to outputting rmcup.
- os
- Indicates the terminal can overstrike an existing character without erasing the original. Overstriking creates a compound character.
- prot
- Indicates the terminal has protected text mode. This means the terminal protects the text from overwriting or erasing. The method of protection is terminal dependent.
- rev
- Indicates the terminal has reverse-video mode.
- rmacs
- Exits the alternate character set mode.
- rmso
- Exits standout mode.
- rmul
- Ends underlining.
- sgr
- Provides a sequence to set arbitrary combinations of attributes.
The sgr capability can set nine attributes. In order, these
attributes are the following:
- standout
- underline
- blink
- dim
- bold
- blank
- protect
- alternate character set
To turn a mode on, set it to a nonzero value. To turn a mode off, set it to 0. The sgr capability can only support those modes for which separate capabilities already exist on the terminal.
- sgr0
- Turns of all the special modes, including the alternate character set.
- smacs
- Enters the alternate character set mode.
- smcup and rmcup
- Indicate the terminal must be in a special mode when running
a program that uses any of the highlighting, underlining, or visual
bell capabilities. The smcup capability enters this mode, and
the rmcup capability exits this mode.
This need arises, for example, with terminals having more than one page of memory. If the terminal has only memory-relative cursor addressing, and not screen-relative cursor addressing, a screen-sized window must be fixed into the terminal for cursor addressing to work properly. This is also used when the smcup capability sets the command character to be used by the terminfo database file.
- smso
- Enters standout mode.
- smul
- Begins underlining.
- uc
- Underlines the current character and moves the cursor one space to the right.
- ul
- Indicates the terminal correctly generates underlined characters (with no special codes needed), even though it does not overstrike.
- xmc
- Indicates the number of blanks left if the capability to enter or exit standout mode leaves blank spaces on the screen.
Highlighting, Overstriking, and Underlining
You should choose one display method as standout mode and use it to highlight error messages and other kinds of text to which you want to draw attention. For example, you could choose reverse-video plus half-bright or reverse-video alone. The sequences to enter and exit standout mode are given by the smso and rmso capabilities. If the code to change into or out of standout mode leaves one or even two blank spaces on the screen, then xmc should be given to tell how many spaces are left.
You should specify the ul boolean capability if your terminal generates underlined characters by using the underline character with no special codes. You should specify this capability even if the terminal does not otherwise overstrike characters. For terminals where a character overstriking another leaves both characters on the screen, specify the os capability. If the terminal can erase overstrikes with a blank, then indicate this by specifying the eo capability.
Example of Using the sgr Capability
The following example demonstrates how to use the sgr capability to turn on various modes. Assume that you must define a terminal that requires the following escape sequences to turn on various modes:
Terminfo Parameter | Mode | Escape Sequence |
---|---|---|
none | \E[0m | |
p1 | standout | \E[0;4;7m |
p2 | underline | \E[0;3m |
p3 | reverse | \E[0;4m |
p4 | blink | \E[0;5m |
p5 | dim | \E[0;7m |
p6 | bold | \E[0;3:4m |
p7 | invis | \E[0;8m |
p8 | protect | not available |
p9 | altcharset | ^O (off) ^N (on) |
You can simulate some modes by combining others. In this example, the standout attribute escape sequence is a combination of the reverse and dim sequences. Also, in the example the bold sequence is a combination of the reverse and underline sequences. To combine such modes as underline and blink, the sequence to use would be \E[0;3;5m.
You cannot simulate certain modes by combining others. For example, you cannot simulate the protect mode. In this example, the system ignores the p8 parameter. The altcharset mode is different in that it is either ^O or ^N, depending on whether the alternate character mode set is on or off. If all modes were turned on, the sequence would appear as \E[0;3;4;5;7;8m^N.
Some sequences are outputted for one or more modes. For example, the ;3 is outputted when either the p2 parameter or p6 parameter is true. If you write out the above sequences along with their dependencies, the result is the following;
Sequence | When To Output | terminfo Translation |
---|---|---|
\E[0 | always | \E[0 |
;3 | if p2 or p6 | %?%p2%p6%|%t;3%; |
;4 | if p1 or p3 or p6 | %?%p1%p3%|%p6%|%t;4%; |
;5 | if p4 | %?%p4%t;5%; |
;7 | if p1 or p5 | %?%p1%p5%|%t;7%; |
;8 | if p7 | %?%p1%t;8%; |
m | always | m |
^N or ^O | if p9 ^N, else ^O | %?%p9%t^N%e^O%; |
The final result would produce a sgr sequence that appears as follows:
sgr=\E[0%?%p2%p6%|%t;3%;%?%p1%p3%|%p6%|%t;4%;%?%p4%t;5;%?%p1%p5%|
%t;7%;%?%p1%t;8%;m%?%p9%t^N%e^O%;,
Keypad
If the terminal has a keypad that transmits codes when the keys are pressed, you can define this in the terminfo entry for the terminal. It is not possible to handle terminals where the keypad only works in local mode. If the keypad can be set to transmit or not transmit, give these codes as smkx and rmkx. Otherwise, the keypad is assumed to always transmit.
To define the codes sent by the left-arrow, right-arrow, up-arrow, down-arrow, and home keys, use the kcub1, kcuf1, kcud1, and khome capabilities, respectively. If there are function keys such as F0, F1, ..., F63, the codes they send can be given as the kf0, kf1, ..., kf63 capabilities. If the first eleven keys have labels other than the default F0 through F10, you can specify the labels with the lf0, lf1, ..., lf10 capabilities. The codes transmitted by certain other special keys can be defined with:
Item | Description |
---|---|
kbs | Backspace key. |
kclr | Clear-screen or erase key. |
kctab | Clear the tab stop in this column. |
kdch1 | Delete-character key. |
kdl1 | Delete-line key. |
ked | Clear to end of screen. |
kel | Clear to end of line. |
khts | Set a tab stop in this column. |
kich1 | Insert character or enter insert mode. |
kil1 | Insert line. |
kind | Scroll forward or down, or both. |
kll | Home down key (home is the lower left corner of the display, in this instance). |
krmir | Exit insert mode. |
knp | Next page. |
kpp | Previous page. |
ktbc | Clear-all-tabs key. |
ri | Scroll backward or up, or both. |
In addition, if the keypad has a three-by-three array of keys including the four arrow keys, specify the other five keys as ka1, ka3, kb2 kc1, and kc3. These keys are useful when you need the effects of a three-by-three directional pad.
Strings that program function keys can be given as the pfkey, pfloc, and pfx capabilities. A string to program the soft screen labels can be given as pln. Each of these strings takes two parameters: the function key number to program (from 0 to 10) and the string with which to program it. Function key numbers out of this range can program undefined keys in a terminal-dependent manner. The capabilities differ in that pfkey causes pressing a given key to be the same as the user typing the given string, pfloc causes the string to be executed by the terminal in local mode, and pfx causes the string to be transmitted to the computer. The capabilities nlab, lw, and lh define the number of soft labels and the width and height. Use smln and rmln to specify the commands for turning on and off soft labels. smln is normally output after one or more pln sequences to ensure the change becomes visible.
Tabs and Initialization
If the terminal has hardware tabs, you can use ht capability (usually Ctrl-I) to specify the command to advance to the next tab stop. To specify the command to move left toward the previous tab stop, use the cbt capability. By convention, if the terminal modes indicate that operating system is expanding the tabs rather than sending them to the terminal, programs should not use the ht or cbt capabilities even if they are present, since the user may not have the tab stops properly set.
If the terminal has hardware tabs that are initially set every n spaces when the terminal is powered up, its terminfo description should define the numeric capability it to show the number of spaces the tabs are set to. Normally, the tput init command uses the it parameter to determine whether to set the mode for hardware tab expansion and whether to set the tab stops. If the terminal has tab stops that can be saved in nonvolatile memory, the terminfo description can assume that they are properly set.
Other, similar capabilities include the is1, is2, and is3 initialization strings for the terminal; the iprog capability that specifies the terminal's initialization program, and the if capability that identifies the name of a file containing long initialization strings. These strings are expected to set the terminal into modes consistent with the rest of the terminfo file description. They are normally sent to the terminal by the tput init command each time the user logs in. When the user logs in, the system does the following:
- Runs the iprog program.
- Prints is1.
- Print is2.
- Sets the margins using the mgc, smgl, and smgr capabilities.
- Sets the tabs using tbc and hts capabilities.
- Prints the if file.
- Prints is3.
You can set up special terminal modes without duplicating strings by putting the common sequences in the is2 capability and special cases in the is1 and is3 capabilities. To specify sequences that do a harder reset from a totally unknown state, specify the rs1, rs2, rs3, and rf capabilities that are the same as is1, is2, is3, and the if capabilities.
A few terminals use the if and rf files. However, the recommended method is to use the initialization and reset strings. These strings are output by the tput reset command. This command is used when the terminal starts behaving strangely or is not responding at all. Commands are normally placed in the rs1, rs2, rs3 and rf capabilities only if they produce annoying effects on the screen and are not necessary when logging in. For example, the command to set the terminal into 80-column mode would normally be part of is2, but it causes an annoying screen behavior and is not necessary since most terminals initialize in 80-column mode.
If there are commands to set and clear tab stops, specify them using the tbc (clear all tab stops) and the hts (set a tab stop in the current column of every row) capabilities. If a more complex sequence is needed to set the tabs, the place the sequence in the is2 or the if capability.
The mgc capability can clear any margin. For more information about how to set and clear margins, see Margins.
Miscellaneous Strings
If the terminal requires a character other than a null character as a pad, then specify the pad string. Only the first character of the pad string is used. If a terminal does not have a pad character, specify the npc capability.
If the terminal can move up or down half a line, define the hu (half-line up) and hd (half-line down) capabilities. These capabilities are primarily useful for superscripts and subscripts on hardcopy terminals. If a hardcopy terminal can eject to the next page (form feed), specify the as ff (usually Ctrl-L) capability.
If there is a command to repeat a given character a given number of times (to save time transmitting a large number of identical characters), this can be indicated with the rep parameterized string. The first parameter is the character to be repeated, and the second is the number of times to repeat it. Thus following:
tparm(repeat_char,'x',10)
is the same as
xxxxxxxxxx
If the terminal has a settable command character, such as the Tektronix 4025, indicate this with the cmdch capability. A prototype command character is chosen that is used in all capabilities. This character is given in the cmdch capability to identify it. On some UNIX systems, if the CC environment variable exists, all occurrences of the prototype character are replaced with the character in the CC variable.
Terminal descriptions that do not represent a specific kind of known terminal such as switch, dialup, patch, and network, should include the gn (generic) capability. This capability allows programs to return errors if they cannot talk to the terminal. The gn capability does not apply to virtual terminal descriptions for which the escape sequences are known. If a terminal is supported by the UNIX system virtual terminal protocol, use the vt capability to define its terminal number.
If a terminal uses xon/xoff handshaking for the flow control, its description should include the xon capability. You should still include padding information as well so that routines can make better decisions about costs. However, actual pad characters are not transmitted. To specify sequences to turn on and off xon/xoff handshaking, use the smxon and rmxon capabilities. If the characters used for handshaking are not ^S and ^Q, use the xonc and xoffc capabilities to define them.
If a terminal has a meta key that acts as a shift key to set the eighth bit of any character transmitted, identify the key with the km capability. Otherwise, software assumes that the eighth bit is parity, and it will usually be cleared. If strings exist to turn this meta mode on and off, they can be given as the smm and rmm capabilities.
If a terminal has more lines of memory than fit on the screen at once, use the lm capability to define the number of lines of memory. A value of lm#0 indicates that the number of lines is not fixed, but that there are still more lines of memory than fit on the screen.
Media copy strings that control an auxiliary printer connected to the terminal are identified with the following capabilities:
Item | Description |
---|---|
mc0 | Prints the contents of the screen |
mc4 | Turns off the printer, and |
mc5 | Turns on the printer. When the printer is on, all text sent to the terminal is sent to the printer. It is undefined whether the text is also displayed on the terminal screen when the printer is on. |
mc5p | Leaves the printer on for a specified number of characters and then turns the printer off. The parameter passed to mc5p should not exceed 255. |
If the terminal screen does not display the text when the printer is on, specify the mc5i capability to signify a silent printer. All text, including the mc4, is transparently passed to the printer while an mc5p is in effect.
Status Lines
You can use the terminfo entry to indicate that the terminal has an extra status line that is not normally used by software,. If the status line is viewed as an extra line below the bottom line, into which the cursor can be addressed normally, the hs capability should be given. Special strings to go to the beginning of the status line and to return from the status line can be given as the tsl and fsl capabilities, respectively. (The fsl must leave the cursor position in the same place it was before the tsl. If necessary, the sc string and the rc string can be included in tsl and fsl to get this effect.) The tsl capability takes one parameter, which is the column number of the status line to which the cursor is to be moved.
If escape sequences and other special commands, such as tab, work while in the status line, specify the eslok capability. A string that turns off the status line (or otherwise erases its contents) should be given as dsl. If the terminal has commands to save and restore the position of the cursor, give them as sc and rc capabilities. The status line is normally assumed to be the same width as the rest of the screen, such as cols. If the status line is a different width (possibly because the terminal does not allow an entire line to be loaded), the width, in columns, can be indicated with the wsl numeric parameter.
Line Graphics
If the terminal has a line drawing alternate character set, specify the mapping of glyph to character in the acsc capability. The definition of this string is based on the alternate character set used in the DEC VT100 terminal, extended slightly with some characters from the AT&T4410v1 terminal. Use the following to define the string:
Glyph Name | vt100+ Character |
---|---|
arrow pointing right | + |
arrow pointing left | , |
arrow pointing down | . |
solid square block | 0 |
lantern symbol | I |
arrow pointing up | - |
diamond | ' |
check board (stipple) | a |
degree symbol | f |
plus or minus sign | g |
board of squares | h |
lower right corner | j |
upper right corner | k |
upper left corner | l |
lower left corner | m |
plus | n |
scan line 1 | o |
horizontal line | q |
scan line 9 | s |
left tee | t |
right tee | u |
bottom tee | v |
top tee | w |
vertical line | x |
bullet | ~ |
The best way to describe a new terminal's line graphics set is to add a third column to the above table with the characters for the new terminal that would produce the appropriate glyph when the terminal is in alternate character set mode. For example:
glyph name vt100 tty
character character
upper left corner l R
lower left corner m F
upper right corner k T
lower right corner j G
horizontal line q ,
vertical line x .
Then, you specify the acsc capability by specifying the characters from left to right as follows:
acsc=lRmFkTjGq\,x.
Color Manipulation
There are two methods of color manipulation, the HP method and the Tektronix method. Most existing color terminals belong to one of these two classes. The Tektronix method uses a set of N predefined colors (usually 8) from which a user can select current foreground and background colors. Thus, the terminal can support up to N colors mixed into N*N color-pairs that are displayed on the screen at the same time.
The HP method restricts the user from both defining the foreground independently of the background or the background independently of the foreground. Instead, the user must define an entire color-pair at once. Up to M color-pairs, made from 2*M different colors, can be defined this way.
The numeric variables colors and pairs define the number of colors and color-pairs that the terminal can display on the screen at one time. If a terminal can change the definition of a color, you should specify the ccc capability. To change the definition of a color using the Tektronix method, use the initc capability. This capability requires four parameters: a color number ranging from 0 to colors-1 and three Red, Green, Blue (RGB) values ranging from 0 to 1,000.
To set current foreground and background to a given color, use the setf and setb capabilities. These capabilities require a single parameter that specifies the number of the color. To use the HP method to initialize a color-pair, use the initp capability. This capability requires seven parameters:
- the number of the color-pair in the range of 0 to pairs -1
- three RGB values for the foreground
- three RGB values fro the background
When you use the initc or initp capabilities, be sure you specify the values in the order red, green, blue or hue, lightness, saturation, respectively. To make a color-pair current, use the scp capability. This capability takes one parameter, the number of the color-pair.
Some terminals erase areas of the screen with the current background color. In such cases, define the bce capability. The op capability contains a sequence for setting the foreground and the background colors to what they were at the terminal start-up time. Similarly, the oc capability contains a control sequence for setting all colors or -pairs to the values they had at the terminal start-up time.
Some color terminals substitute color for video attributes. Such video attributes should not be combined with colors. You should pack information about these video attributes into the ncv capability. There is a one-to-one correspondence between the nine least significant bits of that variable and the video attributes. The following table depicts this correspondence:
Attribute | NCV Bit Number |
---|---|
A_STANDOUT | 0 |
A_UNDERLINE | 1 |
A_REVERSE | 2 |
A_BLINK | 3 |
A_DIM | 4 |
A_BOLD | 5 |
A_INVIS | 6 |
A_PROTECT | 7 |
A_ALTCHARSET | 8 |
When a particular video attribute should not be used with colors, the corresponding ncv bit should be set to 1. Otherwise, set the bit to 0. For example, if the terminal uses colors to simulate reverse video and bold, bits 2 and 5 should be set to 1. The resulting values for ncv will be 22.
Special Cases
Some terminals require special support by the terminfo database. These terminals are not deficient. These terminals have hardware that may be slightly different than what the terminfo database expects of most terminals. Some of the special cases are discussed in this section. The programmer's manual for a terminal should provided all the information you need to code a terminfo description for the terminal.
For terminals that do not allow the ~ (tilde) character, use the hz capability.
Descriptions of terminals that ignore a line-feed character immediately after an am wrap should include the xenl capability. Those terminals whose cursor remains on the right-most column until another character is received rather than wrapping immediately upon receiving the right-most character, should also use the xenl capability.
If el capability is required to get rid of standout (instead of merely writing normal text on top of it), then you should specify xhp capability.
Terminals for which tabs change all moved characters into blanks should indicate the xt capability (destructive tabs). This capability is interpreted to mean that it is not possible to position the cursor on top of the pads inserted for standout mode. Instead, it is necessary to erase standout mode using delete and insert line.
A terminal that is unable to correctly transmit the ESC (escape) or Ctrl-C characters should specify the xsb capability, indicating that the F1 key is used for ESC and the F2 key is used for Ctrl-C.
Other specific terminal problems can be corrected by adding more capabilities.
Similar Terminals
term-nl | Terminal smkx@, rmkx@, use=term
defines a terminal that does not have either the smkx or the rmkx capability, and hence does not turn on the function key labels when in visual mode. This is useful for different terminal modes or for different user preferences. You can specify more than one use capability.
Printer Capabilities
The terminfo database allows you to define the capabilities of printers as well as terminals. To find out what capabilities are available for printers as well as for terminals, see the two lists under Terminal Capabilities that the list the capabilities by variable and by capability name.
Rounding Values
Because parameterized string capabilities work only with integer values, we recommend that terminfo designers create strings that expect rounded numeric values. Programmers should always round values to the nearest integer before using them with a parameterized string capability.
Printer Resolution
A printer's resolution is the smallest spacing of characters it can achieve. In general, printers have independent resolution horizontally and vertically. To determine the vertical resolution of a printer, measure the smallest achievable distance between consecutive printing baselines. To determine the horizontal resolution, measure the smallest achievable distance between the left-most edges of consecutive printed, identical, characters.
The terminfo database assumes all printers are capable of printing with a uniform horizontal and vertical resolution. The terminfo database currently interacts with printers as if they print inside a uniform matrix. All characters are printed at fixed positions relative to each cell in the matrix. Furthermore, each cell has the same size given by the smallest horizontal and vertical step sizes dictated by the resolution.
Many printers are capable of proportional printing where the horizontal spacing depends on the size of the last character printed. The terminfo database does not make use of this capability, although it does provide enough capability definitions to allow an application to simulate proportional printing.
A printer must not only be able to print characters as close together as the horizontal and vertical resolutions suggest, but also of moving to a position that is an integral multiple of the smallest distance away from a previous position. Thus, printed characters can be spaced apart a distance that is an integral multiple of the smallest distance, up to the length of width of a single page.
Some printers can have different resolutions depending on different modes. In normal mode, the existing terminfo capabilities are assumed to work on columns and lines, just like a video terminal. For example, the old lines capability specify the length of a page in lines, and the cols capability specifies the width of a page in columns. In micro mode many terminfo capabilities work on increments of lines and columns. With some printers, the micro mode may exist concurrently with normal mode, so that all the capabilities work at the same time.
Specifying Printer Resolution
You can specify a printer's printing resolution with several different capabilities. Each capability specifies distance in a different way. The following capabilities define print resolution:
Capability | Defined as |
---|---|
orhi | steps per inch horizontally |
orvi | steps per inch vertically |
orc | steps per column |
orl | steps per line |
When printing in normal mode, each character printed causes the printer to move to the next column, except in special cases described later. The distance moved is the same as the per-column resolution. Some printers cause an automatic movement to the next line when a character is printed in the rightmost position. The vertical distance moved is the same as the per-line resolution. When printing in micro mode, these distances can be different, and may be zero for some printers. The following specify printer resolution automatic motion after printing:
Capability | Defined as |
---|---|
orc | Steps moved horizontally in normal mode. |
orl | Steps moved vertically in normal mode. |
mcs | Steps moved horizontally in micro mode. |
mls | Steps moved vertically in micro mode. |
Some printers can print wide characters. The distance moved when a wide character is printed in normal mode may be different from when a regular width character is printed. The distance moved when a wide character is printed in micro mode may also be different from when a regular character is printed in micro mode, but the differences are assumed to be related.
If the distance moved for a regular character is the same in normal mode or micro mode (mcs=ocs), then the distance moved for a wide character is also the same in both modes. This does not mean the normal character distance is necessarily the same as the wide character distance, just that the distances do not change with a change from normal to micro mode. Use the widcs capability to specify the printer resolution when the automatic motion after printing a wide character is the same in both normal or micro mode.
If the distance moved for a regular character is different in micro mode from the distance moved in normal mode (mcs<orc), you can assume the micro mode distance is the same for a wide character printed in micro mode. In this case, you use the mcs capability to specify the distance moved. The printer uses the value you specify for both regular and wide characters
A printer may use control sequences to change the number of columns per inch (the character pitch) and to change the number of lines per inch (the line pitch). If these are used, the resolution of the printer changes but the type of change depends on the printer.
Capability | Defined as |
---|---|
cpi | Change character pitch. |
cpix | If set, cpi changes orhi, otherwise the cpi capability changes the orc value. |
lpi | Change line pitch |
lpix | If set, lpi changes the orvi value, otherwise the orl value is changed. |
chr | Changes steps per column. |
cvr | Changes steps per line. |
The cpi and lpi string capabilities have a single argument, the pitch in columns (or characters) and lines per inch, respectively. The chr capability and cvr string capabilities each have a single argument, the number of steps per column and line, respectively.
Using any of the control sequences in these strings implies a change in some of the values of the orc, orhi, orl, and orvi capabilities. Also, the distance moved when a wide character is printed, specified by the widcs capability, changes in relation to the orc value. The distance moved when a character is printed in micro mode, mcs, changes similarly, with one exception: if the distance is 0 or 1, then no change is assumed.
Programs that use the cpi, lpi, chr, or cvr capability should recalculate the printer resolution and should recalculate other values. For more information, see Effect of Changing Printing Resolution .
Vcpi, Vlpi, Vchr, and Vcvr are the arguments used with cpi, lpi, chr, and cvr respectively. The dagger symbol indicates the old value.
Capabilities that Cause Movement
In the following descriptions, movement refers to the motion of the current position. With video terminals this would be the cursor; with some printers this is the carriage position. Other printers have different equivalents. In general, the current position is where a character would be displayed if printed.
The terminfo database has string capabilities for control sequences that cause movement a number of full columns or lines. It also has equivalent string capabilities for control sequences that cause movement a number of small steps. The following are the string capabilities for motion:
Capability | Description |
---|---|
mcub1 | Move 1 step left. |
mcuf1 | Move 1 step right. |
mcuu1 | Move 1 step up. |
mcud1 | Move 1 step down. |
mcub | Move N steps left. |
mcuf | Move N steps right. |
mcuu | Move N steps up. |
mcud | Move N steps down. |
mhpa | Move N steps from the left. |
mvpa | Move N steps from the top. |
The last six strings are each used with a single N argument.
Sometimes the motion is limited to less than the width or length of a page. Also, some printers do not accept absolute motion to the left of the current position. The following capabilities limit motion:
Capability | Description |
---|---|
mjump | Limits the use of mcub1, mcuf1, mcuu1, and mcud1 capabilities. |
maddr | Limits the use of the mhpa and mvpa capabilities. |
xhpa | If set, the hpa and mhpa capabilities are negated. |
xvpa | If set, the vpa and mvpa capabilities are negated. |
If a printer needs to be in micro mode for the motion capabilities to work, you can define a string capability to contain the control sequence to enter and exit micro mode. A boolean is available for those printers where using a carriage return causes an automatic return to normal mode. The following capabilities are related to micro mode behavior:
Capability | Description |
---|---|
smicm | Enter micro mode. |
rmicm | Exit micro mode. |
crxm | Using the key specified by the cr capability exits micro mode. |
The movement made when a character is printed in the rightmost position varies among printers. Some make no movement, some move to the beginning of the next line, others move to the beginning of the same line. The terminfo database has boolean capabilities that description all three cases. The sam capability specifies that the printer automatically moves to the beginning of the same line after the character is printed in the rightmost margin.
Some printers can be put in a mode where the normal direction of motion is reversed. This mode is especially useful when there exists no capabilities for leftward or upward motion, you can build these capabilities from the motion reversal capability and the rightward or downward motion capabilities. It is best to leave it up to an application to build the leftward or upward capabilities, though, and not enter them into to the terminfo database. This allows several reverse motions to be strung together without intervening wasted steps that leave and reenter reverse mode. The following capabilities control entering and exiting reverse modes:
Capability | Description |
---|---|
slm | Reverse sense of horizontal motions. |
rlm | Restore sense of horizontal motions. |
sum | Reverse sense of vertical motions. |
rum | Restore sense of vertical motions. |
The following capabilities affect the screen while the horizontal motions are reversed:
Capability | Description |
---|---|
mcub1 | Move 1 step right. |
mcuf1 | Move 1 step left. |
mcub | Move N steps right. |
mcuf | Move N steps left. |
cub1 | Move 1 column right. |
cuf1 | Move 1 column left. |
cub | Move N columns right. |
cuf | Move N columns left. |
The following capabilities affect the screen while the vertical motions are reversed:
Capability | Description |
---|---|
mcuu1 | Move 1 step down. |
mcud1 | Move 1 step up. |
mcuu | Move N steps down. |
mcud | Move N steps up. |
cuu1 | Move 1 line down. |
cud1 | Move 1 line up |
cuu | Move N lines down. |
cud | Move N lines up. |
The reverse motion mode should not affect the mvpa and mhpa absolute motion capabilities. The reverse vertical motion mode should, however, also reverse the action of the line wrapping that occurs when a character is printed in the right-most position. Thus printers that have the standard terminfo capability am defined should move to the beginning of the previous line when a character is printed on the right-most position and the printer is in reverse-vertical motion mode.
The action when any other motion capabilities are used in reverse motion modes is not defined. Thus, programs must exit reverse motion modes before using other motion capabilities.
Two miscellaneous capabilities complete the list of new motion capabilities, the docr and the zerom capability. The docr capability provides a list of control characters that cause a carriage return. This capability is useful for printers that move the current position to the beginning of a line when certain control characters, like line-feed or form-feed are used. The zerom capability prevents automatic motion after printing a single character. This capability suspends the motion that normally occurs after printing a character.
Margins
The terminfo database provides two strings for setting margins on terminals: one for the left and one for the right margin. Printers, however, have two additional margins for the top and bottom margins of each page. Furthermore, some printers do not require using motion strings to move the current position to a margin and fixing the margin there, as with existing capabilities, but require the specification of where a margin should be regardless of the current position. Therefore, the terminfo database offers six additional strings for defining margins with printers. The following capabilities affect margins:
Capability | Definition |
---|---|
smgl | Set left margin at the current column. |
smgr | Set right margin at the current column. |
smgb | Set the soft bottom margin at the current line. |
smgt | Set the soft top margin at the current line. |
smgbp | Set the soft bottom margin at line N. |
smglp | Set the soft left margin at column N. |
smgrp | Set the soft right margin at column N. |
smgtp | Set soft top margin at line N. |
All margins can be cleared with the mgc capability.
Shadows, Italics, Wide Characters, Superscripts, and Subscripts
Five new sets of strings are used to describe the capabilities that printers have of enhancing printed text. The following define enhanced printing capabilities:
Capability | Definition |
---|---|
sshm | Enter shadow-printing mode. |
rshm | Exit shadow-printing mode. |
sitm | Enter italicizing mode. |
ritm | Exit italicizing mode. |
swidm | Enter wide-character mode. |
rwidm | Exit wide-character mode. |
ssupm | Enter superscript mode. |
rsupm | Exit superscript mode. |
supcs | List of characters available as superscripts. |
ssubm | Enter subscript mode. |
rsubm | Exit subscript mode. |
subcs | List of characters available as subscripts. |
If a printer requires the sshm control sequence before every character to be shadow-printed, the rshm string is left blank. Thus, programs that find a control sequence in sshm but none in shadow printing mode should use the control sequence specified by the sshm capability before every character to be shadow printed. Otherwise, the control sequence should be used once before the set of characters to be shadow-printed, followed by exiting shadow-printing mode.
The terminfo database also has a capability for printing emboldened text, the bold capability. While shadow printing and emboldened printing are similar in that they darken the text, many printers produce these two types of print in slightly different ways. Generally emboldened printing is done by overstriking the same character one or more times. Shadow printing likewise usually involves overstriking, but with a slight movement up and/or to the side so that the character is fatter.
It is assumed that enhanced printing modes are independent modes, so that it would be possible, for instance, to shadow print italicized subscripts.
As mentioned earlier, the amount of motion automatically made after printing a wide character should be given in the widcs capability.
If only a subset of the printable ASCII characters can be printed as superscripts or subscripts, they should be listed in the supcs or subcs capabilities, respectively. If the ssupm or ssubm strings contain control sequences, but the corresponding supcs or subcs strings are empty, it is assumed that all printable ASCII characters are available as superscripts or subscripts.
Automatic motion made after printing a superscript or subscript is assumed to be the same as for regular characters. For example, printing any of the following result in equivalent motion:
Bi Bi Bi
The boolean capability msgr describes whether an application can use motion control sequences while in standout mode. This capability is extended to cover the enhanced printing modes added here. The mgsr capability should be set for those printers that accept any motion control sequences without affecting shadow, italicized, widened, superscript, or subscript printing. Conversely, if the mgsr capability is not set, a program should end these modes before attempting any motion.
Alternate Character Sets
In addition to allowing you to define line graphics, the terminfo database also lets you define alternate character sets. The following capabilities cover printers and terminals with multiple selectable or definable character sets:
Capability | Definition |
---|---|
scs | Select character set N. The N parameter specifies a number from 0 to 63 that identifies a character set. |
scsd | Start definition of character set N, M characters. The N parameter specifies a number from 0 to 63 that identifies a character set and the M parameter specifies the number of characters in the set. |
defc | Defines a character A to be B dots wide with a descender D. The A parameter is the ASCII code representation for the character. The B parameter specifies the width of the character in dots. The D parameter specifies whether the character is a descender or not. If the character is a descender, specify a 1 for the D parameter. Otherwise, specify a 1. This string is followed by a string of image-data bytes that describe how the character looks. |
rcsd | End definition of character set N. The N parameter specifies a number from 0 to 63 that identifies a character set. |
csnm | List of character set names. |
daisy | Indicates the printer has manually changed print-wheels. |
Character set 0 is the default character set. This is the set that is present after the printer is initialized. Not every printer supports 64 character sets. If you specify a set that a printer does not support, the tparm subroutine returns a null result.
If your application must define a character before using it, use the scsd control sequence before defining the character set, and the rcsd after. If you specify an invalid character set for either of these capabilities, the tparm subroutine returns a null resolution. If your application must select a character set after it is defined, the scs control sequence should follow the rcsd control sequence. By examining the results of using each of the scs, scsd, and rcsd strings with a character set number in a call to the tparm subroutine, a program can determine which of the three are needed.
Between use of the scsd and rcsd strings, the defc string should be used to define each character. To print any character on printers defined in the terminfo database, the ASCII cod is sent to the printer. This is true for characters in an alternate set as well as normal characters. Thus, the definition of a character includes the ASCII code that represents it. In addition, the width of the character includes the ASCII code that represents it. In addition, the width of the character in dots is given, along with tan indication of whether the character is a descender. A descender is a character whose shape extends below the baseline, for example the character g is a descender. The width of the character is dots also indicates the number of image-data bytes that will follow the defc string. These image-data bytes indicate where in a dot-matrix pattern ink should be applied to draw the character. The number of these bytes and their form are defined below under Dot-Mapped Graphics.
It is easiest for the creator of terminfo entries to refer to each character set by number. However, these numbers will be meaningless to the application developer. The csnm capability alleviates this problem by providing names for each number.
When used with a character set number in a call to the tparm subroutine, the csnm capability produces the equivalent name. Use these names as a references only. No naming convention is implied, although anyone who creates a terminfo entry for a printer should use names consistent with the names found in user documents for the printer. Application developers should allow a user to specify a character set by number (leaving it up to the user to examine the csnm string to determine the correct number), or by name, where the application examines the csnm capability to determine the corresponding character set number.
The alternate character set capabilities are likely to be used only with dot-matrix printers. If they are not available, do not define these strings. For printers that have manually changed print-wheels or font cartridges, set the boolean daisy capability.
Dot-Matrix Graphics
Dot-matrix printers typically have the capability to reproduce raster-graphics images. Three new numeric capabilities and three new string capabilities can help a program draw raster-graphic images independent of the type of dot-matrix printer or the number of pins or dots the printer can handle at one time. The dot-matrix capabilities are as follows:
Capability | Definition |
---|---|
npins | Number of pins N in the print-head. The N parameter specifies the number of pins. |
spinv | Spacing of pins vertically in pins per inch. |
spinh | Spacing of dots horizontally in dots per inch. |
porder | Matches software bits to print-head pins. |
sbim | Start printing bit image graphics, B bits wide. The B value specifies the width of the image in dots. |
rbim | End printing bit image graphics. |
The model of dot-matrix or raster-graphics that the terminfo database presents is similar to the technique used for most dot-matrix printers. Each pass of the printer's print-head is assumed to produce a dot-matrix that is N dots high and B dots wide. This is typically a wide, squat, rectangle of dots. The height of this rectangle in dots varies from one printer to the next. This is given in the npins numeric capability. The size of the rectangle in fractions of an inch will also vary. The size can be deduced from the spinv and spinh numeric capabilities. With these three values an application can divide a complete raster-graphics image into several horizontal strips, perhaps interpolating to account for different dot spacing vertically and horizontally.
The sbim and rbim capabilities are used to start and end a dot-matrix image, respectively. The sbim capability is used with a single argument that gives the width of the dot-matrix in dots. A sequence of image-data bytes are sent to the printer after the sbim capability and before the rbim string. The number of bytes is an integral multiple of the width of the dot-matrix. The multiple and the form of each byte is determined by the porder capability is described below.
The porder capability is a comma-separated list of pin numbers. The position of each pin number in the list corresponds to a bit in a data byte. The pins are numbered consecutively from 1 to npins, with 1 being the top pin. The term pin is used loosely here. Ink-jet dot matrix printers don't have pins but they do have an equivalent method of applying a single dot of ink to paper. The bit positions in porder are in groups of 8, with the first position in each group the most significant bit and the last position the least significant bit.
The image-data bytes are computed from the dot-matrix image, mapping vertical dot positions in each print-head pass into eight-bit bytes, using a 1 bit where ink should be applied and 0 where no ink should be applied. If a position is skipped in porder, a 0 bit is used. There must be a multiple of 8 bit positions used or skipped in porder. If not, 0 bits are used to fill the last byte in the least significant bits.
Effect of Changing Printing Resolution
If the control sequences to change the character pitch or the line pitch are used, the pin or dot spacing may change. The following capabilities change pitch on dot-matrix graphics:
Capabilities | Definition |
---|---|
cpi | Change the character pitch. |
cpix | If set, cpi changes spinh. |
lpi | Change line pitch. |
lpix | If set, lpi changes spinv. |
The orhi' and orhi values are the values of the horizontal resolution in steps per inch, before using cpi and after using cpi, respectively. Likewise, orvi' and orvi are the values of the vertical resolution in steps per inch, before using lpi and after using lpi, respectively. Thus, the changes in the dots per inch for dot-matrix graphics follow the changes in steps per inch for printer resolution.
Print Quality
Many dot-matrix printers can alter the dot spacing of printed text to produce near letter-quality printing or draft-quality printing. Usually, it is important to be able to choose one or the other because the rate of printing generally falls off as the quality improves. The capabilities that specify print quality are the following:
Capability | Definition |
---|---|
snlq | Set near-letter quality print. |
snrmq | Set normal quality print. |
sdrfq | Set draft-quality print. |
The capabilities are listed in decreasing levels of quality. If a printer does not have all three levels, one or two of the strings should be left blank as appropriate.
Printing Rate and Buffer Size
Because there is no standard protocol that synchronizes a printer with a program, and because modern printers can buffer data before printing it, a program generally cannot determine at any time what has printed. Two new numeric capabilities can help a program estimate what has printed, the cps and bufsz capabilities.
The cps capability specifies the nominal print rate in characters per second. The cps capability is the nominal or average rate at which the printer prints characters. If this value is not given, estimate the rate at one-tenth the prevailing baud rate.
The bufsz capability defines a terminal's buffer capacity in characters. The bufsz value is the maximum number of subsequent characters buffered before the guaranteed printing of an earlier character, assuming proper flow control was used. If this value is not given it is assumed that the printer does not buffer characters, but prints them as they are received.
As an example, if a printer has a 1000-character buffer, then sending the letter "a" followed by 1000 additional characters is guaranteed to cause the letter "a" to print. If the same printer prints at the rate of 100 characters per second, then it should take 10 seconds to print all the characters in the buffer, less if the buffer is not full. By keeping track of the characters sent to a printer, and knowing the print rate and buffer size, a program can synchronize itself with the printer.
Most printer manufacturers advertise the maximum print rate, not the nominal print rate. A good way to get a value to put in for cps is to generate a few pages of text, count the number of printable characters, then see how long it takes to print the text.
Applications that use these values should recognize the variability in the print rate. Straight text, in short lines, with no embedded control sequences will probably print at close to the advertised print rate and probably faster than the rate in cps. Graphics data with a lot of control sequences, or very long lines of text, will print at well below the advertised rate and below the rate in cps. If the application is using cps to decide how long it should take a printer to print a block of text, the application should pad the estimate. If the application is using cps to decide how much text has already been printed, it should shrink the estimate. The application errs in favor of the user, who wants, above all, to see all the output in its correct place.
Database File Names
Compiled terminfo file descriptions are placed in subdirectories under the /usr/share/lib/terminfo directory to avoid performing linear searches through a single directory containing all of the terminfo file description files. A given description file is stored in the /usr/share/lib/terminfo/c/name file, where name is the name of the terminal, and c is the first letter of the terminal name. For example, the compiled description for the terminal term4-nl can be found in the file /usr/share/lib/terminfo/t/term4-nl. You can create synonyms for the same terminal by making multiple links to the same compiled file. (See the ln command on how to create multiple links to a file.)
Example
The following terminfo entry describes a terminal:
hft|High Function Terminal,
cr=^M, cud1=\E[B, ind=\E[S, bel=^G, il1=\E[L, am,
cub1=^H, ed=\E[J, el=\E[K, clear=\E[H\E[J,
cup=\E[%ip1%d;%p2%dH, cols#80, lines=#25,
dch1=\E[P, dl1=\E[M, home=\E[H,
ich=\E[%p1%d@, ich1=\E[@, smir=\E[6, rmir=\E6,
bold=\E[1m, rev=\E[7m, blink=\E[5m, invis=\E[8m, sgr0=\E[0m,
sgr=\E[%?%p1%t7;%;%?%p2%t4;%;%?%p3%t7;%;%?%p4%t5;%;%?%p6t1;%;m,
kcuu1=\E[A, kcud1=\E[B, kcub1=\E[D,
kcuf1=\E[C, khome=\E[H, kbs=^H,
cuf1=\E[C, ht=^I, cuu1=\E[A, xon,
rmul1=\E[m, smul=\E[4m, rmso=\E[m, smso=\E[7m,
kpp=\E[150q, knp=\E[154q,
kf1=\E[001q, kf2=\E[002q, kf3=\E[003q, kf4=\E[004q,
kf5=\E[005q, kf6=\E[006q, kf7=\E[007q, kf8=\E[008q,
kf9=\E[009q, kf10=\E[010q,
bw, eo, it#8, ms,
ch=\E%i%p1%dG, ech=\E[%p15dx,
kdch1=\E[P, kind=\E[151q, kich1=\E[139q, kimr=\E[41,
kn=^M, ko=^I, ktab=\E[Z, kri=\E[155q,
cub=\E[%p1%dD, cuf=\E[%p1%dC, indn=\E[%p1dS, rin=\E[%p1%dT,
ri=\E[T, cuu=\E[%p1%dA,
box1=332\304\277\263\331\300\302\264\301\303\305,
box2=311\315\273\272\274\310\313\271\312\314\316,
batt2=md,
colf0=\E[30m, colf1=\E[31m, colf2=\E[32m, colf3=\E[33m,
colf4=\E[34m, colf5=\E[35m, colf6=\E[36m, colf7=\E[37m,
colb0=\E[40m, colb1=\E[41m, colb2=\E[42m, colb3=\E[43m,
colb4=\E[44m, colb5=\E[45m, colb6=\E[46m, colb7=\E[47m,
ibm3161|ibm3163|wy60-316X|wyse60-316X|IBM 3161/3163 display,
am, mir, cr=^M, ind=^J,
cols#80, it#8, lines#24,
kich1=\EP\040\010,
ed=\EJ, el=\EI, cup=\EY%p1%' '%+%c%p2%'
'%+%c,
clear=\EH\EJ, dch1=\EQ, dl1=\EO, cud1=\EB,
cub1=\ED, blink=\E4D, bold=\E4H,
sgr0=\E4@\E<@,
invis=\E4P, rev=\E4A, cuf1=\EC,
rmso=\E4@,
smso=\E4A, rmul=\E4@, cuu1=\EA,
smul=\E4B,
sgr=\E4%'@'%?%p1%t%'A'%|%;
%?%p2%t%'B'%|%;
%?%p3%t%'A'%|%;
%?%p4%t%'D'%|%;
%?%p5%t%'@'%|%;
%?%p6%t%'H'%|%;
%?%p7%t%'P'%|%;%c
%?%p9%t\E>A%e\E<@%;,
box1=\354\361\353\370\352\355\367\365\366\364\356,
box2=\354\361\353\370\352\355\367\365\366\364\356,
batt2=md,
ktbc=\E\0401, kil1=\EN, kbs=^H,
kclr=\EL^M,
kcud1=\EB, kdch1=\EQ, kel=\EI,
khome=\EH,
kcub1=\ED, kdl1=\EO, ktab=^I, kcbt=\E2,
kcuf1=\EC, ked=\EJ, kctab=\E1, khts=\E0,
kcuu1=\EA, knl=\r, kact=\E8\r,
kf1=\Ea\r, kf2=\Eb\r, kf3=\Ec\r,
kf4=\Ed\r,
kf5=\Ee\r, kf6=\Ef\r, kf7=\Eg\r,
kf8=\Eh\r,
kf9=\Ei\r, kf10=\Ej\r, kf11=\Ek\r,
kf12=\El\r,
kf13=\E!a\r, kf14=\E!b\r, kf15=\E!c\r,
kf16=\E!d\r,
kf17=\E!e\r, kf18=\E!f\r, kf19=\E!g\r,
kf20=\E!h\r,
kf21=\E!i\r, kf22=\E!j\r, kf23=\E!k\r,
kf24=\E!l\r,
smcup=\E>A, rmcup=\E>A, msgr,
home=\EH, bel=^G, mc5=^P^R, mc4=^P^T,
Files
Item | Description |
---|---|
/usr/share/lib/terminfo/?/* | Compiled terminal capability database. |