Ctlseqs
Ctlseqs
Edward Moy
University of California, Berkeley
Revised by
Stephen Gildea
X Consortium (1994)
Thomas Dickey
XFree86 Project (1996-2006)
invisible-island.net (2006-2019)
updated for XTerm Patch #348 (2019/07/11)
Definitions
o Intermediate, parameter and final bytes may use the same codes as
graphic characters, but they are processed as part of a control
sequence and are not actually graphic characters.
ESC D
Index (IND is 0x84).
ESC E
Next Line (NEL is 0x85).
ESC H
Tab Set (HTS is 0x88).
ESC M
Reverse Index (RI is 0x8d).
ESC N
Single Shift Select of G2 Character Set (SS2 is 0x8e), VT220.
This affects next character only.
ESC O
Single Shift Select of G3 Character Set (SS3 is 0x8f), VT220.
This affects next character 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).
The escape codes to designate and invoke character sets are specified by
ISO 2022 (see that document for a discussion of character sets).
Many of the features are optional; xterm can be configured and built
without support for them.
Single-character functions
BS Backspace (Ctrl-H).
SP Space.
ESC % @ Select default character set. That is ISO 8859-1 (ISO 2022).
ESC l Memory Lock (per HP terminals). Locks memory above the cur-
sor.
Device-Control functions
DCS Ps ; Ps | Pt ST
User-Defined Keys (DECUDK), VT220 and up.
DCS $ q Pt ST
Request Status String (DECRQSS), VT420 and up.
The string following the "q" is one of the following:
m -> SGR
" p -> DECSCL
SP q -> DECSCUSR
" q -> DECSCA
r -> DECSTBM
s -> DECSLRM
t -> DECSLPP
$ | -> DECSCPP
* | -> DECSNLS
xterm responds with DCS 1 $ r Pt ST for valid requests,
replacing the Pt with the corresponding CSI string, or DCS 0 $
r Pt ST for invalid requests.
DCS Ps $ t Pt ST
Restore presentation status (DECRSPS), VT320 and up. The con-
trol can be converted from a response from DECCIR or DECTABSR
by changing the first "u" to a "t"
Ps = 1 -> DECCIR
Ps = 2 -> DECTABSR
DCS + p Pt ST
Set Termcap/Terminfo Data (xterm). The string following the
"p" is a name to use for retrieving data from the terminal
database. The data will be used for the "tcap" keyboard con-
figuration's function- and special-keys, as well as by the
Request Termcap/Terminfo String control.
DCS + q Pt ST
Request Termcap/Terminfo String (xterm). The string following
the "q" is a list of names encoded in hexadecimal (2 digits
per character) separated by ; which correspond to termcap or
terminfo key names.
A few special features are also recognized, which are not key
names:
o Co for termcap colors (or colors for terminfo colors), and
o TN for termcap name (or name for terminfo name).
o RGB for the ncurses direct-color extension.
Only a terminfo name is provided, since termcap applica-
tions cannot use this information.
xterm responds with
DCS 1 + r Pt ST for valid requests, adding to Pt an = , and
the value of the corresponding string that xterm would send,
or
DCS 0 + r Pt ST for invalid requests.
The strings are encoded in hexadecimal (2 digits per charac-
ter).
CSI Ps SP @
Shift left Ps columns(s) (default = 1) (SL), ECMA-48.
CSI Ps SP A
Shift right Ps columns(s) (default = 1) (SR), ECMA-48.
CSI Ps ; Ps H
Cursor Position [row;column] (default = [1,1]) (CUP).
CSI ? Ps J
Erase in Display (DECSED), VT220.
Ps = 0 -> Selective Erase Below (default).
Ps = 1 -> Selective Erase Above.
Ps = 2 -> Selective Erase All.
Ps = 3 -> Selective Erase Saved Lines (xterm).
CSI ? Ps K
Erase in Line (DECSEL), VT220.
Ps = 0 -> Selective Erase to Right (default).
Ps = 1 -> Selective Erase to Left.
Ps = 2 -> Selective Erase All.
CSI ? Pi ; Pa ; Pv S
If configured to support either Sixel Graphics or ReGIS Graph-
ics, xterm accepts a three-parameter control sequence, where
Pi, Pa and Pv are the item, action and value:
Pa = 1 -> read
Pa = 2 -> reset to default
Pa = 3 -> set to value in Pv
Pa = 4 -> read the maximum allowed value
Pv can be omitted except when setting (Pa == 3 ).
Pv = n <- A single integer is used for color registers.
Pv = width ; height <- Two integers for graphics geometry.
CSI ? Pi ; Ps ; Pv S
Notes:
o The current implementation allows reading the graphics
sizes, but disallows modifying those sizes because that is
done once, using resource-values.
o Graphics geometry is not necessarily the same as "window
size" (see the dtterm window manipulation extensions).
For example, xterm limits the maximum graphics geometry at
compile time (1000x1000 as of version 328) although the
window size can be larger.
o While resizing a window will always change the current
graphics geometry, the reverse is not true. Setting
graphics geometry does not affect the window size.
CSI Ps ; Ps ; Ps ; Ps ; Ps T
Initiate highlight mouse tracking. Parameters are
[func;startx;starty;firstrow;lastrow]. See the section Mouse
Tracking.
CSI > Ps ; Ps T
Reset one or more features of the title modes to the default
value. Normally, "reset" disables the feature. It is possi-
ble to disable the ability to reset features by compiling a
different default for the title modes into xterm.
CSI = Ps c
Send Device Attributes (Tertiary DA).
Ps = 0 -> report Terminal Unit ID (default), VT400. XTerm
uses zeros for the site code and serial number in its DECRPTUI
response.
CSI > Ps c
Send Device Attributes (Secondary DA).
Ps = 0 or omitted -> request the terminal's identification
code. The response depends on the decTerminalID resource set-
ting. It should apply only to VT220 and up, but xterm extends
this to VT100.
-> CSI > Pp ; Pv ; Pc c
where Pp denotes the terminal type
Pp = 0 -> "VT100".
Pp = 1 -> "VT220".
Pp = 2 -> "VT240".
Pp = 1 8 -> "VT330".
Pp = 1 9 -> "VT340".
Pp = 2 4 -> "VT320".
Pp = 4 1 -> "VT420".
Pp = 6 1 -> "VT510".
Pp = 6 4 -> "VT520".
Pp = 6 5 -> "VT525".
CSI Ps ; Ps f
Horizontal and Vertical Position [row;column] (default =
[1,1]) (HVP).
CSI ? Pm h
DEC Private Mode Set (DECSET).
Ps = 1 -> Application Cursor Keys (DECCKM), VT100.
Ps = 2 -> Designate USASCII for character sets G0-G3
(DECANM), VT100, and set VT100 mode.
Ps = 3 -> 132 Column Mode (DECCOLM), VT100.
Ps = 4 -> Smooth (Slow) Scroll (DECSCLM), VT100.
Ps = 5 -> Reverse Video (DECSCNM), VT100.
Ps = 6 -> Origin Mode (DECOM), VT100.
Ps = 7 -> Auto-wrap Mode (DECAWM), VT100.
Ps = 8 -> Auto-repeat Keys (DECARM), VT100.
Ps = 9 -> Send Mouse X & Y on button press. See the sec-
tion Mouse Tracking. This is the X10 xterm mouse protocol.
Ps = 1 0 -> Show toolbar (rxvt).
Ps = 1 2 -> Start Blinking Cursor (AT&T 610).
Ps = 1 3 -> Start Blinking Cursor (set only via resource or
menu).
Ps = 1 4 -> Enable XOR of Blinking Cursor control sequence
and menu.
Ps = 1 8 -> Print form feed (DECPFF), VT220.
Ps = 1 9 -> Set print extent to full screen (DECPEX),
VT220.
Ps = 2 5 -> Show Cursor (DECTCEM), VT220.
Ps = 3 0 -> Show scrollbar (rxvt).
Ps = 3 5 -> Enable font-shifting functions (rxvt).
Ps = 3 8 -> Enter Tektronix Mode (DECTEK), VT240, xterm.
Ps = 4 0 -> Allow 80 -> 132 Mode, xterm.
Ps = 4 1 -> more(1) fix (see curses resource).
Ps = 4 2 -> Enable National Replacement Character sets
(DECNRCM), VT220.
Ps = 4 4 -> Turn On Margin Bell, xterm.
Ps = 4 5 -> Reverse-wraparound Mode, xterm.
Ps = 4 6 -> Start Logging, xterm. This is normally dis-
abled by a compile-time option.
Ps = 4 7 -> Use Alternate Screen Buffer, xterm. This may
be disabled by the titeInhibit resource.
Ps = 6 6 -> Application keypad (DECNKM), VT320.
Ps = 6 7 -> Backarrow key sends backspace (DECBKM), VT340,
VT420.
Ps = 6 9 -> Enable left and right margin mode (DECLRMM),
VT420 and up.
Ps = 9 5 -> Do not clear screen when DECCOLM is set/reset
(DECNCSM), VT510 and up.
Ps = 1 0 0 0 -> Send Mouse X & Y on button press and
release. See the section Mouse Tracking. This is the X11
xterm mouse protocol.
Ps = 1 0 0 1 -> Use Hilite Mouse Tracking, xterm.
Ps = 1 0 0 2 -> Use Cell Motion (button event) Mouse Track-
ing, xterm.
Ps = 1 0 0 3 -> Use All Motion (any event) Mouse Tracking,
xterm.
Ps = 1 0 0 4 -> Send FocusIn/FocusOut events, xterm.
Ps = 1 0 0 5 -> Enable UTF-8 Mouse Mode, xterm.
Ps = 1 0 0 6 -> Enable SGR Mouse Mode, xterm.
Ps = 1 0 0 7 -> Enable Alternate Scroll Mode, xterm. This
corresponds to the alternateScroll resource.
Ps = 1 0 1 0 -> Scroll to bottom on tty output (rxvt).
Ps = 1 0 1 1 -> Scroll to bottom on key press (rxvt).
Ps = 1 0 1 5 -> Enable urxvt Mouse Mode.
Ps = 1 0 3 4 -> Interpret "meta" key, xterm. This sets
eighth bit of keyboard input (and enables the eightBitInput
resource).
Ps = 1 0 3 5 -> Enable special modifiers for Alt and Num-
Lock keys, xterm. This enables the numLock resource.
Ps = 1 0 3 6 -> Send ESC when Meta modifies a key, xterm.
This enables the metaSendsEscape resource.
Ps = 1 0 3 7 -> Send DEL from the editing-keypad Delete
key, xterm.
Ps = 1 0 3 9 -> Send ESC when Alt modifies a key, xterm.
This enables the altSendsEscape resource, xterm.
Ps = 1 0 4 0 -> Keep selection even if not highlighted,
xterm. This enables the keepSelection resource.
Ps = 1 0 4 1 -> Use the CLIPBOARD selection, xterm. This
enables the selectToClipboard resource.
Ps = 1 0 4 2 -> Enable Urgency window manager hint when
Control-G is received, xterm. This enables the bellIsUrgent
resource.
Ps = 1 0 4 3 -> Enable raising of the window when Control-G
is received, xterm. This enables the popOnBell resource.
Ps = 1 0 4 4 -> Reuse the most recent data copied to CLIP-
BOARD, xterm. This enables the keepClipboard resource.
Ps = 1 0 4 6 -> Enable switching to/from Alternate Screen
Buffer, xterm. This works for terminfo-based systems, updat-
ing the titeInhibit resource.
Ps = 1 0 4 7 -> Use Alternate Screen Buffer, xterm. This
may be disabled by the titeInhibit resource.
Ps = 1 0 4 8 -> Save cursor as in DECSC, xterm. This may
be disabled by the titeInhibit resource.
Ps = 1 0 4 9 -> Save cursor as in DECSC, xterm. After sav-
ing the cursor, switch to the Alternate Screen Buffer, clear-
ing it first. This may be disabled by the titeInhibit
resource. This control combines the effects of the 1 0 4 7
and 1 0 4 8 modes. Use this with terminfo-based applications
rather than the 4 7 mode.
Ps = 1 0 5 0 -> Set terminfo/termcap function-key mode,
xterm.
Ps = 1 0 5 1 -> Set Sun function-key mode, xterm.
Ps = 1 0 5 2 -> Set HP function-key mode, xterm.
Ps = 1 0 5 3 -> Set SCO function-key mode, xterm.
Ps = 1 0 6 0 -> Set legacy keyboard emulation (i.e, X11R6),
xterm.
Ps = 1 0 6 1 -> Set VT220 keyboard emulation, xterm.
Ps = 2 0 0 4 -> Set bracketed paste mode, xterm.
CSI ? Pm i
Media Copy (MC), DEC-specific.
Ps = 1 -> Print line containing cursor.
Ps = 4 -> Turn off autoprint mode.
Ps = 5 -> Turn on autoprint mode.
Ps = 1 0 -> Print composed display, ignores DECPEX.
Ps = 1 1 -> Print all pages.
CSI ? Pm l
DEC Private Mode Reset (DECRST).
Ps = 1 -> Normal Cursor Keys (DECCKM), VT100.
Ps = 2 -> Designate VT52 mode (DECANM), VT100.
Ps = 3 -> 80 Column Mode (DECCOLM), VT100.
Ps = 4 -> Jump (Fast) Scroll (DECSCLM), VT100.
Ps = 5 -> Normal Video (DECSCNM), VT100.
Ps = 6 -> Normal Cursor Mode (DECOM), VT100.
Ps = 7 -> No Auto-wrap Mode (DECAWM), VT100.
Ps = 8 -> No Auto-repeat Keys (DECARM), VT100.
Ps = 9 -> Don't send Mouse X & Y on button press, xterm.
Ps = 1 0 -> Hide toolbar (rxvt).
Ps = 1 2 -> Stop Blinking Cursor (AT&T 610).
Ps = 1 3 -> Disable Blinking Cursor (reset only via
resource or menu).
Ps = 1 4 -> Disable XOR of Blinking Cursor control sequence
and menu.
Ps = 1 8 -> Don't print form feed (DECPFF).
Ps = 1 9 -> Limit print to scrolling region (DECPEX).
Ps = 2 5 -> Hide Cursor (DECTCEM), VT220.
Ps = 3 0 -> Don't show scrollbar (rxvt).
Ps = 3 5 -> Disable font-shifting functions (rxvt).
Ps = 4 0 -> Disallow 80 -> 132 Mode, xterm.
Ps = 4 1 -> No more(1) fix (see curses resource).
Ps = 4 2 -> Disable National Replacement Character sets
(DECNRCM), VT220.
Ps = 4 4 -> Turn Off Margin Bell, xterm.
Ps = 4 5 -> No Reverse-wraparound Mode, xterm.
Ps = 4 6 -> Stop Logging, xterm. This is normally disabled
by a compile-time option.
Ps = 4 7 -> Use Normal Screen Buffer, xterm.
Ps = 6 6 -> Numeric keypad (DECNKM), VT320.
Ps = 6 7 -> Backarrow key sends delete (DECBKM), VT340,
VT420.
Ps = 6 9 -> Disable left and right margin mode (DECLRMM),
VT420 and up.
Ps = 9 5 -> Clear screen when DECCOLM is set/reset (DEC-
NCSM), VT510 and up.
Ps = 1 0 0 0 -> Don't send Mouse X & Y on button press and
release. See the section Mouse Tracking.
Ps = 1 0 0 1 -> Don't use Hilite Mouse Tracking, xterm.
Ps = 1 0 0 2 -> Don't use Cell Motion (button event) Mouse
Tracking, xterm.
Ps = 1 0 0 3 -> Don't use All Motion (any event) Mouse
Tracking, xterm.
Ps = 1 0 0 4 -> Don't send FocusIn/FocusOut events, xterm.
Ps = 1 0 0 5 -> Disable UTF-8 Mouse Mode, xterm.
Ps = 1 0 0 6 -> Disable SGR Mouse Mode, xterm.
Ps = 1 0 0 7 -> Disable Alternate Scroll Mode, xterm. This
corresponds to the alternateScroll resource.
Ps = 1 0 1 0 -> Don't scroll to bottom on tty output
(rxvt).
Ps = 1 0 1 1 -> Don't scroll to bottom on key press (rxvt).
Ps = 1 0 1 5 -> Disable urxvt Mouse Mode.
Ps = 1 0 3 4 -> Don't interpret "meta" key, xterm. This
disables the eightBitInput resource.
Ps = 1 0 3 5 -> Disable special modifiers for Alt and Num-
Lock keys, xterm. This disables the numLock resource.
Ps = 1 0 3 6 -> Don't send ESC when Meta modifies a key,
xterm. This disables the metaSendsEscape resource.
Ps = 1 0 3 7 -> Send VT220 Remove from the editing-keypad
Delete key, xterm.
Ps = 1 0 3 9 -> Don't send ESC when Alt modifies a key,
xterm. This disables the altSendsEscape resource.
Ps = 1 0 4 0 -> Do not keep selection when not highlighted,
xterm. This disables the keepSelection resource.
Ps = 1 0 4 1 -> Use the PRIMARY selection, xterm. This
disables the selectToClipboard resource.
Ps = 1 0 4 2 -> Disable Urgency window manager hint when
Control-G is received, xterm. This disables the bellIsUrgent
resource.
Ps = 1 0 4 3 -> Disable raising of the window when Control-
G is received, xterm. This disables the popOnBell resource.
Ps = 1 0 4 6 -> Disable switching to/from Alternate Screen
Buffer, xterm. This works for terminfo-based systems, updat-
ing the titeInhibit resource. If currently using the Alter-
nate Screen Buffer, xterm switches to the Normal Screen Buf-
fer.
Ps = 1 0 4 7 -> Use Normal Screen Buffer, xterm. Clear the
screen first if in the Alternate Screen Buffer. This may be
disabled by the titeInhibit resource.
Ps = 1 0 4 8 -> Restore cursor as in DECRC, xterm. This
may be disabled by the titeInhibit resource.
Ps = 1 0 4 9 -> Use Normal Screen Buffer and restore cursor
as in DECRC, xterm. This may be disabled by the titeInhibit
resource. This combines the effects of the 1 0 4 7 and 1 0 4
8 modes. Use this with terminfo-based applications rather
than the 4 7 mode.
Ps = 1 0 5 0 -> Reset terminfo/termcap function-key mode,
xterm.
Ps = 1 0 5 1 -> Reset Sun function-key mode, xterm.
Ps = 1 0 5 2 -> Reset HP function-key mode, xterm.
Ps = 1 0 5 3 -> Reset SCO function-key mode, xterm.
Ps = 1 0 6 0 -> Reset legacy keyboard emulation (i.e,
X11R6), xterm.
Ps = 1 0 6 1 -> Reset keyboard emulation to Sun/PC style,
xterm.
Ps = 2 0 0 4 -> Reset bracketed paste mode, xterm.
CSI > Ps ; Ps m
Set or reset resource-values used by xterm to decide whether
to construct escape sequences holding information about the
modifiers pressed with a given key.
Ps = 0 -> modifyKeyboard.
Ps = 1 -> modifyCursorKeys.
Ps = 2 -> modifyFunctionKeys.
Ps = 4 -> modifyOtherKeys.
CSI 1 ; 2 R , or
CSI 1 ; 5 R , or
CSI 1 ; 6 R , etc.
CSI > Ps n
Disable modifiers which may be enabled via the CSI > Ps; Ps m
sequence. This corresponds to a resource value of "-1", which
cannot be set with the other sequence.
Ps = 0 -> modifyKeyboard.
Ps = 1 -> modifyCursorKeys.
Ps = 2 -> modifyFunctionKeys.
Ps = 4 -> modifyOtherKeys.
CSI ? Ps n
Device Status Report (DSR, DEC-specific).
Ps = 6 -> Report Cursor Position (DECXCPR) [row;column] as
CSI ? r ; c R (assumes the default page, i.e., "1").
Ps = 1 5 -> Report Printer status as CSI ? 1 0 n (ready).
or CSI ? 1 1 n (not ready).
Ps = 2 5 -> Report UDK status as CSI ? 2 0 n (unlocked) or
CSI ? 2 1 n (locked).
Ps = 2 6 -> Report Keyboard status as
CSI ? 2 7 ; 1 ; 0 ; 0 n (North American).
CSI > Ps p
Set resource value pointerMode. This is used by xterm to
decide whether to hide the pointer cursor as the user types.
CSI Ps ; Ps " p
Set conformance level (DECSCL), VT220 and up.
The 7-bit and 8-bit control modes can also be set by S7C1T and
S8C1T, but DECSCL is preferred.
CSI Ps $ p
Request ANSI mode (DECRQM). For VT300 and up, reply DECRPM is
CSI Ps; Pm$ y
where Ps is the mode number as in SM/RM, and Pm is the mode
value:
0 - not recognized
1 - set
2 - reset
3 - permanently set
4 - permanently reset
CSI ? Ps $ p
Request DEC private mode (DECRQM). For VT300 and up, reply
DECRPM is
CSI ? Ps; Pm$ y
where Ps is the mode number as in DECSET/DECSET, Pm is the
mode value as in the ANSI DECRQM.
Two private modes are read-only (i.e., 1 3 and 1 4 ), pro-
vided only for reporting their values using this control
sequence. They correspond to the resources cursorBlink and
cursorBlinkXOR.
CSI # p
CSI Ps ; Ps # p
Push video attributes onto stack (XTPUSHSGR), xterm. This is
an alias for CSI # { , used to work around language limita-
tions of C#.
CSI Ps SP q
Set cursor style (DECSCUSR), VT520.
Ps = 0 -> blinking block.
Ps = 1 -> blinking block (default).
Ps = 2 -> steady block.
Ps = 3 -> blinking underline.
Ps = 4 -> steady underline.
Ps = 5 -> blinking bar (xterm).
Ps = 6 -> steady bar (xterm).
CSI Ps " q
Select character protection attribute (DECSCA). Valid values
for the parameter:
Ps = 0 -> DECSED and DECSEL can erase (default).
Ps = 1 -> DECSED and DECSEL cannot erase.
Ps = 2 -> DECSED and DECSEL can erase.
CSI Ps ; Ps r
Set Scrolling Region [top;bottom] (default = full size of win-
dow) (DECSTBM), VT100.
CSI ? Pm r
Restore DEC Private Mode Values. The value of Ps previously
saved is restored. Ps values are the same as for DECSET.
CSI Pt ; Pl ; Pb ; Pr ; Ps $ r
Change Attributes in Rectangular Area (DECCARA), VT400 and up.
Pt ; Pl ; Pb ; Pr denotes the rectangle.
Ps denotes the SGR attributes to change: 0, 1, 4, 5, 7.
CSI Pl ; Pr s
Set left and right margins (DECSLRM), VT420 and up. This is
available only when DECLRMM is enabled.
CSI ? Pm s
Save DEC Private Mode Values. Ps values are the same as for
DECSET.
CSI Ps ; Ps ; Ps t
Window manipulation (from dtterm, as well as extensions by
xterm). These controls may be disabled using the allowWin-
dowOps resource.
CSI > Ps ; Ps t
This xterm control sets one or more features of the title
modes. Each parameter enables a single feature.
Ps = 0 -> Set window/icon labels using hexadecimal.
Ps = 1 -> Query window/icon labels using hexadecimal.
Ps = 2 -> Set window/icon labels using UTF-8.
Ps = 3 -> Query window/icon labels using UTF-8. (See dis-
cussion of Title Modes)
CSI Ps SP t
Set warning-bell volume (DECSWBV), VT520.
Ps = 0 or 1 -> off.
Ps = 2 , 3 or 4 -> low.
Ps = 5 , 6 , 7 , or 8 -> high.
CSI Pt ; Pl ; Pb ; Pr ; Ps $ t
Reverse Attributes in Rectangular Area (DECRARA), VT400 and
up.
Pt ; Pl ; Pb ; Pr denotes the rectangle.
Ps denotes the attributes to reverse, i.e., 1, 4, 5, 7.
CSI Ps SP u
Set margin-bell volume (DECSMBV), VT520.
Ps = 1 -> off.
Ps = 2 , 3 or 4 -> low.
Ps = 0 , 5 , 6 , 7 , or 8 -> high.
CSI Pt ; Pl ; Pb ; Pr ; Pp ; Pt ; Pl ; Pp $ v
Copy Rectangular Area (DECCRA), VT400 and up.
Pt ; Pl ; Pb ; Pr denotes the rectangle.
Pp denotes the source page.
Pt ; Pl denotes the target location.
Pp denotes the target page.
CSI Ps $ w
Request presentation state report (DECRQPSR), VT320 and up.
Ps = 0 -> error.
Ps = 1 -> cursor information report (DECCIR).
Response is
DCS 1 $ u Pt ST
Refer to the VT420 programming manual, which requires six
pages to document the data string Pt,
Ps = 2 -> tab stop report (DECTABSR).
Response is
DCS 2 $ u Pt ST
The data string Pt is a list of the tab-stops, separated by
"/" characters.
CSI Pt ; Pl ; Pb ; Pr ' w
Enable Filter Rectangle (DECEFR), VT420 and up.
Parameters are [top;left;bottom;right].
Defines the coordinates of a filter rectangle and activates
it. Anytime the locator is detected outside of the filter
rectangle, an outside rectangle event is generated and the
rectangle is disabled. Filter rectangles are always treated
as "one-shot" events. Any parameters that are omitted default
to the current locator position. If all parameters are omit-
ted, any locator motion will be reported. DECELR always can-
cels any prevous rectangle definition.
CSI Ps * x
Select Attribute Change Extent (DECSACE), VT420 and up.
Ps = 0 -> from start to end position, wrapped.
Ps = 1 -> from start to end position, wrapped.
Ps = 2 -> rectangle (exact).
CSI Pc ; Pt ; Pl ; Pb ; Pr $ x
Fill Rectangular Area (DECFRA), VT420 and up.
Pc is the character to use.
Pt ; Pl ; Pb ; Pr denotes the rectangle.
CSI Ps # y
Select checksum extension (XTCHECKSUM), xterm. The bits of Ps
modify the calculation of the checksum returned by DECRQCRA:
0 -> do not negate the result.
1 -> do not report the VT100 video attributes.
2 -> do not omit checksum for blanks.
3 -> omit checksum for cells not explicitly initialized.
4 -> do not mask cell value to 8 bits or ignore combining
characters.
5 -> do not mask cell value to 7 bits.
CSI Pi ; Pg ; Pt ; Pl ; Pb ; Pr * y
Request Checksum of Rectangular Area (DECRQCRA), VT420 and up.
Response is
DCS Pi ! ~ x x x x ST
Pi is the request id.
Pg is the page number.
Pt ; Pl ; Pb ; Pr denotes the rectangle.
The x's are hexadecimal digits 0-9 and A-F.
CSI Ps ; Pu ' z
Enable Locator Reporting (DECELR).
Valid values for the first parameter:
Ps = 0 -> Locator disabled (default).
Ps = 1 -> Locator enabled.
Ps = 2 -> Locator enabled for one report, then disabled.
The second parameter specifies the coordinate unit for locator
reports.
Valid values for the second parameter:
Pu = 0 <- or omitted -> default to character cells.
Pu = 1 <- device physical pixels.
Pu = 2 <- character cells.
CSI Pt ; Pl ; Pb ; Pr $ z
Erase Rectangular Area (DECERA), VT400 and up.
Pt ; Pl ; Pb ; Pr denotes the rectangle.
CSI Pm ' {
Select Locator Events (DECSLE).
Valid values for the first (and any additional parameters)
are:
Ps = 0 -> only respond to explicit host requests (DECRQLP).
This is default. It also cancels any filter rectangle.
Ps = 1 -> report button down transitions.
Ps = 2 -> do not report button down transitions.
Ps = 3 -> report button up transitions.
Ps = 4 -> do not report button up transitions.
CSI # {
CSI Ps ; Ps # {
Push video attributes onto stack (XTPUSHSGR), xterm. The
optional parameters correspond to the SGR encoding for video
attributes, except for colors (which do not have a unique SGR
code):
Ps = 1 -> Bold.
Ps = 2 -> Faint.
Ps = 3 -> Italicized.
Ps = 4 -> Underlined.
Ps = 5 -> Blink.
Ps = 7 -> Inverse.
Ps = 8 -> Invisible.
Ps = 9 -> Crossed-out characters.
Ps = 1 0 -> Foreground color.
Ps = 1 1 -> Background color.
Ps = 2 1 -> Doubly-underlined.
CSI Pt ; Pl ; Pb ; Pr $ {
Selective Erase Rectangular Area (DECSERA), VT400 and up.
Pt ; Pl ; Pb ; Pr denotes the rectangle.
CSI Pt ; Pl ; Pb ; Pr # |
Report selected graphic rendition (XTREPORTSGR), xterm. The
response is an SGR sequence which contains the attributes
which are common to all cells in a rectangle.
Pt ; Pl ; Pb ; Pr denotes the rectangle.
CSI Ps $ |
Select columns per page (DECSCPP), VT340.
Ps = 0 -> 80 columns, default if Ps omitted.
Ps = 8 0 -> 80 columns.
Ps = 1 3 2 -> 132 columns.
CSI Ps ' |
Request Locator Position (DECRQLP).
Valid values for the parameter are:
Ps = 0 , 1 or omitted -> transmit a single DECLRP locator
report.
CSI Ps * |
Select number of lines per screen (DECSNLS), VT420 and up.
CSI Pm ' }
Insert Ps Column(s) (default = 1) (DECIC), VT420 and up.
CSI Pm ' ~
Delete Ps Column(s) (default = 1) (DECDC), VT420 and up.
OSC Ps ; Pt BEL
OSC Ps ; Pt ST
Set Text Parameters. For colors and font, if Pt is a "?", the
control sequence elicits a response which consists of the con-
trol sequence which would set the corresponding value. The
dtterm control sequences allow you to determine the icon name
and window title.
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 = 3 -> Set X property on top-level window. Pt should be
in the form "prop=value", or just "prop" to delete the prop-
erty.
Ps = 4 ; c ; spec -> Change Color Number c to the color
specified by spec. This can be a name or RGB specification as
per XParseColor. Any number of c/spec pairs may be given.
The color numbers correspond to the ANSI colors 0-7, their
bright versions 8-15, and if supported, the remainder of the
88-color or 256-color table.
Privacy Message
Many keyboards have keys labeled "Alt". Few have keys labeled "Meta".
However, xterm's default translations use the Meta modifier. Common
keyboard configurations assign the Meta modifier to an "Alt" key. By
using xmodmap one may have the modifier assigned to a different key, and
have "real" alt and meta keys. Here is an example:
The table shows the result for a given character "x" with modifiers
according to the default translations with the resources set on or off.
This assumes altIsNotMeta is set:
-----------------------------------------------------------
key altSendsEscape metaSendsEscape result
-----------+----------------+-----------------+------------
x | off | off | x
Meta-x | off | off | shift
Alt-x | off | off | shift
Alt+Meta-x | off | off | shift
x | ON | off | x
Meta-x | ON | off | shift
Alt-x | ON | off | ESC x
Alt+Meta-x | ON | off | ESC shift
x | off | ON | x
Meta-x | off | ON | ESC x
Alt-x | off | ON | shift
Alt+Meta-x | off | ON | ESC shift
x | ON | ON | x
Meta-x | ON | ON | ESC x
Alt-x | ON | ON | ESC x
Alt+Meta-x | ON | ON | ESC x
-----------+----------------+-----------------+------------
X does not predefine NumLock (used for VT220 keyboards) or Alt (used as
an extension for the Sun/PC keyboards) as modifiers. These keys are
recognized as modifiers when enabled by the numLock resource, or by the
"DECSET 1 0 3 5 " control sequence.
The cursor keys transmit the following escape sequences depending on the
mode specified via the DECCKM escape sequence.
The home- and end-keys (unlike PageUp and other keys also on the 6-key
editing keypad) are considered "cursor keys" by xterm. Their mode is
also controlled by the DECCKM escape sequence:
Not all keys are present on the Sun/PC keypad (e.g., PF1, Tab), but are
supported by the program.
Note that F1 through F4 are prefixed with SS3 , while the other keys are
prefixed with CSI . Older versions of xterm implement different escape
sequences for F1 through F4, with a CSI prefix. These can be activated
by setting the oldXtermFKeys resource. However, since they do not cor-
respond to any hardware terminal, they have been deprecated. (The DEC
VT220 reserves F1 through F5 for local functions such as Setup).
Code Modifiers
---------+---------------------------
2 | Shift
3 | Alt
4 | Shift + Alt
5 | Control
6 | Shift + Control
7 | Alt + Control
8 | Shift + Alt + Control
9 | Meta
10 | Meta + Shift
11 | Meta + Alt
12 | Meta + Alt + Shift
13 | Meta + Ctrl
14 | Meta + Ctrl + Shift
15 | Meta + Ctrl + Alt
16 | Meta + Ctrl + Alt + Shift
---------+---------------------------
The codes used for the PC-style function keys were inspired by a feature
of the VT510, referred to in its reference manual as DECFNK. In the
DECFNK scheme, codes 2-8 identify modifiers for function-keys and cur-
sor-, editing-keypad keys. Unlike xterm, the VT510 limits the modifiers
which can be used with cursor- and editing-keypad keys. Although the
name "DECFNK" implies that it is a mode, the VT510 manual mentions it
only as a feature, which (like xterm) interacts with the DECUDK feature.
Unlike xterm, VT510/VT520 provide an extension to DECUDK (DECPFK and
DECPAK) which apparently was the reason for the feature in those termi-
nals, i.e., for identifying a programmable key rather than making it
simple for applications to obtain modifier information. It is not
described in the related VT520 manual. Neither manual was readily
available at the time the feature was added to xterm.
On the other hand, the VT510 and VT520 reference manuals do document a
related feature. That is its emulation of the SCO console, which is
similar to the "xterm-sco" terminal description. The SCO console func-
tion-keys are less useful to applications developers than the approach
used by xterm because
However, xterm is most useful as a DEC VT102 or VT220 emulator. Set the
sunKeyboard resource to true to force a Sun/PC keyboard to act like a
VT220 keyboard.
The VT100/VT220 keypad did not have all of those keys. They were imple-
mented in xterm in X11R1 (1987), defining a mapping of all X11 keys
which might be provided on a keypad. For instance, a Sun4/II type-4
keyboard provided "=" (equal), "/" (divide), and "*" (multiply).
While the VT420 provided the same keypad, the VT520 used a PC-keyboard.
Because that keyboard's keypad lacks the "," (comma), it was not possi-
ble to use EDT's delete-character function with the keypad. XTerm
solves that problem for the VT220-keyboard configuration by mapping
Ctrl + to , and
Ctrl - to -
A VT52 does not have function keys, but it does have a numeric keypad
and cursor keys. They differ from the other emulations by the prefix.
Also, the cursor keys do not change:
Key Normal/Application
-------------+--------------------
Cursor Up | ESC A
Cursor Down | ESC B
Cursor Right | ESC C
Cursor Left | ESC D
-------------+--------------------
The xterm program provides support for Sun keyboards more directly, by a
menu toggle that causes it to send Sun-style function key codes rather
than VT220. Note, however, that the sun and VT100 emulations are not
really compatible. For example, their wrap-margin behavior differs.
Only function keys are altered; keypad and cursor keys are the same.
The emulation responds identically. See the xterm-sun terminfo entry
for details.
XTerm maintains two screen buffers. The Normal Screen Buffer allows you
to scroll back to view saved lines of output up to the maximum set by
the saveLines resource. The Alternate Screen Buffer is exactly as large
as the display, contains no additional saved lines. When the Alternate
Screen Buffer is active, you cannot scroll back to view saved lines.
XTerm provides control sequences and menu entries for switching between
the two.
When bracketed paste mode is set, pasted text is bracketed with control
sequences so that the program can differentiate pasted text from typed-
in text. When bracketed paste mode is set, the program will receive:
ESC [ 2 0 0 ~ ,
followed by the pasted text, followed by
ESC [ 2 0 1 ~ .
Title Modes
Separate from the ability to set the titles, xterm provides the ability
to query the titles, returning them either in ISO-8859-1 or UTF-8. This
choice is available only while xterm is using UTF-8 encoding.
Finally, the characters sent to, or returned by a title control are less
constrained than the rest of the control sequences. To make them more
manageable (and constrained), for use in shell scripts, xterm has an
optional feature which decodes the string from hexadecimal (for setting
titles) or for encoding the title into hexadecimal when querying the
value.
Mouse Tracking
The VT widget can be set to send the mouse position and other informa-
tion on button presses. These modes are typically used by editors and
other full-screen applications that want to make use of the mouse.
o mouse protocol
o protocol encoding
The mouse protocols include DEC Locator mode, enabled by the DECELR CSI
Ps ; Ps ' z control sequence, and is not described here (control
sequences are summarized above). The remaining five modes of the mouse
protocols are each enabled (or disabled) by a different parameter in the
"DECSET CSI ? Pm h " or "DECRST CSI ? Pm l " control sequence.
#define SET_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 motion reporting modes are strictly xterm extensions, and are not
part of any standard, though they are analogous to the DEC VT200 DECELR
locator reports.
Normally, parameters (such as pointer position and button number) for
all mouse tracking escape sequences generated by xterm encode numeric
parameters in a single character as value+32. For example, ! specifies
the value 1. The upper left character position on the terminal is
denoted as 1,1. This scheme dates back to X10, though the normal mouse-
tracking (from X11) is more elaborate.
o 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 key (shift, ctrl, meta) information is also sent. It
is enabled by specifying parameter 1000 to DECSET. On button press or
release, xterm sends CSI M CbCxCy.
o The next three bits encode the modifiers which were down when the
button was pressed and are added together: 4=Shift, 8=Meta, 16=Con-
trol. Note however that the shift and control bits are normally
unavailable because xterm uses the control modifier with mouse for
popup menus, and the shift modifier is used in the default transla-
tions for button events. The Meta modifier recognized by xterm is
the mod1 mask, and is not necessarily the "Meta" key (see
xmodmap(1)).
Wheel mice
Wheel mice may return buttons 4 and 5. Those buttons are represented by
the same event codes as buttons 1 and 2 respectively, except that 64 is
added to the event code. Release events for the wheel buttons are not
reported. By default, the wheel mouse events are translated to scroll-
back and scroll-forw actions. Those actions normally scroll the whole
window, as if the scrollbar was used. However if Alternate Scroll mode
is set, then cursor up/down controls are sent when the terminal is dis-
playing the Alternate Screen Buffer. The initial state of Alternate
Scroll mode is set using the alternateScroll resource.
Other buttons
Additional buttons are encoded like the wheel mice,
Past button 11, the encoding is ambiguous because the same code may cor-
respond to different button/modifier combinations. It is not possible
to use these buttons (6-11) in xterm's translation resource because
their names are not in the X Toolkit's symbol table.
Highlight tracking
o startx and starty give the starting x and y location for the high-
lighted region.
o 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:
o otherwise:
CSI T CxCyCxCyCxCy.
The parameters are startx, starty, endx, endy, mousex, and mousey.
o startx, starty, endx, and endy give the starting and ending
character positions of the region.
o mousex and mousey give the location of the mouse at button up,
which may not be over a character.
Button-event tracking
o The other bits of the event code specify button and modifier keys as
in normal mode. For example, motion into cell x,y with button 1
down is reported as CSI M @ CxCy. ( @ = 32 + 0 (button 1) + 32
(motion indicator) ). Similarly, motion with button 3 down is
reported as CSI M B CxCy. ( B = 32 + 2 (button 3) + 32 (motion
indicator) ).
Any-event tracking
Any-event mode is the same as button-event mode, except that all motion
events are reported, even if no mouse button is down. It is enabled by
specifying 1003 to DECSET.
FocusIn/FocusOut
Extended coordinates
The original X10 mouse protocol limits the Cx and Cy ordinates to 223
(=255 - 32). XTerm supports more than one scheme for extending this
range, by changing the protocol encoding:
UTF-8 (1005)
This enables UTF-8 encoding for Cx and Cy under all tracking
modes, expanding the maximum encodable position from 223 to
2015. For positions less than 95, the resulting output is
identical under both modes. Under extended mouse mode, posi-
tions greater than 95 generate "extra" bytes which will con-
fuse applications which do not treat their input as a UTF-8
stream. Likewise, Cb will be UTF-8 encoded, to reduce confu-
sion with wheel mouse events.
This scheme has the drawback that the encoded coordinates will
not pass through luit unchanged, e.g., for locales using non-
UTF-8 encoding.
SGR (1006)
The normal mouse response is altered to use
o CSI < followed by semicolon-separated
The encoded button value in this case does not add 32 since
that was useful only in the X10 scheme for ensuring that the
byte containing the button value is a printable code.
URXVT (1015)
The normal mouse response is altered to use
Sixel Graphics
CSI ? Pm h
xterm has these additional private Set Mode values:
Ps = 8 0 -> Sixel scrolling.
Ps = 1 0 7 0 -> use private color registers for each
graphic.
Ps = 8 4 5 2 -> Sixel scrolling leaves cursor to right of
graphic.
DCS Pa ; Pb ; Ph q Ps..Ps ST
See:
http://vt100.net/docs/vt3xx-gp/chapter14.html
ReGIS Graphics
CSI ? Pm h
xterm has these additional private Set Mode values:
Ps = 1 0 7 0 -> use private color registers for each
graphic.
DCS Pm p Pr..Pr ST
See:
http://vt100.net/docs/vt3xx-gp/chapter1.html
The ReGIS data device control string has one positional param-
eter with four possible values:
Pm = 0 -> resume command, use fullscreen mode.
Pm = 1 -> start new command, use fullscreen mode.
Pm = 2 -> resume command, use command display mode.
Pm = 3 -> start new command, use command display mode.
BS Backspace (Ctrl-H).
VT Cursor up (Ctrl-K).
ESC SO Begin 4015 APL mode (ESC Ctrl-N). This is ignored by xterm.
ESC SI End 4015 APL mode (ESC Ctrl-O). This is ignored by xterm.
OSC 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. This is normally dis-
abled by a compile-time option.
VT52 Mode
Parameters for cursor movement are at the end of the ESC Y escape
sequence. Each ordinate is encoded in a single character as value+32.
For example, ! is 1. The screen coordinate system is 0-based.
ESC Y Ps Ps
Move the cursor to given row and column.
ESC Z Identify.
-> ESC / Z ("I am a VT52.").
Further reading
Technical manuals
Manuals for hardware terminals are more readily available than simi-
larly-detailed documentation for terminal emulators such as aixterm,
shelltool, dtterm.
o Not all details are clear even in DEC STD 070 (which is more than
twice the length of the VT520 programmer's reference manual, and
almost three times longer than the VT420 reference manual). How-
ever, as an internal standards document, DEC STD 070 is more likely
to describe the actual behavior of DEC's terminals than the more
polished user's guides.
That said, here are technical manuals which have been used in developing
xterm. Not all were available initially. In August 1996 for instance,
the technical references were limited to EK-VT220-HR-002 and EK-
VT420-UG.002. Shortly after, Richard Shuford sent a copy of EK-VT3XX-
TP-001. Still later (beginning in 2003), Paul Williams' vt100.net site
provided EK-VT102-UG-003, EK-VT220-RM-002, EK-VT420-RM-002, EK-VT520-RM
A01, EK-VT100-TM-003, and EK-VT102-UG-003. The remaining documents were
found on the bitsavers site.
Standards
o The printed ECMA-48 5th edition (1991) and the first PDF produced
for that edition (April 1998) state that SD (scroll down) ends with
05/14, i.e., ^ , which disagrees with DEC's VT420 hardware implemen-
tation and DEC's manuals which use 05/04 T . (A few other terminals
such as AT&T 5620 and IBM 5151 also used 05/04, but the documenta-
tion and dates are lacking).
ECMA created a new PDF in April 2003 which changed that detail to
use T , and later in 2008 provided PDFs of the earlier editions
which used T .
o The VT320, VT420, VT520 manuals claim that DECSCL does a hard reset
(RIS).
Both the VT220 manual and DEC STD 070 (which documents levels 1-4 in
detail) state that it is a soft reset, e.g., DECSTR.
Miscellaneous
A few hardware terminals survived into the 1990s only as terminal emula-
tors. Documentation for these and other terminal emulators which have
influenced xterm are generally available only in less-accessible and
less-detailed manual pages.
Later, the SunView program was adapted for the OPEN LOOK environment
introduced 1988-1990.
Still later, in 1995, OPEN LOOK was abandoned in favor of CDE. The
CDE terminal emulator dtterm implemented those controls, with a cou-
ple of additions.
There were two sets of controls (CSI Ps[ ; Pm ; Pm]t , and OSC
PstextST ) implemented by shelltool, documented in appendix E of
both PHIGS Programming Manual (1992), and the unpublished X Window
System User's Guide (OPEN LOOK Edition) (1995). The CDE program
kept those, and added a few new ones.
Besides the Sun-derived OSC controls for setting window title and
icon label, dtterm also supported the xterm controls for the same
feature.
The CDE source was unavailable for inspection until 2012, so that
clarification of the details of the window operations relied upon
vttest.
o The control sequences for saving/restoring the cursor and for sav-
ing/restoring "DEC Private Mode Values" may appear to be related
(since the "save" controls both end with s ), but that is coinciden-
tal. The latter was introduced in X10.4:
Most Dec Private mode settings can be save away internally using
\E[?ns, where n is the same number to set or reset the Dec
Private mode. The mode can be restored using \E[?nr. This can
be used in termcap for vi, for example, to turn off saving of
lines, but restore whatever the original state was on exit.
while the SCOSC/SCORC pair was added in 1995 by XFree86 (and docu-
mented long afterwards).
o The aixterm manual page gives the format of the control sequence for
foreground and background colors 8-15, but does not specify what
those colors are. That is implied by the description's mention of
HFT:
Unlike xterm, there are no resource names for the 16 colors, leaving
the reader to assume that the mapping is hard-coded. The control
sequences for colors 8-15 are not specified by ECMA-48, but rather
(as done in other instances by xterm) chosen to not conflict with
current or future standards.