Xterm Control Sequences Edward Moy University of California, Berkeley Revised by Stephen Gildea MIT X Consortium Definitions c The literal character `c'. _C A single (required) character. _Ps A single (usually optional) numeric parameter, composed of one of more digits. _Pm A multiple numeric parameter composed of any number of sin- gle numeric parameters, separated by `;' character(s). _Pt A text parameter composed of printable characters. VT100 Mode Most of these control sequences are standard VT102 control sequences, but there are some sequences here from later DEC VT terminals, too. Major VT102 features not supported are smooth scrolling, double size characters, blinking characters, and VT52 mode. There are additional control sequences to provide xterm- dependent functions, like the scrollbar or window size. Where the function is specified by DEC or ISO 6429, the code assigned to it is given in parentheses. The escape codes to designate character sets are specified by ISO 2022; see that document for a discussion of character sets. BEL Bell (Ctrl-G) BS Backspace (Ctrl-H) TAB Horizontal Tab (HT) (Ctrl-I) LF Line Feed or New Line (NL) (Ctrl-J) Xterm Control Sequences VT100 Mode VT Vertical Tab (Ctrl-K) same as LF FF Form Feed or New Page (NP) (Ctrl-L) same as LF CR Carriage Return (Ctrl-M) SO Shift Out (Ctrl-N) -> Switch to Alternate Charac- ter Set: invokes the G1 character set. SI Shift In (Ctrl-O) -> Switch to Standard Character Set: invokes the G0 character set (the default). ESC # 8 DEC Screen Alignment Test (DECALN) ESC ( _C Designate G0 Character Set (ISO 2022) _C = 0 -> DEC Special Character and Line Drawing Set _C = A -> United Kingdom (UK) _C = B -> United States (USASCII) ESC ) _C Designate G1 Character Set (ISO 2022) _C = 0 -> DEC Special Character and Line Drawing Set _C = A -> United Kingdom (UK) _C = B -> United States (USASCII) ESC * _C Designate G2 Character Set (ISO 2022) _C = 0 -> DEC Special Character and Line Drawing Set _C = A -> United Kingdom (UK) _C = B -> United States (USASCII) ESC + _C Designate G3 Character Set (ISO 2022) _C = 0 -> DEC Special Character and Line Drawing Set _C = A -> United Kingdom (UK) _C = B -> United States (USASCII) ESC 7 Save Cursor (DECSC) ESC 8 Restore Cursor (DECRC) ESC = Application Keypad (DECPAM) ESC > Normal Keypad (DECPNM) ESC D Index (IND) ESC E Next Line (NEL) ESC H Tab Set (HTS) ESC M Reverse Index (RI) ESC N Single Shift Select of G2 Character Set (SS2): affects next character only ESC O Single Shift Select of G3 Character Set (SS3): affects next character only ESC P _Pt ESC \ Device Control String (DCS) xterm implements no DCS functions; _Pt is ignored. _Pt need not be printable characters. ESC Z Return Terminal ID (DECID). Obsolete form of ESC [ c (DA). ESC [ _Ps @ Insert _Ps (Blank) Character(s) (default = 1) (ICH) ESC [ _Ps A Cursor Up _Ps Times (default = 1) (CUU) ESC [ _Ps B Cursor Down _Ps Times (default = 1) (CUD) ESC [ _Ps C 2 Xterm Control Sequences VT100 Mode Cursor Forward _Ps Times (default = 1) (CUF) ESC [ _Ps D Cursor Backward _Ps Times (default = 1) (CUB) ESC [ _Ps ; _Ps H Cursor Position [row;column] (default = [1,1]) (CUP) ESC [ _Ps J Erase in Display (ED) _Ps = 0 -> Clear Below (default) _Ps = 1 -> Clear Above _Ps = 2 -> Clear All ESC [ _Ps K Erase in Line (EL) _Ps = 0 -> Clear to Right (default) _Ps = 1 -> Clear to Left _Ps = 2 -> Clear All ESC [ _Ps L Insert _Ps Line(s) (default = 1) (IL) ESC [ _Ps M Delete _Ps Line(s) (default = 1) (DL) ESC [ _Ps P Delete _Ps Character(s) (default = 1) (DCH) ESC [ _Ps ; _Ps ; _Ps ; _Ps ; _Ps T Initiate hilite mouse tracking. Parameters are [func;startx;starty;firstrow;lastrow]. See the section Mouse Tracking. ESC [ _Ps c Send Device Attributes (DA) _Ps = 0 or omitted -> request attributes from terminal -> ESC [ ? 1 ; 2 c (``I am a VT100 with Advanced Video Option.'') ESC [ _Ps ; Ps f Horizontal and Vertical Position [row;column] (default = [1,1]) (HVP) ESC [ _Ps g Tab Clear (TBC) _Ps = 0 -> Clear Current Column (default) _Ps = 3 -> Clear All ESC [ _Pm h Set Mode (SM) _Ps = 4 -> Insert Mode (IRM) _Ps = 2 0 -> Automatic Newline (LNM) ESC [ _Pm l Reset Mode (RM) _Ps = 4 -> Replace Mode (IRM) _Ps = 2 0 -> Normal Linefeed (LNM) ESC [ _Pm m Character Attributes (SGR) _Ps = 0 -> Normal (default) _Ps = 1 -> Bold _Ps = 4 -> Underscore _Ps = 5 -> Blink (appears as Bold) 3 Xterm Control Sequences VT100 Mode _Ps = 7 -> Inverse ESC [ _Ps n Device Status Report (DSR) _Ps = 5 -> Status Report ESC [ 0 n (``OK'') _Ps = 6 -> Report Cursor Position (CPR) [row;column] as ESC [ r ; c R ESC [ _Ps ; Ps r Set Scrolling Region [top;bottom] (default = full size of window) (DECSTBM) ESC [ _Ps x Request Terminal Parameters (DECREQTPARM) ESC [ ? _Pm h DEC Private Mode Set (DECSET) _Ps = 1 -> Application Cursor Keys (DECCKM) _Ps = 2 -> Designate USASCII for character sets G0-G3. (In the VT102, this selects VT52 mode (DECANM), which xterm doesn't support.) _Ps = 3 -> 132 Column Mode (DECCOLM) _Ps = 4 -> Smooth (Slow) Scroll (DECSCLM) _Ps = 5 -> Reverse Video (DECSCNM) _Ps = 6 -> Origin Mode (DECOM) _Ps = 7 -> Wraparound Mode (DECAWM) _Ps = 8 -> Auto-repeat Keys (DECARM) _Ps = 9 -> Send Mouse X & Y on button press. See the section Mouse Tracking. _Ps = 3 8 -> Enter Tektronix Mode (DECTEK) _Ps = 4 0 -> Allow 80 <--> 132 Mode _Ps = 4 1 -> curses(5) fix _Ps = 4 4 -> Turn On Margin Bell _Ps = 4 5 -> Reverse-wraparound Mode _Ps = 4 6 -> Start Logging _Ps = 4 7 -> Use Alternate Screen Buffer (unless disabled by the titeInhibit resource) _Ps = 1 0 0 0 -> Send Mouse X & Y on button press and release. See the sec- tion Mouse Tracking. _Ps = 1 0 0 1 -> Use Hilite Mouse Tracking. See the section Mouse Tracking. ESC [ ? _Pm l DEC Private Mode Reset (DECRST) _Ps = 1 -> Normal Cursor Keys (DECCKM) _Ps = 3 -> 80 Column Mode (DECCOLM) _Ps = 4 -> Jump (Fast) Scroll (DECSCLM) _Ps = 5 -> Normal Video (DECSCNM) _Ps = 6 -> Normal Cursor Mode (DECOM) _Ps = 7 -> No Wraparound Mode (DECAWM) _Ps = 8 -> No Auto-repeat Keys (DECARM) _Ps = 9 -> Don't Send Mouse X & Y on button press _Ps = 4 0 -> Disallow 80 <--> 132 Mode _Ps = 4 1 -> No curses(5) fix 4 Xterm Control Sequences VT100 Mode _Ps = 4 4 -> Turn Off Margin Bell _Ps = 4 5 -> No Reverse-wraparound Mode _Ps = 4 6 -> Stop Logging _Ps = 4 7 -> Use Normal Screen Buffer _Ps = 1 0 0 0 -> Don't Send Mouse X & Y on button press and release _Ps = 1 0 0 1 -> Don't Use Hilite Mouse Tracking ESC [ ? _Pm r Restore DEC Private Mode Values. The value of _Ps previously saved is restored. _Ps values are the same as for DECSET. ESC [ ? _Pm s Save DEC Private Mode Values. _Ps values are the same as for DECSET. ESC ] _Ps ; _Pt BEL Set Text Parameters _Ps = 0 -> Change Icon Name and Window Title to _Pt _Ps = 1 -> Change Icon Name to _Pt _Ps = 2 -> Change Window Title to _Pt _Ps = 4 6 -> Change Log File to _Pt (normally disabled by a compile-time option) _Ps = 5 0 -> Set Font to _Pt ESC ^ _Pt ESC \ Privacy Message (PM) xterm implements no PM functions; _Pt is ignored. _Pt need not be printable characters. ESC _Pt ESC \ Application Program Command (APC) xterm implements no APC functions; _Pt is ignored. _Pt need not be printable characters. ESC c Full Reset (RIS) ESC n Select the G2 Character Set (LS2) ESC o Select the G3 Character Set (LS3) ESC | Invoke the G3 Character Set as GR (LS3R). Has no visible effect in xterm. ESC } Invoke the G2 Character Set as GR (LS2R). Has no visible effect in xterm. ESC ~ Invoke the G1 Character Set as GR (LS1R). Has no visible effect in xterm. Mouse Tracking The VT widget can be set to send the mouse position and other information on button presses. These modes are typically used by editors and other full-screen applications that want to make use of the mouse. There are three mutually exclusive modes, each enabled (or dis- abled) by a different parameter in the DECSET (or DECRST) escape sequence. Parameters for all mouse tracking escape sequences generated by xterm encode numeric parameters in a single charac- ter as value+040. For example, `!' is 1. The screen coodi- nate system is 1-based. 5 Xterm Control Sequences VT100 Mode X10 compatibility mode sends an escape sequence on button press encoding the location and the mouse button pressed. It is enabled by specifying parameter 9 to DECSET. On button press, xterm sends ESC [ M CbCxCy (6 characters). Cb is button-1. Cx and Cy are the x and y coordinates of the mouse when the button was pressed. Normal tracking mode sends an escape sequence on both button press and release. Modifier information is also sent. It is enabled by specifying parameter 1000 to DECSET. On button press or release, xterm sends ESC [ M CbCxCy. The low two bits of Cb encode button information: 0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release. The upper bits encode what modifiers were down when the button was pressed and are added together. 4=Shift, 8=Meta, 16=Control. Cx and Cy are the x and y coordinates of the mouse event. The upper left corner is (1,1). Mouse hilite tracking notifies a program of a button press, receives a range of lines from the program, highlights the region covered by the mouse within that range until button release, and then sends the program the release coordinates. It is enabled by specifying parameter 1001 to DECSET. Warning: use of this mode requires a cooperating program or it will hang xterm. On button press, the same information as for normal tracking is generated; xterm then waits for the program to send mouse tracking informa- tion. All X events are ignored until the proper escape sequence is received from the pty: ESC [ _Ps ; _Ps ; _Ps ; _Ps ; _Ps T . The parameters are func, startx, starty, firstrow, and lastrow. func is non-zero to initiate hilite tracking and zero to abort. startx and starty give the starting x and y location for the highlighted region. The ending location tracks the mouse, but will never be above row firstrow and will always be above row lastrow. (The top of the screen is row 1.) When the button is released, xterm reports the ending position one of two ways: if the start and end coordinates are valid text locations: ESC [ t CxCy. If either coordinate is past the end of the line: ESC [ T CxCyCxCyCxCy. The parameters are startx, starty, endx, endy, mousex, and mousey. startx, starty, endx, and endy give the starting and ending character positions of the region. mousex and mousey give the location of the mouse at button up, which may not be over a character. Tektronix 4014 Mode Most of these sequences are standard Tektronix 4014 control sequences. The major features missing are the write-thru and defocused modes. This document does not describe the commands used in the various Tektronix plotting modes but does describe the commands to switch modes. BEL Bell (Ctrl-G) BS Backspace (Ctrl-H) TAB Horizontal Tab (Ctrl-I) LF Line Feed or New Line (Ctrl-J) VT Cursor up (Ctrl-K) 6 Xterm Control Sequences Tektronix 4014 Mode FF Form Feed or New Page (Ctrl-L) CR Carriage Return (Ctrl-M) ESC ETX Switch to VT100 Mode (ESC Ctrl-C) ESC ENQ Return Terminal Status (ESC Ctrl-E) ESC LF PAGE (Clear Screen) ESC SO Begin 4015 APL mode (ignored by xterm) (ESC Ctrl- N) ESC SI End 4015 APL mode (ignored by xterm) (ESC Ctrl-O) ESC ETB COPY (Save Tektronix Codes to file COPYyy-mm- dd.hh:mm:ss) (ESC Ctrl-W) ESC CAN Bypass Condition (ESC Ctrl-X) ESC SUB GIN mode (ESC Ctrl-Z) ESC FS Special Point Plot Mode (ESC Ctrl-\) ESC 8 Select Large Character Set ESC 9 Select # 2 Character Set ESC : Select #3 Character Set ESC ; Select Small Character Set ESC ] _Ps ; _Pt BEL Set Text Parameters of VT window _Ps = 0 -> Change Icon Name and Window Title to _Pt _Ps = 1 -> Change Icon Name to _Pt _Ps = 2 -> Change Window Title to _Pt _Ps = 4 6 -> Change Log File to _Pt ESC ` Normal Z Axis and Normal (solid) Vectors ESC a Normal Z Axis and Dotted Line Vectors ESC b Normal Z Axis and Dot-Dashed Vectors ESC c Normal Z Axis and Short-Dashed Vectors ESC d Normal Z Axis and Long-Dashed Vectors ESC h Defocused Z Axis and Normal (solid) Vectors ESC i Defocused Z Axis and Dotted Line Vectors ESC j Defocused Z Axis and Dot-Dashed Vectors ESC k Defocused Z Axis and Short-Dashed Vectors ESC l Defocused Z Axis and Long-Dashed Vectors ESC p Write-Thru Mode and Normal (solid) Vectors ESC q Write-Thru Mode and Dotted Line Vectors ESC r Write-Thru Mode and Dot-Dashed Vectors ESC s Write-Thru Mode and Short-Dashed Vectors ESC t Write-Thru Mode and Long-Dashed Vectors FS Point Plot Mode (Ctrl-\) GS Graph Mode (Ctrl-]) RS Incremental Plot Mode (Ctrl-^) US Alpha Mode (Ctrl-_) 7