VT102 User Guide

C Programming Summary

General

This appendix provides a summary of VT102 escape and control sequences.

Figure C-1 shows the codes generated by the standard keys. Figure C-2 shows the control codes generated by the function keys; shaded keys do not need CTRL down to generate the control character.

VT102 Keyboard MA-7418B OCTAL CODE GENERATED BY KEYBOARD. (SHIFTED CODES SHOWN ABOVE KEYCAP LEGENDS UNSHIFTED CODES SHOWN BELOW KEYCAP LEGENDS) NOTE:THE \ AND LINE FEED KEYS FUNCTION AS SHOWN WHEN THE WPS TERMINAL KEYBOARD FEATURE IS OFF (0). WHEN WPS TERMINAL KEYBOARD IS ON (1), THESE KEYS SWITCH FUNCTIONS. 0411 !061 1002 @062 0433 #063 0444 $064 0455 %065 1366 ^066 0467 &067 0528 *070 0509 (071 0510 )060 137- _055 153= +075 176` ~140 121Q161 127W167 105E145 122R162 124T164 131Y171 125U165 111I151 117O157 120P160 173[ {133 175] }135 CAPSLOCK 101A141 123S163 104D144 106F146 107G147 110H150 112J152 113K153 114L154 072; :073 042' "047 174\ |134 SHIFT 132Z172 130X170 103C143 126V166 102B142 116N156 115M155 074, <054 076. >056 077/ ?057 SHIFT LINEFEED 040SPACE040
Figure C-1 Standard Key Codes
VT102 Function Key Control Codes MA-7419B MNEMONICS SHOWN ABOVE KEYCAP LEGENDS OCTAL CODES SHOWN BELOW KEYCAP LEGENDS NOTE:THE \ AND LINE FEED KEYS FUNCTION AS SHOWN WHEN THE WPS TERMINAL KEYBOARD FEATURE IS OFF (0). WHEN WPS TERMINAL KEYBOARD IS ON (1), THESE KEYS SWITCH FUNCTIONS. ESCESC033 RS` ~036 BSBACKSPACE010 HTTAB011 XONQ021 ETBW027 ENQE005 DC2R022 DC4T024 EMY031 NAKU025 HTI011 SIO017 DLEP020 ESC[ {033 GS] }035 CRRETURN015 DELDELETE177 CTRL SOHA001 XOFFS023 EOTD004 ACKF006 BELG007 BSH010 LFJ012 VTK013 FFL014 FS\ |034 SUBZ032 CANX030 ETXC003 SYNV026 STXB002 SON016 CRM015 US/ ?037 LFLINEFEED012 NUL000
Figure C-2 Function Key Control Codes

Programming Sequences

The rest of this appendix repeats the information on the VT102 Programming Reference Card (EK-VT102-RC-001).

Control Characters Received

Name Character Mnemonic Octal Code Function
Null NUL 000 Ignored when received (not stored in input buffer) and used as a fill character.
End of text ETX 003 Can be selected as a half-duplex turnaround character.
End of transmission EOT 004 Can be selected as a disconnect character or half-duplex turnaround character. When used as a turnaround character, the disconnect character is DLE-EOT.
Enquire ENQ 005 Transmits answerback message.
Bell BEL 007 Generates bell tone.
Backspace BS 010 Moves cursor to the left one character position; if cursor is at left margin, no action occurs.
Horizontal tab HT 011 Moves cursor to next tab stop, or to right margin if there are no more tab stops.
Linefeed LF 012 Causes a linefeed or a new line operation. (See Linefeed/New Line mode). Also causes printing if auto print operation selected.
Vertical tab VT 013 Processed as LF.
Form feed FF 014 Processed as LF. FF can also be selected as a half-duplex turnaround character.
Carriage return CR 015 Moves cursor to left margin on current line. CR can also be selected as a half-duplex turnaround character.
Shift out SO 016 Selects G1 character set designated by a select character set sequence.
Shift in SI 017 Selects G0 character set designated by a select character set sequence.
Device control 1 DC1 021 Processed as XON. DC1 causes terminal to continue transmitting characters.
Device control 3 DC3 023 Processed as XOFF. DC3 causes terminal to stop transmitting all characters except XOFF and XON. DC3 can also be selected as a half-duplex turnaround character.
Cancel CAN 030 If received during an escape or control sequence, cancels the sequence and displays substitution character ( ).
Substitute SUB 032 Processed as CAN.
Escape ESC 033 Processed as a sequence introducer.

ANSI Compatible Sequences

Set Mode

Name Mnemonic Mode Sequence
Keyboard action KAM Locked ESC [ 2 h
Insertion-replacement IRM Insert ESC [ 4 h
Send-receive SRM Off ESC [ 1 2 h
Linefeed/new line LMN New line ESC [ 2 0 h
Cursor key DECCKM Application ESC [ ? 1 h
ANSI/VT52 DECANM ANSI N/A
Column DECCOLM 132 column ESC [ ? 3 h
Scrolling DECSCLM Smooth ESC [ ? 4 h
Screen DECSCNM Reverse ESC [ ? 5 h
Origin DECOM Relative ESC [ ? 6 h
Auto wrap DECAWM On ESC [ ? 7 h
Auto repeat DECARM On ESC [ ? 8 h
Print form feed DECPFF On ESC [ ? 1 8 h
Print extent DECPEX Full screen ESC [ ? 1 9 h

Reset Mode

Name Mnemonic Mode Sequence*
Keyboard action KAM Unlocked ESC [ 2 l
Insertion-replacement IRM Replace ESC [ 4 l
Send-receive SRM On ESC [ 1 2 l
Linefeed/new line LMN Linefeed ESC [ 2 0 l
Cursor key DECCKM Cursor ESC [ ? 1 l
ANSI/VT52 DECANM VT52 ESC [ ? 2 l
Column DECCOLM 80 column ESC [ ? 3 l
Scrolling DECSCLM Jump ESC [ ? 4 l
Screen DECSCNM Normal ESC [ ? 5 l
Origin DECOM Absolute ESC [ ? 6 l
Auto wrap DECAWM Off ESC [ ? 7 l
Auto repeat DECARM Off ESC [ ? 8 l
Print form feed DECPFF Off ESC [ ? 1 8 l
Print extent DECPEX Scrolling region ESC [ ? 1 9 l
* The last character of the sequence is lowercase L (1548)

Cursor Key Codes Generated

Cursor Key (Arrow) ANSI Characters Generated
Reset (Cursor) Set (Application)
Up ESC [ A ESC O A
Down ESC [ B ESC O B
Right ESC [ C ESC O C
Left ESC [ D ESC O D

Keypad Character Selection

Name Mnemonic Sequence
Alternate DECKPAM ESC =
Numeric DECKPNM ESC >

Keypad Codes Generated

Key VT52 Numeric Keypad Mode VT52 Alternate Keypad Mode ANSI Numeric Keypad Mode ANSI Alternate Keypad Mode
0 0 ESC ? p 0 ESC O p
1 1 ESC ? q 1 ESC O q
2 2 ESC ? r 2 ESC O r
3 3 ESC ? s 3 ESC O s
4 4 ESC ? t 4 ESC O t
5 5 ESC ? u 5 ESC O u
6 6 ESC ? v 6 ESC O v
7 7 ESC ? w 7 ESC O w
8 8 ESC ? x 8 ESC O x
9 9 ESC ? y 9 ESC O y
- (minus) - (minus) ESC ? m - (minus) ESC O m
, (comma) , (comma) ESC ? l* , (comma) ESC O l*
. (period) . (period) ESC ? n . (period) ESC O n
ENTER Same as RETURN ESC ? M Same as RETURN ESC O M
PF1 ESC P ESC P ESC O P ESC O P
PF2 ESC Q ESC Q ESC O Q ESC O Q
PF3 ESC R ESC R ESC O R ESC O R
PF4 ESC S ESC S ESC O S ESC O S
* The last character of the sequence is lowercase L (1548)

Select Character Sets SCS

Character Set G0 Designator G1 Designator
United Kingdom (UK) ESC ( A ESC ) A
United States (US) ESC ( B ESC ) B
Special characters and line drawing set ESC ( 0 ESC ) 0
Alternate character ROM ESC ( 1 ESC ) 1
Alternate character ROM - special characters ESC ( 2 ESC ) 2
Name Mnemonic Sequence
Single shift 2 SS2 ESC N
Single shift 3 SS3 ESC O
US/UK Character Set
US/UK Character Set B7 B6 B5 B4 B3 B2 B1 BITS 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 ROW 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 0 1 0 0 1 2 0 1 0 3 0 1 1 4 1 0 0 5 1 0 1 6 1 1 0 7 1 1 1 COLUMN (XON) (XOFF) ESC 33271B OCTALDECIMALHEX ASCII CHARACTER KEY NUL 000 111 222 ETX 333 EOT 444 ENQ 555 666 BEL 777 BS 1088 HT 1199 LF 1210A VT 1311B FF 1412C CR 1513D SO 1614E SI 1715F 201610 DC1 211711 221812 DC3 231913 242014 252115 262216 272317 CAN 302418 312519 SUB 32261A ESC 33271B 34281C 35291D 36301E 37311F SP 403220 ! 413321 " 423422 433523 $ 443624 % 453725 & 463826 ' 473927 ( 504028 ) 514129 * 52422A + 53432B , 54442C - 55452D . 56462E / 57472F 0 604830 1 614931 2 625032 3 635133 4 645234 5 655335 6 665436 7 675537 8 705638 9 715739 : 72583A ; 73593B < 74603C = 75613D > 76623E ? 77633F @ 1006440 A 1016541 B 1026642 C 1036743 D 1046844 E 1056945 F 1067046 G 1077147 H 1107248 I 1117349 J 112744A K 113754B L 114764C M 115774D N 116784E O 117794F P 1208050 Q 1218151 R 1228252 S 1238353 T 1248454 U 1258555 V 1268656 W 1278757 X 1308858 Y 1318959 Z 132905A [ 133915B \ 134925C ] 135935D ^ 136945E _ 137955F ` 1409660 a 1419761 b 1429862 c 1439963 d 14410064 e 14510165 f 14610266 g 14710367 h 15010468 i 15110569 j 1521066A k 1531076B l 1541086C m 1551096D n 1561106E o 1571116F p 16011270 q 16111371 r 16211472 s 16311573 t 16411674 u 16511775 v 16611876 w 16711977 x 17012078 y 17112179 z 1721227A { 1731237B | 1741247C } 1751257D ~ 1761267E 1771277F * # £ *NOTE:  DEPENDS ON THE CHARACTER SET SELECTED; U.S.=#  U.K.=£ MA-7247B
Special Characters and Line Drawing Set
Special Characters and Line Drawing Character Set B7 B6 B5 B4 B3 B2 B1 BITS 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 ROW 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 0 0 1 0 0 1 2 0 1 0 3 0 1 1 4 1 0 0 5 1 0 1 6 1 1 0 7 1 1 1 COLUMN (XON) (XOFF) ESC 33271B OCTALDECIMALHEX ASCII CHARACTER KEY NUL 000 111 222 ETX 333 EOT 444 ENQ 555 666 BEL 777 BS 1088 HT 1199 LF 1210A VT 1311B FF 1412C CR 1513D SO 1614E SI 1715F 201610 DC1 211711 221812 DC3 231913 242014 252115 262216 272317 CAN 302418 312519 SUB 32261A ESC 33271B 34281C 35291D 36301E 37311F SP 403220 ! 413321 " 423422 # 433523 $ 443624 % 453725 & 463826 ' 473927 ( 504028 ) 514129 * 52422A + 53432B , 54442C - 55452D . 56462E / 57472F 0 604830 1 614931 2 625032 3 635133 4 645234 5 655335 6 665436 7 675537 8 705638 9 715739 : 72583A ; 73593B < 74603C = 75613D > 76623E ? 77633F @ 1006440 A 1016541 B 1026642 C 1036743 D 1046844 E 1056945 F 1067046 G 1077147 H 1107248 I 1117349 J 112744A K 113754B L 114764C M 115774D N 116784E O 117794F P 1208050 Q 1218151 R 1228252 S 1238353 T 1248454 U 1258555 V 1268656 W 1278757 X 1308858 Y 1318959 Z 132905A [ 133915B \ 134925C ] 135935D ^ 136945E 137955F 1409660 1419761 1429862 1439963 14410064 14510165 14610266 14710367 15010468 15110569 1521066A 1531076B 1541086C 1551096D 1561106E 1571116F 16011270 16111371 16211472 16311573 16411674 16511775 16611876 16711977 17012078 17112179 1721227A 1731237B 1741247C 1751257D 1761267E 1771277F (BLANK) SCAN 1 SCAN 3 SCAN 5 SCAN 7 SCAN 9 MA-7249A

