ANSI X3.64 Command Reference

TCC includes support for ANSI Std X3.64, allowing you to manipulate the cursor, screen color, and other display attributes through sequences of special characters embedded in the text sent to the display. These sequences are called "ANSI commands". (For a general description of this feature, see ANSI Support.) Because of the design of Windows, TCC cannot provide ANSI X3.64 support to external applications.


TCC supports most common ANSI X3.64 screen commands, but does not provide the complete set of options supported by some operating system's ANSI X3.64 drivers (for example, TCC does not include ANSI X3.64 key substitutions; that functionality is already provided with key aliases). This section is a quick reference to the ANSI X3.64 commands supported by TCC.


ANSI X3.64 support within TCC can be enabled or disabled with the ANSI Colors configuration option, or the SETDOS /A command. You can test whether ANSI X3.64 support is enabled with the _ANSI internal variable.


An ANSI X3.64 command string consists of three parts:


<ESC>[The ASCII character ESC, followed by a left bracket. These two characters must be present in all ANSI X3.64 strings.
parametersOptional parameters for the command, usually numeric. If there are multiple parameters, they are separated by semicolons.
commandA single-letter command. (Case sensitive!)


For example, to position the cursor to row 7, column 12 the ANSI X3.64 command is:




The parameters part of this command is "7;12" and the command part is "H".


To transmit ANSI X3.64 commands to the screen you can use the ECHO command. The ESC character can be generated by inserting it into the string directly (if you are putting the string in a batch file and your editor will insert such a character), or by using the internal "escape" character (defaults: caret, [^]) followed by a lower-case "e".


For example, the sequence shown above could be transmitted from a batch file with either of these commands (the first uses an ESC character directly, represented below by "<ESC>"; the second uses ^e):


echo <ESC>[7;12H

echo ^e[7;12H


You can also include ANSI X3.64 commands in your prompt, using $e to send the <ESC> character.




The internal TCC ANSI X3.64 interpreter supports the subset of X3.64 commands below. Variable parameters are shown in lower-case italics, e.g., row and attr, and must be replaced with the appropriate decimal numeric value when using the commands. The default value for row, rows, col, and cols is 1.



Cursor up by rows (default is 1)


Cursor down by rows (default is 1)


Repeat the previous character


Repeat the previous character # times


Cursor right by cols (default is 1)


Cursor left by cols (default is 1)


Move cursor to first row


Move cursor to row


Cursor down one line and to first column


Cursor down by rows and to first column


Cursor up one line and to first column


Cursor up by rows and to first column


Set cursor position, same as "H" command


Move cursor to column 1


Move cursor to column


Set cursor to top left


Move cursor to row, column 1


Set cursor position (top left is row 1, column 1)


Erase from cursor to end of display


Erase from cursor to end of display


Erase from start of display to cursor


Clear whole screen


Clear from cursor to end of line


Erase from start of line to cursor (inclusive)


Erase line


Insert one blank line


Insert # blank lines


Move cursor forward one tab


Move cursor forward # tabs


Delete one line


Delete # of lines


Set display attributes; see table of attribute values below


Delete one character


Delete # characters


Save cursor position (may not be nested)


Restore saved cursor position (or top-left if nothing saved)


Erase one character


Erase # characters


Move cursor back one tab


Move cursor back # tabs


Wrap lines at screen edge


Don't wrap lines at screen edge


Show cursor


Hide cursor


Send "^e]lTitle^e\" (the console's window title) to console input


Set console title to "Title". BEL is the ASCII character 7


Insert one blank character


Insert # blank characters



Display Attributes


The m escape sequences set display attributes.  Attribute values used for the m command are:


0Restore all attributes to default
1Bright (high intensity) foreground color
2Normal intensity foreground color
4Bright (high intensity) background
5Bright (high intensity) background
7Reverse video
8Concealed (foreground becomes background)
22Bold off (foreground is not intense)
24Background is not intense
25Background is not intense
27Normal video
28Concealed off
30..37Foreground color
40..47Background color


Foreground Code

Background Code



























If you are setting multiple attributes, combine them into a single command (using the ; concatenation operator). The attribute settings are cumulative, and are independent of order (except code 0, reset to default).




Set bright red foreground without changing background:


  echo ^e[31;1m


Set the display to bright cyan on blue, and clear the screen:


  echo ^e[44;36;1m^e[2J


Set up a prompt which saves the cursor position, displays the date and time on the top line in bright white on magenta, and then restores the cursor position and sets the color to bright cyan on blue, and displays the standard prompt:


  prompt $e[s$e[1;1f$e[45;37;1m$e[K$d $t$e[u$e[44;36;1m$p$g