ANSI escape code

ISO/IEC 6429ANSIANSI X3.64ECMA-48ANSI escape sequenceControl Sequence IntroducerANSI standardANSI escape codesANSI Escape sequencesSGR
ANSI escape sequences are a standard for in-band signaling to control the cursor location, color, and other options on video text terminals and terminal emulators.wikipedia
183 Related Articles

Terminal emulator

terminal emulationterminalterminal program
ANSI escape sequences are a standard for in-band signaling to control the cursor location, color, and other options on video text terminals and terminal emulators.
Terminals usually support a set of escape sequences for controlling color, cursor position, etc. Examples include the family of terminal control sequence standards known as ECMA-48, ANSI X3.64 or ISO/IEC 6429.

Computer terminal

terminalterminalsdumb terminal
ANSI escape sequences are a standard for in-band signaling to control the cursor location, color, and other options on video text terminals and terminal emulators.
The ANSI X3.64 escape code standard produced uniformity to some extent, but significant differences remained.

Escape character

escapeESCescaped
Certain sequences of bytes, most starting with Esc and '[', are embedded into the text, which the terminal looks for and interprets as commands, not as character codes.
This was later developed to ANSI escape codes covered by the ANSI X3.64 standard.

VT100

VT102DEC VT100VT-100
The first popular video terminal to support these sequences was the Digital VT100, introduced in 1978.
It was one of the first terminals to support ANSI escape codes for cursor control and other tasks, and added a number of extended codes for special features like controlling the status lights on the keyboard.

Ecma International

ECMAEuropean Computer Manufacturers AssociationEuropean Computer Manufacturer's Association
The ANSI X3L2 committee collaborated with the ECMA committee TC 1 to produce nearly identical standards.

Bulletin board system

BBSbulletin board systemsBBSes
They were used in development, scientific and commercial applications and later by the nascent bulletin board systems to offer improved displays compared to earlier systems lacking cursor movement, a primary reason they became a standard adopted by all manufacturers.
As time progressed, most terminal programs began using the ANSI standard, but could use their native character set if it was available.

Tput

As these sequences were different for different terminals, elaborate libraries such as termcap ("terminal capabilities") and utilities such as tput had to be created so programs could use the same API to work with any terminal.
System V Release 4 defined additional terminfo capabilities including standardized ANSI color capabilities and, which could be used by tput.

Terminfo

TERMtermcap or terminfo
Although termcap/terminfo-style libraries were primarily developed on and for Unix, since about 1984 programs running on Unix-like operating systems could almost always assume they were using a terminal or emulator that supported ANSI sequences; this led to widespread use of ANSI by programs running on those platforms.
These functions provide a stack-based expression parser, which is primarily used to help minimize the number of characters sent for control sequences which have optional parameters such as SGR (Select Graphic Rendition).

Digital Equipment Corporation

DECDigitalDigital Equipment
The first popular video terminal to support these sequences was the Digital VT100, introduced in 1978.

Control character

control codenon-printing charactercontrol codes
Only a few control characters (BEL, CR, LF, BS) were interpreted by the underlying BIOS, making it almost impossible to do any kind of full-screen application.
Several standards exist for these sequences, notably ANSI X3.64.

C0 and C1 control codes

C1 control codeC0 control charactersISO 6429
The standard says that in 8-bit environments these two-byte sequences can be merged into single C1 control code in the 0x80–0x9F range.
C1 codes are the range 80 HEX –9F HEX and the default C1 set was originally defined in ECMA-48 (harmonized later with ISO 6429).

VT320

VT300 seriesVT330/340VT340
The VT320 was an ANSI standard computer terminal introduced by Digital Equipment Corporation (DEC) in 1987.

VT52

VT50VT55VT-52
One example is the VT52 terminal, which allowed the cursor to be placed at an x,y location on the screen by sending the ESC character, a Y character, and then two characters representing with numerical values equal to the x,y location plus 32 (thus starting at the ASCII space character and avoiding the control characters).
These systems used a VT52-based screen driver in an era when ANSI escape codes had already become almost universal.

ConEmu

and Maximus5's ConEmu interpreted ANSI escape sequences printed by programs.
It also provides emulation for ANSI escape codes for color, bypassing the capabilities of the standard Windows Console Host to provide 256 and 24-bit color in Windows.

ANSI.SYS

ANSI bomb
DOS 2.0 introduced the ability to add a device driver for the ANSI escape sequences – the de facto standard being ANSI.SYS, but others like ANSI.COM, NANSI.SYS and ANSIPLUS.EXE are used as well (these are considerably faster as they bypass the BIOS).
ANSI.SYS is a device driver in the DOS family of operating systems that provides extra console functions through ANSI escape sequences.

ISO/IEC 2022

ISO 2022ISO-2022-JPISO-2022
ISO 2022 / ECMA-35 also recognizes the use of the backspace and carriage return control characters as means of combining otherwise spacing characters, as well as the CSI sequence "Graphic Character Combination" (GCC).

ANSI art

ANSIANSI graphicsANSI Art Scene
ANSI art also contains special ANSI escape sequences that color text with the 16 foreground and 8 background colours offered by ANSI.SYS, an MS-DOS device driver loosely based upon the ANSI X3.64 standard for text terminals.

Newline

line feedLFend of line
Only a few control characters (BEL, CR, LF, BS) were interpreted by the underlying BIOS, making it almost impossible to do any kind of full-screen application.
RI, (U+008D REVERSE LINE FEED, ISO/IEC 6429 8D, decimal 141) is used to move the printing position back one line (by reverse feeding the paper, or by moving a display cursor up one line) so that other characters may be printed over existing text.

Windows Terminal

Windows Terminal, introduced in 2019, supports the sequences by default, and it appears Microsoft intends to merge or replace Windows Console with it.

Reverse video

inverse videoblack-on-whiteinverse-video
For example, the following GNU sed command embellishes the output of the make command by displaying lines containing words starting with "WARN" in reverse video and words starting with "ERR" in bright yellow on a dark red background (letter case is ignored).
On a terminal understanding ANSI escape sequences, the reverse video function is activated using the escape sequence CSI 7 m (which equals SGR 7).

Advanced Video Attribute Terminal Assembler and Recreator

AVATAR
Its basic level was designed explicitly as a compression of the much longer ANSI escape codes, and can thus render colored text and artwork faster over slow connections.

GNOME Terminal

gnome-terminalTerminal
As "true color" graphic cards with 16 to 24 bits of color became common, Xterm, KDE's Konsole, as well as all libvte based terminals (including GNOME Terminal) support 24-bit foreground and background color setting

In-band signaling

in-bandin-band signallinginband
ANSI escape sequences are a standard for in-band signaling to control the cursor location, color, and other options on video text terminals and terminal emulators.