Ansi Escape Code Article Index for
Ansi
Website Links For
Escape
 

Information About

Ansi Escape Code




From the MS-DOS ''prompt'' command, the Escape Character can be specified as , e.g. ''prompt [44m;...'' would specify a blue background as part of the prompt. In C , C++ , Java , Python or Perl this is "", in QBasic or GWBASIC , the code would be CHR$(27) or CHR$(&H1B) (for those of you who prefer Hexadecimal ). Support is built in on Windows and Linux , DOS systems need a Device Driver for the ANSI codes — the de facto standard being ANSI.SYS , but others are used as well.




EXAMPLES

CSI 0 ; 6 8 ; "DIR" ; 13 p - This re-assigns the key F10 to send to the keyboard buffer the string "DIR" and ENTER, which in the DOS command line would display the contents of the current directory. (MS-DOS ANSI.SYS only)

CSI 2 J - This clears the screen and locates the cursor to the y,x position 0,0 (upper left corner).

CSI 32 m - This makes text green. Normally the green would be dark, dull green, so you may wish to enable Bold with the code CSI 1 m which would make it bright green. This can also be accomplished with CSI 32 ; 1 m

CSI s - This saves the cursor position. Using the code CSI u will restore it to the position. Say the current cursor position is 7(y) and 10(x). The code CSI s will save those two numbers. Now you can move to a different cursor position, such as 20(y) and 3(x), using the code CSI 20 ; 3 H or CSI 20 ; 3 f. Now if you use the code CSI u the cursor position will return to 7(y) and 10(x). Some terminals require the DEC sequences ESC 7 / ESC 8 instead.


SEE ALSO



EXTERNAL LINKS

  • Standard ECMA-48 : Control Functions for Coded Character Sets ''5th edition (June 1991)''