Character Attributes

Name Mnemonic Sequence
Select graphic rendition (no attributes) SGR ESC [ m
Select graphic rendition (no attributes) SGR ESC [ 0 m
Select graphic rendition (select attribute bold) SGR ESC [ 1 m
Select graphic rendition (select attribute underline) SGR ESC [ 4 m
Select graphic rendition (select attribute blink) SGR ESC [ 5 m
Select graphic rendition (select attribute, reverse video) SGR ESC [ 7 m

Scrolling Region

Name Mnemonic Sequence
Set top and bottom margins DECSTBM ESC [ Pt ; Pb r

Cursor Movement Commands

Name Mnemonic Sequence
Cursor up CUU ESC [ Pn A
Cursor down CUD ESC [ Pn B
Cursor forward (right) CUF ESC [ Pn C
Cursor backward (left) CUB ESC [ Pn D
Cursor position CUP ESC [ Pl ; Pc H
Cursor position (home) CUP ESC [ H
Horizontal and vertical position HVP ESC [ Pl ; Pc f
Horizontal and vertical position (home) HVP ESC [ f
Index IND ESC D
Reverse index RI ESC M
Next line NEL ESC E
Save cursor (and attributes) DECSC ESC 7
Restore cursor (and attributes) DECRC ESC 8

Tab Stops

Name Mnemonic Sequence
Horizontal tab set (at current column) HTS ESC H
Tabulation clear (at current column) TBC ESC [ g
Tabulation clear (at current column) TBC ESC [ 0 g
Tabulation clear (all tabs) TBC ESC [ 3 g

Line Attributes

Name Mnemonic Sequence
Double-height top half DECDHL ESC # 3
Double-height bottom half DECDHL ESC # 4
Single-width single-height DECSWL ESC # 5
Double-width single-height DECDWL ESC # 6

Erasing

Name Mnemonic Sequence
Erase in line (cursor to end of line) EL ESC [ K
Erase in line (cursor to end of line) EL ESC [ 0 K
Erase in line (beginning of line to cursor) EL ESC [ 1 K
Erase in line (entire line containing cursor) EL ESC [ 2 K
Erase in display (cursor to end of screen) ED ESC [ J
Erase in display (cursor to end of screen) ED ESC [ 0 J
Erase in display (beginning of screen to cursor) ED ESC [ 1 J
Erase in display (entire screen) ED ESC [ 2 J

Editing Functions

Name Mnemonic Sequence
Delete character DCH ESC [ Pn P
Insert line IL ESC [ Pn L
Delete line DL ESC [ Pn M

Print Commands

Name Mnemonic Sequence
Media copy (enter auto print) MC ESC [ ? 5 i
Media copy (exit auto print) MC ESC [ ? 4 i
Media copy (enter printer controller) MC ESC [ 5 i
Media copy (exit printer controller) MC ESC [ 4 i
Media copy (print screen) MC ESC [ i
Media copy (print screen) MC ESC [ 0 i
Media copy (print cursor line) MC ESC [ ? 1 i

Reports

Name Mnemonic Sequence
Device status report (request status of VT102) DSR ESC [ 5 n
Response:
    Terminal OK DSR ESC [ 0 n
    Terminal not OK DSR ESC [ 3 n
Device status report (request status of printer) DSR ESC [ ? 1 5 n
Response:
    Printer ready DSR ESC [ ? 1 0 n
    Printer not ready DSR ESC [ ? 1 1 n
    No printer DSR ESC [ ? 1 3 n
Device status report (report cursor position) DSR ESC [ 6 n
Cursor position report CPR ESC [ Pl ; Pc R
Device attributes (what are you) DA ESC [ c
Device attributes (what are you) DA ESC [ 0 c
Identify terminal (what are you) DECID ESC Z

NOTE: ESC Z is not recommended.

Device attributes response: VT102 DA ESC [ ? 6 c

Reset

Name Mnemonic Sequence
Reset to initial state RIS ESC c

Tests and adjustments

Name Mnemonic Sequence
Screen alignment display (fill screen with “Es”) DECALN ESC # 8
Invoke confidence test (power-up test) DECTST ESC [ 2 ; 1 y
Invoke confidence test (data loopback test; requires test connector) DECTST ESC [ 2 ; 2 y
Invoke confidence test (EIA modem control test; requires test connector) DECTST ESC [ 2 ; 4 y
Invoke confidence test (repeat power-up test continuously until failure or power-off) DECTST ESC [ 2 ; 9 y
Invoke confidence test (repeat data loopback test continuously until failure or power-off; requires test connector) DECTST ESC [ 2 ; 1 0 y
Invoke confidence test (repeat EIA test continuously until failure or power-off; requires test connector) DECTST ESC [ 2 ; 1 2 y
Invoke confidence test (printer port data loopback test; requires test connector) DECTST ESC [ 2 ; 1 6 y
Invoke confidence test (repeat printer port data loopback test continuously until failure or power-off; requires test connector) DECTST ESC [ 2 ; 2 4 y

Keyboard LEDs

Name Mnemonic Sequence
Load LEDs (L1 off) DECLL ESC [ q
Load LEDs (L1 off) DECLL ESC [ 0 q
Load LEDs (L1 on) DECLL ESC [ 1 q

VT52 Compatible Mode

Modes Sequence
Enter ANSI mode ESC <

Keypad Character Selection

Name Sequence
Enter alternate keypad mode ESC =
Exit alternate keypad mode (Numeric keypad mode) ESC >

NOTE: VT52 alternate keypad and numeric keypad mode different than ANSI.

Character Sets

Name Sequence
Special graphics character set ESC F*
Select US/UK character set (as determined by the US/UK character SET-UP feature) ESC G
* Same as special character and line drawing set in ANSI mode.

Cursor Position

Name Sequence
Cursor up* ESC A
Cursor down* ESC B
Cursor right* ESC C
Cursor left* ESC D
Cursor to home ESC H
Direct cursor address ESC Y Pl Pc†
Reverse line feed ESC I‡
* Same when sent from the terminal.
† Line and column numbers for direct cursor address are single character codes whose values are the desired number plus 378.
Line and colum numbers start at one.
‡ The last character of the sequence is an uppercase i (1118).

Erasing

Name Sequence
Erase to end of line ESC K
Erase to end of screen ESC J

Print Commands

Name Sequence
Enter auto print mode ESC ^
Exit auto print mode ESC _
Enter printer controller mode ESC W
Exit printer controll mode ESC X
Print screen ESC ]
Print cursor line ESC V

Reports

Name Sequence
Identify (what are you) ESC Z
Response: VT102 (same as VT52) ESC / Z