Xterm Control Sequences (2022)

Definitions
C1 (8-Bit) Control Characters
VT100 Mode
PC-Style Function Keys
VT220-Style Function Keys
VT52-Style Function Keys
Sun-Style Function Keys
HP-Style Function Keys
The Alternate Screen Buffer
Bracketed Paste Mode
Mouse Tracking
Tektronix 4014 Mode
VT52 Mode

Edward Moy
University of California, Berkeley

Revisedby
Stephen Gildea

X Consortium (1994)
Thomas Dickey

XFree86 Project (1996-2005)

Definitions

c

The literalcharacter c.

C

A single (required)character.

Ps

A single (usuallyoptional) numeric parameter, composed of one of moredigits.

Pm

A multiple numericparameter composed of any number of single numericparameters, separated by ; character(s). Individual valuesfor the parameters are listed with P s.

Pt

A text parametercomposed of printable characters.

C1 (8-Bit) Control Characters

The xtermprogram recognizes both 8-bit and 7-bit control characters.It generates 7-bit controls (by default) or 8-bit if S8C1Tis enabled. The following pairs of 7-bit and 8-bit controlcharacters are equivalent:

ESCD

Index (IND is 0x84)

ESC E

Next Line (NEL is 0x85)

ESC H

Tab Set ( HTSis 0x88)

ESC M

Reverse Index (RI is 0x8d)

ESC N

Single Shift Select of G2 Character Set (SS2 is 0x8e): affects nextcharacter only

ESC O

Single Shift Select of G3 Character Set (SS3 is 0x8f): affects nextcharacter only

ESC P

Device Control String (DCS is 0x90)

ESC V

Start of Guarded Area (SPA is 0x96)

ESC W

End of Guarded Area (EPA is 0x97)

ESC X

Start of String (SOS is 0x98)

ESC Z

Return Terminal ID (DECID is 0x9a).Obsolete form of CSI c(DA).

ESC [

Control Sequence Introducer (CSI is 0x9b)

ESC \

String Terminator (ST is 0x9c)

ESC ]

Operating System Command (OSC is 0x9d)

ESC ^

Privacy Message (PM is 0x9e)

ESC _

Application Program Command (APC is 0x9f)

These controlcharacters are used in the vtXXX emulation.

VT100 Mode

Most of thesecontrol sequences are standard VT102 control sequences, butthere is support for later DEC VT terminals (i.e., VT220,VT320, VT420), as well as ISO 6429 and aixterm colorcontrols. The only VT102 features not supported isauto-repeat, since the only way X provides for this willaffect all windows. There are additional control sequencesto provide xterm-dependent functions, such as thescrollbar or window size. Where the function is specified byDEC or ISO 6429, the code assigned to it is given inparentheses. The escape codes to designate and invokecharacter sets are specified by ISO 2022; see that documentfor a discussion of character sets.

Single-characterfunctions

BEL

Bell (Ctrl-G)

BS

Backspace (Ctrl-H)

CR

Carriage Return (Ctrl-M)

ENQ

Return Terminal Status (Ctrl-E). Defaultresponse is an empty string, but may be overridden by aresource answerbackString.

FF

Form Feed or New Page (NP) (Ctrl-L) same asLF

LF

Line Feed or New Line (NL) (Ctrl-J)

SO

Shift Out (Ctrl-N) → Switch toAlternate Character Set: invokes the G1 character set.

SP

Space.

TAB

Horizontal Tab (HT) (Ctrl-I)

VT

Vertical Tab (Ctrl-K) same as LF

SI

Shift In (Ctrl-O) → Switch to StandardCharacter Set: invokes the G0 character set (thedefault).

Controlsbeginning with ESC (other than those where ESC is part of a7-bit equivalent to 8-bit C1 controls), ordered by the finalcharacter(s).

ESC SP F

7-bit controls (S7C1T).

ESC SP G

8-bit controls (S8C1T).

ESC SP L

Set ANSI conformance level 1 (dpANSX3.134.1).

ESC SP M

Set ANSI conformance level 2 (dpANSX3.134.1).

ESC SP N

Set ANSI conformance level 3 (dpANSX3.134.1).

ESC # 3

DEC double-height line, top half(DECDHL)

ESC # 4

DEC double-height line, bottom half(DECDHL)

ESC # 5

DEC single-width line (DECSWL)

ESC # 6

DEC double-width line (DECDWL)

ESC # 8

DEC Screen Alignment Test (DECALN)

ESC % @

Select default character set, ISO 8859-1(ISO 2022)

ESC % G

Select UTF-8 character set (ISO 2022)

ESC (C

Designate G0 Character Set (ISO 2022)

ESC )C

Designate G1 Character Set (ISO 2022)

ESC *C

Designate G2 Character Set (ISO 2022)

ESC +C

Designate G3 Character Set (ISO 2022)

Final character C fordesignating character sets (0 , A and B apply to VT100 andup, the remainder to VT220 and up):
C
= 0 → DEC Special Character and Line Drawing Set
C
= A → United Kingdom (UK)
C
= B → United States (USASCII)
C
= 4 → Dutch
C
= C or 5 → Finnish
C
= R → French
C
= Q → French Canadian
C
= K → German
C
= Y → Italian
C
= E or 6 → Norwegian/Danish
C
= Z → Spanish
C
= H or 7 → Swedish
C
= = → Swiss

ESC 7

Save Cursor (DECSC)

ESC 8

Restore Cursor (DECRC)

ESC =

Application Keypad (DECPAM)

ESC >

Normal Keypad (DECPNM)

ESC F

Cursor to lower left corner of screen (ifenabled by the hpLowerleftBugCompat resource).

ESC c

Full Reset (RIS)

ESC l

Memory Lock (per HP terminals). Locksmemory above the cursor.

ESC m

Memory Unlock (per HP terminals)

ESC n

Invoke the G2 Character Set as GL(LS2).

ESC o

Invoke the G3 Character Set as GL(LS3).

ESC |

