ANSI Standard (X3.64) Control Sequences for Video Terminals and Peripherals with Examples for the IBM PC Compiled by W.C. Parke, 1986 References: ANSI X3.64-1979: Information Systems-Codes, American National Standards Institute, 1430 Broadway, NY, NY 10018 ISO 6429 standard: Information Processing-ISO 7-bit and 8-bit Coded Character Sets-Additional Control Functions for Charater-Imaging Devices, ANSI as above. Mark L. Siegel, April 1984 BYTE, p. 365 Zenith Programmer's Utility Pack, Ver. 2, 1984 In the table below: F is a Final character in an Escape sequence (F from 48 to 126 in the ASCII table) a control sequence (F from 64 to 126). Fe is a Final character in ASCII range 64 to 95. Gs is a graphic character appearing in strings (Gs ranges from 32 to 126) in the ASCII table. C0 is the set of 7-bit ASCII control characters from 0 to 31. C1 the set of control characters available only in 8-bit systems. Ce is a control represented as a single bit combination in the C1 set of controls in an 8-bit character set. I is an Intermediate character from 32 to 47 (inclusive) in the ASCII table. P is a parameter character from 48 to 63 (inclusive) in the ASCII table. Pn is a numeric parameter in a control sequence, a string of zero or more characters ranging from 48 to 57 in the ASCII table. Numeric parameters must be in decimal radix. Ps is a variable number of selective parameters in a control sequence with each selective parameter separated from the other by the code 59 (which usually represents a semicolon); Ps ranges from 48 to 57 and 59. Default Sequence Sequence Parameter Mnemonic Name Sequence Value --------------------------------------------------------------------------- Introducer sequences: CSI Control Sequence Intro Esc [ SS2 Single Shift 2 (G2 set) Esc N SS3 Single Shift 3 (G3 set) Esc O Delimiters: APC Applicatn Program Command Esc Fe DCS Device Control String Esc P OSC Operating System Command Esc ] PM Privacy Message Esc ^ ST String Terminator Esc \ Configuration: DA Device Attributes Esc [ Pn c 0 The VT100 responds to receiving the DA by transmitting the sequence: Esc [ ? l ; Ps c DSR Device Status Report Esc [ Ps n 0 The console driver will output a CPR sequence. STS Set Transmit State Esc S DMI Disable Manual Input Esc \ EMI Enable Manual Input Esc b INT Interrupt Esc a RIS Reset to Initial State Esc c Editor Functions: CBT Cursor Backward Tab Esc [ Pn Z 1 CCH Cancel Previous Character Esc T CHA Cursor Horzntal Absolute Esc [ Pn G 1 CHT Cursor Horizontal Tab Esc [ Pn I 1 CNL Cursor Next Line Esc [ Pn E 1 CPL Cursor Preceding Line Esc [ Pn F 1 CPR Cursor Position Report Esc [ Pn ; Pn R 1, 1 Report of cursor current line and column. ()Do not use as part of MS-DOS Prompt command.) CTC Cursor Tab Control Esc [ Ps W 0 CUB Cursor Backward Esc [ Pn D 1 Move cursor back Pn columns. Ignored if cursor in leftmost column. CUD Cursor Down Esc [ Pn B 1 Move cursor down Pn lines. Ignored if cursor on bottom line. CUF Cursor Forward Esc [ Pn C 1 Move cursor Pn columns forward. Ignored if cursor at rightmost column. CUP Cursor Position Esc [ Pn ; Pn H 1, 1 Move cursor to position specified. First parameter is line number and second is column number. No parameters means home position. CUU Cursor Up Esc [ Pn A 1 Move cursur up Pn lines. Ignored if cursor on top line. Default Sequence Sequence Parameter Mnemonic Name Sequence Value --------------------------------------------------------------------------- CVT Cursor Vertical Tab Esc [ Pn Y DAQ Define Area Qualification Esc [ Ps o 0 DCH Delete Character Esc [ Pn P 1 DL Delete Line Esc [ Pn M 1 EA Erase in Area Esc [ Ps O 0 ECH Erase Character Esc [ Pn X 1 ED Erase in Display Esc [ Ps J 0 Erases whole screen and cursor goes to home position. EF Erase in Field Esc [ Ps N 0 EL Erase in Line Esc [ Ps K 0 Erases everything between the cursor and the end of the line, including cursor position. EPA End of Protected Area Esc W ESA End of Selected Area Esc G ICH Insert Character Esc [ Pn @ 1 IL Insert Line Esc [ Pn L 1 NP Next Page Esc [ Pn U 1 PP Preceding Page Esc [ Pn V 1 SD Scroll Down Esc [ Pn T 1 SL Scroll Left Esc [ Pn Space @ 1 SPI Spacing Increment Esc [ Pn ; Pn Space G none SPA Start of Protected Area Esc V SR Scroll Right Esc [ Pn Space A 1 SSA Start of Selected Area Esc F SU Scroll Up Esc [ Pn S 1 TBC Tab Clear Esc [ Ps g 0 TSS Thin Space Specification Esc [ Pn Space E none VPA Vert Position Absolute Esc [ Pn d 1 VPR Vert Position Relative Esc [ Pn e 1 VTS Vertical Tabulation Set Esc J Format Sequences: FNT Font Selection Esc [ Pn ; Pn Space D 0, 0 GSM Graphic Size Modify Esc [ Pn ; Pn Space B 100, 100 GSS Graphic Size Selection Esc [ Pn Space C none HPA Horz Position Absolute Esc [ Pn ` 1 HPR Horz Position Relative Esc [ Pn a 1 HTJ Horz Tab w/Justification Esc I HTS Horizontal Tab Set Esc H HVP Horz & Vertical Position Esc [ Pn ; Pn f 1, 1 Moves cursor to line number, column number specified. No parameters moves cursor to home position. IND Index Esc D JFY Justify Esc [ Ps ; ... ; Ps Space F 0 MC Media Copy Esc [ Ps i 0 MW Message Waiting Esc U NEL Next Line Esc E PLD Partial Line Down Esc K PLU Partial Line Up Esc L PU1 Private Use 1 Esc Q PU2 Private Use 2 Esc R QUAD Typographic Quadding Esc [ Ps Space H 0 RCP Restore Cursor Position ESC [ u Restores cursor position saved by SCP. REP Repeat Char or Control Esc [ Pn b 1 RI Reverse Index Esc M Default Sequence Sequence Parameter Mnemonic Name Sequence Value --------------------------------------------------------------------------- RM Reset Mode Esc [ Ps l none Reset screen width or type. See SM for parameters. Parameter 7 will reset wrap mode (characters past end-of-line are lost.) SCP Save Cursor Position Esc [ s Cursor position will be restored with RCP sequence. SEM Select Edit Extent Mode Esc [ Ps Q 0 SGR Select Graphic Rendition Esc [ Ps m 0 Invokes graphic rendition specified by the parameters. All following characters are rendered according to the parameter(s) until the next SGR. Parameter functions on IBM PC: 0 All attributes off (normal, white on black) 1 Bold on (high intensity) 4 Underscore On (monochrome displays only) 5 Blink on 7 Reverse Video on 8 Cancelled on (invisible) 30 Black foreground 31 Red foreground 32 Green foreground 33 Yellow foreground 34 Blue foreground 35 Magenta foreground 36 Cyan foreground 37 White foreground 40 Black foreground 41 Red background 42 Green background 43 Yellow background 44 Blue background 45 Magenta background 46 Cyan background 47 White background SM Select Mode Esc [ Ps h none Invokes the screen width or type specified. IBM PC paramters: 0 40 x 25 monochrome 1 40 x 25 color 2 80 x 25 monochrome 3 80 x 25 color 4 320 x 200 color 5 320 x 200 monochrome 6 640 x 200 monochrome 7 wrap at end of line (word wrap) IBM PC Keyboard Reassignment: Keyboard reassignment uses an undefined ANSI X3.64-1979 code sequence to define a character or set of characters send by the console whenever a given key is pressed on an IBM PC compatible. The control sequence is: ESC [ Pn ; Pn ; ... Pn p or ESC [ "string" ; p The first ASCII code in the sequence defines which code is being mapped. If the first code is 0 (nul), then the second code is the extended IBM keycode. The remaining numbers define the sequence of ASCII codes generated when this key is intercepted, or the string (enclosed in quotes) to be generated. For example: ESC [65;81p A becomes Q ESC [0;68;"dir";13p F10 generates dir followed by a CR.