Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
ANSI escape code
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== {{anchor|CSIsection}} Control Sequence Introducer commands == For Control Sequence Introducer, or CSI, commands, the {{code|ESC [}} (written as {{code|\e[}}, {{code|\x1b[}} or {{code|\033[}} in several programming languages) is followed by any number (including none) of "parameter bytes" in the range 0x30–0x3F (ASCII <code>0–9:;<=>?</code>), then by any number of "intermediate bytes" in the range 0x20–0x2F (ASCII space and {{code|!"#$%&'()*+,-./}}), then finally by a single "final byte" in the range 0x40–0x7E (ASCII <code>@A–Z[\]^_`a–z{|}~</code><!--Note: can't use {{code}} due to the | in the content.-->).<ref name="ECMA-48"/>{{Rp|5.4}} All common sequences just use the parameters as a series of semicolon-separated numbers such as {{code|1;2;3}}.<ref name="ECMA-48" />{{Rp|page=5.4.2}} Missing numbers are treated as {{code|0}} ({{code|1;;3}} acts like the middle number is {{code|0}}, and no parameters at all in {{code|ESC[m}} acts like a {{code|0}} reset code). Some sequences (such as CUU) treat {{code|0}} as {{code|1}} in order to make missing parameters useful.<ref name="ECMA-48"/>{{Rp|F.4.2}} A subset of arrangements was declared "private" so that terminal manufacturers could insert their own sequences without conflicting with the standard. Sequences containing the parameter bytes <code><=>?</code> or the final bytes 0x70–0x7E (<code>p–z{|}~</code>) are private. The behavior of the terminal is undefined in the case where a CSI sequence contains any character outside of the range 0x20–0x7E. These illegal characters are either C0 control characters (the range 0–0x1F), DEL (0x7F), or bytes with the high bit set. Possible responses are to ignore the byte, to process it immediately, and furthermore whether to continue with the CSI sequence, to abort it immediately, or to ignore the rest of it.{{Citation needed|date=July 2015}} {| class="wikitable" |+ Some ANSI control sequences (not an exhaustive list) |- ! Code!!Abbr!!Name!!Effect |- id=CUU | style="font-family:monospace;" | CSI {{var|n}} A | {{tt|CUU}} | Cursor Up | rowspan=4 | Moves the cursor {{var|n}} (default {{code|1}}) cells in the given direction. If the cursor is already at the edge of the screen, this has no effect. |- id=CUD | style="font-family:monospace;" | CSI {{var|n}} B | {{tt|CUD}} | Cursor Down |- id=CUF | style="font-family:monospace;" | CSI {{var|n}} C | {{tt|CUF}} | Cursor Forward |- id=CUB | style="font-family:monospace;" | CSI {{var|n}} D | {{tt|CUB}} | Cursor Back |- id=CNL | style="font-family:monospace;" | CSI {{var|n}} E | {{tt|CNL}} | Cursor Next Line | Moves cursor to beginning of the line {{var|n}} (default {{code|1}}) lines down. (not [[ANSI.SYS]]) |- id=CPL | style="font-family:monospace;" | CSI {{var|n}} F | {{tt|CPL}} | Cursor Previous Line | Moves cursor to beginning of the line {{var|n}} (default {{code|1}}) lines up. (not [[ANSI.SYS]]) |- id=CHA | style="font-family:monospace;" | CSI {{var|n}} G | {{tt|CHA}} | {{nobr|Cursor Horizontal Absolute}} | Moves the cursor to column {{var|n}} (default {{code|1}}). (not [[ANSI.SYS]]) |- id=CUP | style="font-family:monospace;" | CSI {{var|n}} ; {{var|m}} H | {{tt|CUP}} | Cursor Position | Moves the cursor to row {{var|n}}, column {{var|m}}. The values are 1-based, and default to {{code|1}} (top left corner) if omitted. A sequence such as {{code|CSI ;5H}} is a synonym for {{code|CSI 1;5H}} as well as {{code|CSI 17;H}} is the same as {{code|CSI 17H}} and {{code|CSI 17;1H}} |- id=ED | style= "font-family:monospace;" | CSI {{var|n}} J | {{tt|ED}} | Erase in Display | Clears part of the screen. If {{var|n}} is {{code|0}} (or missing), clear from cursor to end of screen. If {{var|n}} is {{code|1}}, clear from cursor to beginning of the screen. If {{var|n}} is {{code|2}}, clear entire screen (and moves cursor to upper left on DOS [[ANSI.SYS]]). If {{var|n}} is {{code|3}}, clear entire screen and delete all lines saved in the scrollback buffer (this feature was added for [[xterm]] and is supported by other terminal applications). |- id=EL | style="font-family:monospace;" | CSI {{var|n}} K | {{tt|EL}} | Erase in Line | Erases part of the line. If {{var|n}} is {{code|0}} (or missing), clear from cursor to the end of the line. If {{var|n}} is {{code|1}}, clear from cursor to beginning of the line. If {{var|n}} is {{code|2}}, clear entire line. Cursor position does not change. |- id=SU | style="font-family:monospace;" | CSI {{var|n}} S | {{tt|SU}} | Scroll Up | Scroll whole page up by {{var|n}} (default {{code|1}}) lines. New lines are added at the bottom. (not [[ANSI.SYS]]) |- id=SD | style="font-family:monospace;" | CSI {{var|n}} T | {{tt|SD}} | Scroll Down | Scroll whole page down by {{var|n}} (default {{code|1}}) lines. New lines are added at the top. (not [[ANSI.SYS]]) |- id=HVP | style="font-family:monospace;" | CSI {{var|n}} ; {{var|m}} f | {{tt|HVP}} | {{nobr|Horizontal Vertical Position}} | Same as CUP, but counts as a format effector function (like {{control code link|CR}} or {{control code link|LF}}) rather than an editor function (like CUD or CNL). This can lead to different handling in certain terminal modes.<ref name="ECMA-48" />{{Rp|Annex A}} |- | style="font-family:monospace;" | CSI {{var|n}} m | {{tt|SGR}} | [[#SGR|Select Graphic Rendition]] | Sets colors and style of the characters following this code |- id=AUX | style="font-family:monospace;" | CSI 5i | | AUX Port On | Enable aux serial port usually for local serial printer |- id=noAUX | style="font-family:monospace;" | CSI 4i | | AUX Port Off | Disable aux serial port usually for local serial printer {{anchor|CPR}} |- id=DSR | style="font-family:monospace;" | CSI 6n | {{tt|DSR}} | Device Status Report | Reports the cursor position (CPR) by transmitting {{code|ESC[n;mR}}, where {{var|n}} is the row and {{var|m}} is the column. |} {| class="wikitable" |+ Some popular private sequences |- ! Code!!Abbr!!Name!!Effect |- id=SCP | style="font-family:monospace;" | CSI s | {{tt|SCP, SCOSC}} | Save Current Cursor Position | Saves the cursor position/state in SCO console mode.<ref>{{cite web |url=https://vt100.net/docs/vt510-rm/SCOSC.html |title=SCOSC—Save Current Cursor Position |publisher=[[Digital Equipment Corporation|DEC]] |work=VT510 Video Terminal Programmer Information}}</ref> In vertical split screen mode, instead used to set (as <code>CSI <var>n</var> ; <var>n</var> s</code>) or reset left and right margins.<ref>{{cite web |url=https://vt100.net/docs/vt510-rm/DECSLRM.html |title=DECSLRM—Set Left and Right Margins |publisher=[[Digital Equipment Corporation|DEC]] |work=VT510 Video Terminal Programmer Information}}</ref> |- id=RCP | style="font-family:monospace;" | CSI u | {{tt|RCP, SCORC}} | {{nobr|Restore Saved Cursor Position}} | Restores the cursor position/state in SCO console mode.<ref>{{cite web |url=https://vt100.net/docs/vt510-rm/SCORC.html |title=SCORC—Restore Saved Cursor Position |publisher=[[Digital Equipment Corporation|DEC]] |work=VT510 Video Terminal Programmer Information}}</ref> |- | style="font-family:monospace;" | CSI ? 25 h | {{tt|DECTCEM}} | | Shows the cursor, from the [[VT220]]. |- | style="font-family:monospace;" | CSI ? 25 l | {{tt|DECTCEM}} | | Hides the cursor. |- | style="font-family:monospace;" | CSI ? 1004 h | | | Enable reporting focus. Reports whenever terminal emulator enters or exits focus as {{code|ESC [I}} and {{code|ESC [O}}, respectively. |- | style="font-family:monospace;" | CSI ? 1004 l | | | Disable reporting focus. |- | style="font-family:monospace;" | CSI ? 1049 h | | | Enable alternative screen buffer, from xterm |- | style="font-family:monospace;" | CSI ? 1049 l | | | Disable alternative screen buffer, from xterm |- | style="font-family:monospace;" | CSI ? 2004 h | | | Turn on bracketed paste mode.<ref>{{cite web |first1=Edward |last1=Moy |first2=Stephen |last2=Gildea |first3=Thomas | last3=Dickey |title=XTerm Control Sequences |url=https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_ |at=Functions using CSI, ordered by the final character(s) |access-date=4 February 2022}}</ref> In bracketed paste mode, text pasted into the terminal will be surrounded by {{code|ESC [200~}} and {{code|ESC [201~}}; programs running in the terminal should not treat characters bracketed by those sequences as commands ([[Vim (text editor)|Vim]], for example, does not treat them as commands).<ref>{{cite web|url=https://cirw.in/blog/bracketed-paste|title=bracketed paste mode|author=Conrad Irwin|date=April 2013|website=cirw.in}}</ref> From xterm<ref>{{cite web |first1=Edward |last1=Moy |first2=Stephen |last2=Gildea |first3=Thomas | last3=Dickey |title=XTerm Control Sequences |url=https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Bracketed-Paste-Mode |at=Bracketed Paste Mode |access-date=4 February 2022}}</ref> |- | style="font-family:monospace;" | CSI ? 2004 l | | | Turn off bracketed paste mode. |}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
ANSI escape code
(section)
Add topic