Invoke the G3 Character Set as GR(LS3R).

ESC }

Invoke the G2 Character Set as GR(LS2R).

ESC ~

Invoke the G1 Character Set as GR(LS1R).

ApplicationProgram-Control functions

APC Pt ST

xterm implements noAPC functions; Pt is ignored. P tneed not be printable characters.

Device-Controlfunctions

DCS Ps ; P s | Pt ST

User-Defined Keys (DECUDK). Thefirst parameter:
P s
= 0 → Clear all UDK definitionsbefore starting (default)
P s
= 1 → Erase Below (default)
The second parameter:
P s
= 0 → Lock the keys (default)
P s
= 1 → Do not lock.
The third parameter is a ’;’-separated list ofstrings denoting the key-code separated by a ’/’from the hex-encoded key value. The key codes correspond tothe DEC function-key codes (e.g., F6=17).

DCS $ q Pt ST

Request Status String (DECRQSS). The stringfollowing the "q" is one of the following:

“ q

→ DECSCA
“ p

→ DECSCL
r

→ DECSTBM
m

→ SGR

xterm responds withDCS 1 $ r Pt ST forvalid requests, replacing the P t withthe corresponding CSI string,or DCS 0 $ r Pt ST forinvalid requests.

DCS + q Pt ST

Request Termcap/Terminfo String (xterm,experimental). The string following the "q" is alist of names encoded in hexadecimal (2 digits percharacter) separated by ; which correspond to termcap orterminfo key names.

xterm responds withDCS 1 + r Pt ST forvalid requests, adding to P t an = ,and the value of the corresponding string that xterm wouldsend, or DCS 0 + r Pt ST forinvalid requests. The strings are encoded in hexadecimal (2digits per character).

Functions usingCSI , ordered by the finalcharacter(s)

CSI Ps @

Insert P s (Blank)Character(s) (default = 1) (ICH)

CSI Ps A

Cursor Up P s Times(default = 1) (CUU)

CSI Ps B

Cursor Down P s Times(default = 1) (CUD)

CSI Ps C

Cursor Forward P sTimes (default = 1) (CUF)

CSI Ps D

Cursor Backward P sTimes (default = 1) (CUB)

CSI Ps E

Cursor Next Line P sTimes (default = 1) (CNL)

CSI Ps F

Cursor Preceding Line Ps Times (default = 1) (CPL)

CSI Ps G

Cursor Character Absolute [column] (default= [row,1]) (CHA)

CSI Ps ; P s H

Cursor Position [row;column] (default =[1,1]) (CUP)

CSI Ps I

Cursor Forward Tabulation Ps tab stops (default = 1) (CHT)

CSI Ps J

Erase in Display (ED)

P s = 0→ Erase Below (default)
P s
= 1 → Erase Above
P s
= 2 → Erase All
P s
= 3 → Erase Saved Lines(xterm)

CSI ? Ps J

Erase in Display (DECSED)

P s = 0→ Selective Erase Below (default)
P s
= 1 → Selective Erase Above
P s
= 2 → Selective Erase All

CSI Ps K

Erase in Line (EL)

P s = 0→ Erase to Right (default)
P s
= 1 → Erase to Left
P s
= 2 → Erase All

CSI ? Ps K

Erase in Line (DECSEL)

P s = 0→ Selective Erase to Right (default)
P s
= 1 → Selective Erase to Left
P s
= 2 → Selective Erase All

CSI Ps L

Insert P s Line(s)(default = 1) (IL)

CSI Ps M

Delete P s Line(s)(default = 1) (DL)

CSI Ps P

Delete P sCharacter(s) (default = 1) (DCH)

CSI Ps S

Scroll up P s lines(default = 1) (SU)

CSI Ps T

Scroll down P s lines(default = 1) (SD)

CSI Ps ; P s ;P

s ; Ps ; P s T

Initiate highlight mouse tracking.Parameters are [func;startx;starty;firstrow;lastrow]. Seethe section Mouse Tracking.

CSI Ps X

Erase P sCharacter(s) (default = 1) (ECH)

CSI Ps Z

Cursor Backward Tabulation Ps tab stops (default = 1) (CBT)

CSI Pm `

Character Position Absolute [column](default = [row,1]) (HPA)

CSI Ps b

Repeat the preceding graphic character Ps times (REP)

CSI Ps c

Send Device Attributes (Primary DA)

P s = 0or omitted → request attributes from terminal. Theresponse depends on the decTerminalID resourcesetting.
CSI ? 1 ; 2 c(‘‘VT100 with Advanced VideoOption’’)
CSI ? 1 ; 0 c(‘‘VT101 with No Options’’)
CSI ? 6 c(‘‘VT102’’)
CSI ? 6 0 ; 1 ; 2 ; 6 ;8 ; 9 ; 1 5 ; c (‘‘VT220’’)
The VT100-style response parameters do not mean anything bythemselves. VT220 parameters do, telling the host whatfeatures the terminal supports:
→ 1 132-columns
→ 2 Printer
→ 6 Selective erase
→ 8 User-defined keys
→ 9 National replacement character sets
→ 1 5 Technical characters
→ 2 2 ANSI color, e.g., VT525
→ 2 9 ANSI text locator (i.e., DEC Locator mode)

CSI > Ps c

Send Device Attributes (Secondary DA)

P s = 0or omitted → request the terminal’sidentification code. The response depends on thedecTerminalID resource setting. It should apply onlyto VT220 and up, but xterm extends this to VT100.
CSI > Pp ; P v ; Pc c
where P p denotes the terminal type
→ 0 (‘‘VT100’’)
→ 1 (‘‘VT220’’)
and P v is the firmware version (forxterm, this is the XFree86 patch number, startingwith 95). In a DEC terminal, P cindicates the ROM cartridge registration number and isalways zero.

CSI Pm d

Line Position Absolute [row] (default =[1,column]) (VPA)

CSI Ps ; P s f

Horizontal and Vertical Position[row;column] (default = [1,1]) (HVP)

CSI Ps g

Tab Clear (TBC)

P s = 0→ Clear Current Column (default)
P s
= 3 → Clear All

CSI Pm h

Set Mode (SM)

P s = 2→ Keyboard Action Mode (AM)
P s
= 4 → Insert Mode (IRM)
P s
= 1 2 → Send/receive (SRM)
P s
= 2 0 → Automatic Newline(LNM)

CSI ? Pm h

DEC Private Mode Set (DECSET)

P s = 1→ Application Cursor Keys (DECCKM)
P s
= 2 → Designate USASCII forcharacter sets G0-G3 (DECANM), and set VT100 mode.
P s
= 3 → 132 Column Mode (DECCOLM)
P s
= 4 → Smooth (Slow) Scroll(DECSCLM)
P s
= 5 → Reverse Video (DECSCNM)
P s
= 6 → Origin Mode (DECOM)
P s
= 7 → Wraparound Mode (DECAWM)
P s
= 8 → Auto-repeat Keys (DECARM)
P s
= 9 → Send Mouse X & Y onbutton press. See the section Mouse Tracking.
P s
= 1 0 → Show toolbar (rxvt)
P s
= 1 2 → Start Blinking Cursor(att610)
P s
= 1 8 → Print form feed (DECPFF)
P s
= 1 9 → Set print extent to fullscreen (DECPEX)
P s
= 2 5 → Show Cursor (DECTCEM)
P s
= 3 0 → Show scrollbar (rxvt).
P s
= 3 5 → Enable font-shiftingfunctions (rxvt).
P s
= 3 8 → Enter Tektronix Mode(DECTEK)
P s
= 4 0 → Allow 80 → 132 Mode
P s
= 4 1 → more(1) fix (seecurses resource)
P s
= 4 2 → Enable NationReplacement Character sets (DECNRCM)
P s
= 4 4 → Turn On Margin Bell
P s
= 4 5 → Reverse-wraparound Mode
P s
= 4 6 → Start Logging (normallydisabled by a compile-time option)
P s
= 4 7 → Use Alternate ScreenBuffer (unless disabled by the titeInhibit resource)
P s
= 6 6 → Application keypad(DECNKM)
P s
= 6 7 → Backarrow key sendsbackspace (DECBKM)
P s
= 1 0 0 0 → Send Mouse X & Yon button press and release. See the section MouseTracking.
P s
= 1 0 0 1 → Use Hilite MouseTracking.
P s
= 1 0 0 2 → Use Cell MotionMouse Tracking.
P s
= 1 0 0 3 → Use All Motion MouseTracking.
P s
= 1 0 1 0 → Scroll to bottom ontty output (rxvt).
P s
= 1 0 1 1 → Scroll to bottom onkey press (rxvt).
P s
= 1 0 3 5 → Enable specialmodifiers for Alt and NumLock keys.
P s
= 1 0 3 6 → Send ESC when Metamodifies a key (enables the metaSendsEscaperesource).
P s
= 1 0 3 7 → Send DEL from theediting-keypad Delete key
P s
= 1 0 4 7 → Use Alternate ScreenBuffer (unless disabled by the titeInhibit resource)
P s
= 1 0 4 8 → Save cursor as inDECSC (unless disabled by the titeInhibit resource)
P s
= 1 0 4 9 → Save cursor as inDECSC and use Alternate Screen Buffer, clearing it first(unless disabled by the titeInhibit resource). Thiscombines the effects of the 1 0 4 7 and 1 0 4 8 modes. Usethis with terminfo-based applications rather than the 4 7mode.
P s
= 1 0 5 1 → Set Sun function-keymode.
P s
= 1 0 5 2 → Set HP function-keymode.
P s
= 1 0 5 3 → Set SCO function-keymode.
P s
= 1 0 6 0 → Set legacy keyboardemulation (X11R6).
P s
= 1 0 6 1 → Set Sun/PC keyboardemulation of VT220 keyboard.
P s
= 2 0 0 4 → Set bracketed pastemode.

CSI Pm i

Media Copy (MC)

P s = 0→ Print screen (default)
P s
= 4 → Turn off printercontroller mode
P s
= 5 → Turn on printer controllermode

CSI ? Pm i

Media Copy (MC, DEC-specific)

P s = 1→ Print line containing cursor
P s
= 4 → Turn off autoprint mode
P s
= 5 → Turn on autoprint mode
P s
= 1 0 → Print composed display,ignores DECPEX
P s
= 1 1 → Print all pages

CSI Pm l

Reset Mode (RM)

P s = 2→ Keyboard Action Mode (AM)
P s
= 4 → Replace Mode (IRM)
P s
= 1 2 → Send/receive (SRM)
P s
= 2 0 → Normal Linefeed(LNM)

CSI ? Pm l

DEC Private Mode Reset (DECRST)

P s = 1→ Normal Cursor Keys (DECCKM)
P s
= 2 → Designate VT52 mode(DECANM).
P s
= 3 → 80 Column Mode (DECCOLM)
P s
= 4 → Jump (Fast) Scroll(DECSCLM)
P s
= 5 → Normal Video (DECSCNM)
P s
= 6 → Normal Cursor Mode (DECOM)
P s
= 7 → No Wraparound Mode(DECAWM)
P s
= 8 → No Auto-repeat Keys(DECARM)
P s
= 9 → Don’t Send Mouse X& Y on button press
P s
= 1 0 → Hide toolbar (rxvt)
P s
= 1 2 → Stop Blinking Cursor(att610)
P s
= 1 8 → Don’t print formfeed (DECPFF)
P s
= 1 9 → Limit print to scrollingregion (DECPEX)
P s
= 2 5 → Hide Cursor (DECTCEM)
P s
= 3 0 → Don’t showscrollbar (rxvt).
P s
= 3 5 → Disable font-shiftingfunctions (rxvt).
P s
= 4 0 → Disallow 80 → 132Mode
P s
= 4 1 → No more(1) fix(see curses resource)
P s
= 4 2 → Disable NationReplacement Character sets (DECNRCM)
P s
= 4 4 → Turn Off Margin Bell
P s
= 4 5 → No Reverse-wraparoundMode
P s
= 4 6 → Stop Logging (normallydisabled by a compile-time option)
P s
= 4 7 → Use Normal Screen Buffer
P s
= 6 6 → Numeric keypad (DECNKM)
P s
= 6 7 → Backarrow key sendsdelete (DECBKM)
P s
= 1 0 0 0 → Don’t SendMouse X & Y on button press and release. See the sectionMouse Tracking.
P s
= 1 0 0 1 → Don’t UseHilite Mouse Tracking
P s
= 1 0 0 2 → Don’t Use CellMotion Mouse Tracking
P s
= 1 0 0 3 → Don’t Use AllMotion Mouse Tracking
P s
= 1 0 1 0 → Don’t scrollto bottom on tty output (rxvt).
P s
= 1 0 1 1 → Don’t scrollto bottom on key press (rxvt).
P s
= 1 0 3 5 → Disable specialmodifiers for Alt and NumLock keys.
P s
= 1 0 3 6 → Don’t send ESCwhen Meta modifies a key (disables themetaSendsEscape resource).
P s
= 1 0 3 7 → Send VT220 Removefrom the editing-keypad Delete key
P s
= 1 0 4 7 → Use Normal ScreenBuffer, clearing screen first if in the Alternate Screen(unless disabled by the titeInhibit resource)
P s
= 1 0 4 8 → Restore cursor as inDECRC (unless disabled by the titeInhibit resource)
P s
= 1 0 4 9 → Use Normal ScreenBuffer and restore cursor as in DECRC (unless disabled bythe titeInhibit resource). This combines the effectsof the 1 0 4 7 and 1 0 4 8 modes. Use this withterminfo-based applications rather than the 4 7 mode.
P s
= 1 0 5 1 → Reset Sunfunction-key mode.
P s
= 1 0 5 2 → Reset HPfunction-key mode.
P s
= 1 0 5 3 → Reset SCOfunction-key mode.
P s
= 1 0 6 0 → Reset legacykeyboard emulation (X11R6).
P s
= 1 0 6 1 → Reset Sun/PCkeyboard emulation of VT220 keyboard.
P s
= 2 0 0 4 → Reset bracketedpaste mode.

CSI Pm m

Character Attributes (SGR)

P s = 0→ Normal (default)
P s
= 1 → Bold
P s
= 4 → Underlined
P s
= 5 → Blink (appears as Bold)
P s
= 7 → Inverse
P s
= 8 → Invisible, i.e., hidden(VT300)
P s
= 2 2 → Normal (neither bold norfaint)
P s
= 2 4 → Not underlined
P s
= 2 5 → Steady (not blinking)
P s
= 2 7 → Positive (not inverse)
P s
= 2 8 → Visible, i.e., nothidden (VT300)
P s
= 3 0 → Set foreground color toBlack
P s
= 3 1 → Set foreground color toRed
P s
= 3 2 → Set foreground color toGreen
P s
= 3 3 → Set foreground color toYellow
P s
= 3 4 → Set foreground color toBlue
P s
= 3 5 → Set foreground color toMagenta
P s
= 3 6 → Set foreground color toCyan
P s
= 3 7 → Set foreground color toWhite
P s
= 3 9 → Set foreground color todefault (original)
P s
= 4 0 → Set background color toBlack
P s
= 4 1 → Set background color toRed
P s
= 4 2 → Set background color toGreen
P s
= 4 3 → Set background color toYellow
P s
= 4 4 → Set background color toBlue
P s
= 4 5 → Set background color toMagenta
P s
= 4 6 → Set background color toCyan
P s
= 4 7 → Set background color toWhite
P s
= 4 9 → Set background color todefault (original).

If 16-colorsupport is compiled, the following apply. Assume thatxterm’s resources are set so that the ISO colorcodes are the first 8 of a set of 16. Then theaixterm colors are the bright versions of the ISOcolors:
P s
= 9 0 → Set foreground color toBlack
P s
= 9 1 → Set foreground color toRed
P s
= 9 2 → Set foreground color toGreen
P s
= 9 3 → Set foreground color toYellow
P s
= 9 4 → Set foreground color toBlue
P s
= 9 5 → Set foreground color toMagenta
P s
= 9 6 → Set foreground color toCyan
P s
= 9 7 → Set foreground color toWhite
P s
= 1 0 0 → Set background colorto Black
P s
= 1 0 1 → Set background colorto Red
P s
= 1 0 2 → Set background colorto Green
P s
= 1 0 3 → Set background colorto Yellow
P s
= 1 0 4 → Set background colorto Blue
P s
= 1 0 5 → Set background colorto Magenta
P s
= 1 0 6 → Set background colorto Cyan
P s
= 1 0 7 → Set background colorto White

If xtermis compiled with the 16-color support disabled, it supportsthe following, from rxvt:
P s
= 1 0 0 → Set foreground andbackground color to default

If 88- or256-color support is compiled, the following apply.
P s
= 3 8 ; 5 ; P s→ Set foreground color to the second Ps
P s
= 4 8 ; 5 ; P s→ Set background color to the second Ps

CSIP s n

Device StatusReport (DSR)

P s = 5→ Status Report CSI 0 n(‘‘OK’’)
P s
= 6 → Report Cursor Position(CPR) [row;column] as
CSI
r ; c R

CSI ? Ps n

Device Status Report (DSR,DEC-specific)

P s = 6→ Report Cursor Position (CPR) [row;column] asCSI ? r ; c R(assumes page is zero).
P s
= 1 5 → Report Printer status asCSI ? 1 0 n (ready) orCSI ? 1 1 n (not ready)
P s
= 2 5 → Report UDK status asCSI ? 2 0 n (unlocked) orCSI ? 2 1 n (locked)
P s
= 2 6 → Report Keyboard statusas
CSI
? 2 7 ; 1 ; 0 ; 0 n (North American)
The last two parameters apply to VT400 & up, and denotekeyboard ready and LK01 respectively.
P s
= 5 3 → Report Locator status as
CSI
? 5 3 n Locator available, ifcompiled-in, or
CSI
? 5 0 n No Locator, if not.

CSI ! p

Soft terminal reset (DECSTR)

CSI Ps ; P s “p

Set conformance level (DECSCL) Valid valuesfor the first parameter:

P s = 6 1→ VT100
P s
= 6 2 → VT200
P s
= 6 3 → VT300
Valid values for the second parameter:
P s
= 0 → 8-bit controls
P s
= 1 → 7-bit controls (always setfor VT100)
P s
= 2 → 8-bit controls

CSI Ps “ q

Select character protection attribute(DECSCA). Valid values for the parameter:

P s = 0→ DECSED and DECSEL can erase (default)
P s
= 1 → DECSED and DECSEL cannoterase
P s
= 2 → DECSED and DECSEL canerase

CSI Ps ; P s r

Set Scrolling Region [top;bottom] (default= full size of window) (DECSTBM)

CSI ? Pm r

Restore DEC Private Mode Values. The valueof P s previously saved is restored.P s values are the same as forDECSET.

CSI Pt ; P l ; Pb ;

P r ; Ps $ r

Change Attributes in Rectangular Area(DECCARA).

P t ;P l ; P b ; Pr denotes the rectangle.
P s
denotes the SGR attributes to change:0, 1, 4, 5, 7

CSI s

Save cursor (ANSI.SYS)

CSI ? Pm s

Save DEC Private Mode Values. Ps values are the same as for DECSET.

CSI Ps ; P s ;P

s t

Window manipulation (from dtterm, aswell as extensions). These controls may be disabled usingthe allowWindowOps resource. Valid values for thefirst (and any additional parameters) are:

P s = 1→ De-iconify window.
P s
= 2 → Iconify window.
P s
= 3 ; x ; y → Move windowto [x, y].
P s
= 4 ; height ; width →Resize the xterm window to height and width inpixels.
P s
= 5 → Raise the xtermwindow to the front of the stacking order.
P s
= 6 → Lower the xtermwindow to the bottom of the stacking order.
P s
= 7 → Refresh the xtermwindow.
P s
= 8 ; height ; width →Resize the text area to [height;width] in characters.
P s
= 9 ; 0 → Restore maximizedwindow.
P s
= 9 ; 1 → Maximize window (i.e.,resize to screen size).
P s
= 1 1 → Report xtermwindow state. If the xterm window is open(non-iconified), it returnsCSI 1 t . If the xtermwindow is iconified, it returnsCSI 2 t .
P s
= 1 3 → Report xtermwindow position as CSI 3 ;x; yt
P s
= 1 4 → Report xtermwindow in pixels as CSI 4 ;height ; width t
P s
= 1 8 → Report the size of thetext area in characters as CSI8 ; height ; width t
P s
= 1 9 → Report the size of thescreen in characters as CSI 9; height ; width t
P s
= 2 0 → Report xtermwindow’s icon label asOSC L labelST
P s
= 2 1 → Report xtermwindow’s title as OSC ltitle ST
P s
>= 2 4 → Resize to Ps lines (DECSLPP)

CSI Pt ; P l ; Pb ; P r ; Ps $ t

Reverse Attributes inRectangular Area (DECRARA).
P t
; P l ; Pb ; P r denotes therectangle.
P s
denotes the attributes to reverse. 1,4, 5, 7

CSI u

Save cursor (ANSI.SYS)

CSI Pt ; P l ; Pb ;

P r ; Pp ; P t ; Pl ; P p $ v

Copy Rectangular Area (DECCRA)

P t ;P l ; P b ; Pr denotes the rectangle.
P p
denotes the source page.
P t
; P l denotesthe target location.
P p
denotes the target page.

CSI Pt ; P l ; Pb ; P r ’w

Enable Filter Rectangle(DECEFR)
Parameters are [top;left;bottom;right].
Defines the coordinates of a filter rectangle and activatesit. Anytime the locator is detected outside of the filterrectangle, an outside rectangle event is generated and therectangle is disabled. Filter rectangles are always treatedas "one-shot" events. Any parameters that areomitted default to the current locator position. If allparameters are omitted, any locator motion will be reported.DECELR always cancels any prevous rectangle definition.

CSI Ps x

Request Terminal Parameters(DECREQTPARM)

if P s isa "0" (default) or "1", and xtermis emulating VT100, the control sequence elicits a responseof the same form whose parameters describe the terminal:
P s
→ the given Ps incremented by 2.
1 → no parity
1 → eight bits
1 2 8 → transmit 38.4k baud
1 2 8 → receive 38.4k baud
1 → clock multiplier
0 → STP flags

CSI Ps x

Select Attribute Change Extent(DECSACE).

P s = 0→ from start to end position, wrapped
P s
= 1 → from start to endposition, wrapped
P s
= 2 → rectangle (exact).

CSI Pc ; P t ; Pl ; P b ; Pr $ x

Fill Rectangular Area (DECFRA).
P c
is the character to use.
P t
; P l ; Pb ; P r denotes therectangle.

CSI Ps ; P u ’z

Enable Locator Reporting (DECELR)

Valid values for the firstparameter:
P s
= 0 → Locator disabled (default)
P s
= 1 → Locator enabled
P s
= 2 → Locator enabled for onereport, then disabled
The second parameter specifies the coordinate unit forlocator reports.
Valid values for the second parameter:
P u
= 0 or omitted → default tocharacter cells
P u
= 1 → device physical pixels
P u
= 2 → character cells

CSI Pt ; P l ; Pb ; P r $ z

Erase Rectangular Area(DECERA).
P t
; P l ; Pb ; P r denotes therectangle.

CSI Pm ’ {

Select Locator Events (DECSLE)

Valid values for the first (andany additional parameters) are:
P s
= 0 → only respond to explicithost requests (DECRQLP)
(default) also cancels any filter rectangle
P s
= 1 → report button downtransitions
P s
= 2 → do not report button downtransitions
P s
= 3 → report button uptransitions
P s
= 4 → do not report button uptransitions

CSI Pt ; P l ; Pb ; P r $ {

Selective Erase RectangularArea (DECSERA).
P t
; P l ; Pb ; P r denotes therectangle.

CSI Ps ’ |

Request Locator Position (DECRQLP)

Valid values for the parameterare:
P s
= 0 , 1 or omitted → transmit asingle DECLRP locator report

If LocatorReporting has been enabled by a DECELR, xterm will respondwith a DECLRP Locator Report. This report is also generatedon button up and down events if they have been enabled witha DECSLE, or when the locator is detected outside of afilter rectangle, if filter rectangles have been enabledwith a DECEFR.

CSI P e; P b ; P r ;P c ; P p &w

Parameters are[event;button;row;column;page].
Valid values for the event:
P e
= 0 → locator unavailable - noother parameters sent
P e
= 1 → request - xterm received aDECRQLP
P e
= 2 → left button down
P e
= 3 → left button up
P e
= 4 → middle button down
P e
= 5 → middle button up
P e
= 6 → right button down
P e
= 7 → right button up
P e
= 8 → M4 button down
P e
= 9 → M4 button up
P e
= 1 0 → locator outside filterrectangle
‘‘button’’ parameter is a bitmaskindicating which buttons are pressed:
P b
= 0 → no buttons down
P b
& 1 → right button down
P b
& 2 → middle button down
P b
& 4 → left button down
P b
& 8 → M4 button down
‘‘row’’ and‘‘column’’ parameters are thecoordinates of the locator position in the xterm window,encoded as ASCII decimal.
The ‘‘page’’ parameter is not usedby xterm, and will be omitted.

Operating SystemControls

OSC Ps ; P tST

OSC Ps ; P tBEL

Set Text Parameters. For colors and font,if P t is a "?", the controlsequence elicits a response which consists of the controlsequence which would set the corresponding value. Thedtterm control sequences allow you to determine theicon name and window title.

P s = 0→ Change Icon Name and Window Title to Pt
P s
= 1 → Change Icon Name to Pt
P s
= 2 → Change Window Title toP t
P s
= 3 → Set X property ontop-level window. P t should be in theform "prop=value", or just"prop" to delete the property
P s
= 4 ; c ; spec → ChangeColor Number c to the color specified by spec,i.e., a name or RGB specification as per XParseColor.Any number of c name pairs may be given. The colornumbers correspond to the ANSI colors 0-7, their brightversions 8-15, and if supported, the remainder of the88-color or 256-color table.

If a"?" is given rather than a name or RGBspecification, xterm replies with a control sequence of thesame form which can be used to set the corresponding color.Because more than one pair of color number and specificationcan be given in one control sequence, xterm can makemore than one reply.

The 8 colorswhich may be set using 1 0 through 1 7 are denoteddynamic colors, since the corresponding controlsequences were the first means for settingxterm’s colors dynamically, i.e., after it wasstarted. They are not the same as the ANSI colors. One ormore parameters is expected for P t .Each successive parameter changes the next color in thelist. The value of P s tells thestarting point in the list. The colors are specified by nameor RGB specification as per XParseColor.

If a"?" is given rather than a name or RGBspecification, xterm replies with a control sequence of thesame form which can be used to set the corresponding dynamiccolor. Because more than one pair of color number andspecification can be given in one control sequence,xterm can make more than one reply.

Ps = 1 0 → Change VT100 textforeground color to P t
P s
= 1 1 → Change VT100 textbackground color to P t
P s
= 1 2 → Change text cursor colorto P t
P s
= 1 3 → Change mouse foregroundcolor to P t
P s
= 1 4 → Change mouse backgroundcolor to P t
P s
= 1 5 → Change Tektronixforeground color to P t
P s
= 1 6 → Change Tektronixbackground color to P t
P s
= 1 7 → Change highlight colorto P t
P s
= 1 8 → Change Tektronix cursorcolor to P t

Ps = 4 6 → Change Log File to Pt (normally disabled by a compile-timeoption)

Ps = 5 0 → Set Font to Pt If P t beginswith a "#", index in the font menu, relative (ifthe next character is a plus or minus sign) or absolute. Anumber is expected but not required after the sign (thedefault is the current entry for relative, zero for absoluteindexing).

Ps = 5 1 (reserved for Emacs shell)

Ps = 5 2 → Manipulate Selection Data.These controls may be disabled using theallowWindowOps resource. The parameter Pt is parsed as

P c ; Pd

The first, Pc , may contain any character from theset c p s 0 1 2 3 4 5 6 7 . It is used to construct a listof selection parameters for clipboard, primary, select, orcut buffers 0 through 8 respectively, in the order given. Ifthe parameter is empty, xterm uses s 0 , to specifythe configurable primary/clipboard selection and cut buffer0.
The second parameter, P d , gives theselection data. Normally this is a string encoded in base64.The data becomes the new selection, which is then availablefor pasting by other applications.
If the second parameter is a ? , xterm replies to thehost with the selection data encoded using the sameprotocol.

PrivacyMessage

PM Pt ST

xterm implements noPM functions; Pt is ignored. P tneed not be printable characters.

PC-Style Function Keys

If xtermdoes minimal translation of the function keys, it usuallydoes this with a PC-style keyboard, so PC-style functionkeys result. Sun keyboards are similar to PC keyboards. Bothhave cursor and scrolling operations printed on the keypad,which duplicate the smaller cursor and scrolling keypads.
X does not predefine NumLock (used for VT220 keyboards) orAlt (used as an extension for the Sun/PC keyboards) asmodifiers. These keys are recognized as modifiers whenenabled by the numLock resource, or by the DECSET 1 03 5 control sequence.
The cursor keys transmit the following escape sequencesdepending on the mode specified via the DECCKM escapesequence.

Xterm Control Sequences (1)

The home- and end-keys (unlike PageUp andother keys also on the 6-key editing keypad) are considered"cursor keys" by xterm. Their mode is alsocontrolled by the DECCKM escape sequence:

Xterm Control Sequences (2)

The application keypad transmits thefollowing escape sequences depending on the mode specifiedvia the DECPNM and DECPAM escape sequences.Use the NumLock key to override the application mode.
Not all keys are present on the Sun/PC keypad (e.g., PF1,Tab), but are supported by the program.

Xterm Control Sequences (3)

They also provide 12 function keys, as wellas a few other special-purpose keys.

Xterm Control Sequences (4)

Older versions of xterm implementdifferent escape sequences for F1 through F4. These can beactivated by setting the oldXtermFKeys resource.However, since they do not correspond to any hardwareterminal, they have been deprecated. (The DEC VT220 reservesF1 through F5 for local functions such as Setup).

Xterm Control Sequences (5)

In normal mode, i.e., a Sun/PC keyboardwhen the sunKeyboard resource is false, xtermrecognizes function key modifiers which are parametersappended before the final character of the controlsequence.

Xterm Control Sequences (6)

For example, shift-F5 would be sent asCSI 1 5 ; 2 ~

If thealwaysUseMods resource is set, the Meta modifier alsois recognized, making parameters 9 through 16.

VT220-Style Function Keys

However,xterm is most useful as a DEC VT102 or VT220emulator. Set the sunKeyboard resource to true toforce a Sun/PC keyboard to act like a VT220 keyboard.
The VT102/VT220 application keypad transmits unique escapesequences in application mode, which are distinct from thecursor and scrolling keypad:

Xterm Control Sequences (7)

The VT220 provides a 6-key editing keypad,which is analogous to that on the PC keyboard. It is notaffected by DECCKM orDECPNM/DECPAM:

Xterm Control Sequences (8)

The VT220 provides 8 additional functionkeys. With a Sun/PC keyboard, access these keys byControl/F1 for F13, etc.

Xterm Control Sequences (9)

VT52-Style Function Keys

A VT52 does nothave function keys, but it does have a numeric keypad andcursor keys. They differ from the other emulations by theprefix. Also, the cursor keys do not change:

Xterm Control Sequences (10)

The keypad is similar:

Xterm Control Sequences (11)

Sun-Style Function Keys

The xtermprogram provides support for Sun keyboards more directly, bya menu toggle that causes it to send Sun-style function keycodes rather than VT220. Note, however, that the sunand VT100 emulations are not really compatible. Forexample, their wrap-margin behavior differs.
Only function keys are altered; keypad and cursor keys arethe same. The emulation responds identically. See thexterm-sun terminfo entry for details.

HP-Style Function Keys

Similarly,xterm can be compiled to support HP keyboards. Seethe xterm-hp terminfo entry for details.

The Alternate Screen Buffer

Xtermmaintains two screen buffers. The normal screen bufferallows you to scroll back to view saved lines of output upto the maximum set by the saveLines resource. Thealternate screen buffer is exactly as large as the display,contains no additional saved lines. When the alternatescreen buffer is active, you cannot scroll back to viewsaved lines. Xterm provides control sequences andmenu entries for switching between the two.
Most full-screen applications use terminfo or termcap toobtain strings used to start/stop full-screen mode, i.e.,smcup and rmcup for terminfo, or thecorresponding ti and te for termcap. ThetiteInhibit resource removes the ti andte strings from the TERMCAP string which is set inthe environment for some platforms. That is not done whenxterm is built with terminfo libraries becauseterminfo does not provide the whole text of the termcap datain one piece. It would not work for terminfo anyway, sinceterminfo data is not passed in environment variables;setting an environment variable in this manner would have noeffect on the application’s ability to switch betweennormal and alternate screen buffers. Instead, the newerprivate mode controls (such as 1 0 4 9 ) for switchingbetween normal and alternate screen buffers simply disablethe switching. They add other features such as clearing thedisplay for the same reason: to make the details ofswitching independent of the application that requests theswitch.

Bracketed Paste Mode

When bracketedpaste mode is set, pasted text is bracketed with controlsequences so that the program can differentiate pasted textfrom typed-in text. When bracketed paste mode is set, theprogram will receive: ESC [ 200 ~, followed by the pastedtext, followed by ESC [ 201 ~.

Mouse Tracking

The VT widget canbe set to send the mouse position and other information onbutton presses. These modes are typically used by editorsand other full-screen applications that want to make use ofthe mouse.

There are sixmutually exclusive modes. One is DEC Locator mode, enabledby the DECELR CSI Ps ; P s ´zcontrol sequence, and is not described here (controlsequences are summarized above). The remaining five modesare each enabled (or disabled) by a different parameter inDECSET CSI ? Pm h or DECRSTCSI ? Pm l control sequence.

Manifest constantsfor the parameter values are defined in xcharmouse.has follows:

#defineSET_X10_MOUSE 9
#define SET_VT200_MOUSE 1000
#define SET_VT200_HIGHLIGHT_MOUSE 1001
#define SET_BTN_EVENT_MOUSE 1002
#define SET_ANY_EVENT_MOUSE 1003

The motionreporting modes are strictly xterm extensions, andare not part of any standard, though they are analogous tothe DEC VT200 DECELR locator reports.

Parameters (such aspointer position and button number) for all mouse trackingescape sequences generated by xterm encode numericparameters in a single character as value+32. Forexample, ! specifies the value 1. The upper left characterposition on the terminal is denoted as 1,1.

X10 compatibilitymode sends an escape sequence only on button press, encodingthe location and the mouse button pressed. It is enabled byspecifying parameter 9 to DECSET. On button press,xterm sends CSI M Cb C x C y(6 characters). C b is button−1.C x and C y arethe x and y coordinates of the mouse when the button waspressed.

Normal trackingmode sends an escape sequence on both button press andrelease. Modifier key (shift, ctrl, meta) information isalso sent. It is enabled by specifying parameter 1000 toDECSET. On button press or release, xterm sendsCSI M C b Cx C y . The low two bitsof C b encode button information:0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release. Thenext three bits encode the modifiers which were down whenthe button was pressed and are added together: 4=Shift,8=Meta, 16=Control. Note however that the shift and controlbits are normally unavailable because xterm uses thecontrol modifier with mouse for popup menus, and the shiftmodifier is used in the default translations for buttonevents. The Meta modifier recognized by xtermis the mod1 mask, and is not necessarily the"Meta" key (see xmodmap). Cx and C y are the xand y coordinates of the mouse event, encoded as in X10mode.

Wheel mice mayreturn buttons 4 and 5. Those buttons are represented by thesame event codes as buttons 1 and 2 respectively, exceptthat 64 is added to the event code. Release events for thewheel buttons are not reported.

Mouse highlighttracking notifies a program of a button press, receives arange of lines from the program, highlights the regioncovered by the mouse within that range until button release,and then sends the program the release coordinates. It isenabled by specifying parameter 1001 to DECSET. Highlightingis performed only for button 1, though other button eventscan be received. Warning: use of this mode requires acooperating program or it will hang xterm. On buttonpress, the same information as for normal tracking isgenerated; xterm then waits for the program to sendmouse tracking information. All X events are ignoreduntil the proper escape sequence is received from thepty: CSI Ps ; P s ; Ps ; P s ; Ps T . The parameters are func, startx,starty, firstrow, and lastrow. func is non-zeroto initiate highlight tracking and zero to abort.startx and starty give the starting x and ylocation for the highlighted region. The ending locationtracks the mouse, but will never be above rowfirstrow and will always be above row lastrow.(The top of the screen is row 1.) When the button isreleased, xterm reports the ending position one oftwo ways: if the start and end coordinates are valid textlocations: CSI t Cx C y . If eithercoordinate is past the end of the line:CSI T C x Cy C x C y Cx C y . The parameters arestartx, starty, endx, endy, mousex, and mousey.startx, starty, endx, and endy give the startingand ending character positions of the region. mousexand mousey give the location of the mouse at buttonup, which may not be over a character.

Button-eventtracking is essentially the same as normal tracking, butxterm also reports button-motion events. Motionevents are reported only if the mouse pointer has moved to adifferent character cell. It is enabled by specifyingparameter 1002 to DECSET. On button press or release,xterm sends the same codes used by normal trackingmode. On button-motion events, xterm adds 32 to theevent code (the third character, C b). The other bits of the event code specify button andmodifier keys as in normal mode. For example, motion intocell x,y with button 1 down is reported asCSI M @ C xC y . ( @ = 32 + 0 (button 1) + 32(motion indicator) ). Similarly, motion with button 3 downis reported as CSI M B Cx C y . ( B = 32 + 2(button 3) + 32 (motion indicator) ).

Any-event mode isthe same as button-event mode, except that all motion eventsare reported, even if no mouse button is down. It is enabledby specifying 1003 to DECSET.

Tektronix 4014 Mode

Most of thesesequences are standard Tektronix 4014 control sequences.Graph mode supports the 12-bit addressing of the Tektronix4014. The major features missing are the write-through anddefocused modes. This document does not describe thecommands used in the various Tektronix plotting modes butdoes 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)

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 FF

PAGE (Clear Screen) (ESC Ctrl-L)

ESC SO

Begin 4015 APL mode (ignored byxterm) (ESC Ctrl-N)

ESC SI

End 4015 APL mode (ignored by xterm)(ESC Ctrl-O)

ESC ETB

COPY (Save Tektronix Codes to fileCOPYyyyy-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

OSC Ps ; P tBEL

Set Text Parameters of VT window

P s = 0→ Change Icon Name and Window Title to Pt
P s
= 1 → Change Icon Name to Pt
P s
= 2 → Change Window Title toP t
P s
= 4 6 → Change Log File to Pt (normally disabled by a compile-timeoption)

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 LineVectors

ESC j

Defocused Z Axis and Dot-Dashed Vectors

ESC k

Defocused Z Axis and Short-DashedVectors

ESC l

Defocused Z Axis and Long-DashedVectors

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-DashedVectors

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-_)

VT52 Mode

Parameters forcursor movement are at the end of theESC Y escape sequence. Eachordinate is encoded in a single character asvalue+32. For example, ! is 1. The screen coordinatesystem is 0-based.

ESCA

Cursor up.

ESC B

Cursor down.

ESC C

Cursor right.

ESC D

Cursor left.

ESC F

Enter graphics mode.

ESC G

Exit graphics mode.

ESC H

Move the cursor to the home position.

ESC I

Reverse line feed.

ESC J

Erase from the cursor to the end of thescreen.

ESC K

Erase from the cursor to the end of theline.

ESC Y Ps P s

Move the cursor to given row andcolumn.

ESC Z

Identify

ESC / Z (‘‘I am aVT52.’’)

ESC =

Enter alternate keypad mode.

ESC >

Exit alternate keypad mode.

ESC <

Exit VT52 mode (Enter VT100 mode).

Top Articles

Latest Posts

Article information

Author: Cheryll Lueilwitz

Last Updated: 01/30/2023

Views: 5940

Rating: 4.3 / 5 (74 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Cheryll Lueilwitz

Birthday: 1997-12-23

Address: 4653 O'Kon Hill, Lake Juanstad, AR 65469

Phone: +494124489301

Job: Marketing Representative

Hobby: Reading, Ice skating, Foraging, BASE jumping, Hiking, Skateboarding, Kayaking

Introduction: My name is Cheryll Lueilwitz, I am a sparkling, clean, super, lucky, joyous, outstanding, lucky person who loves writing and wants to share my knowledge and understanding with you.