Escape Sequences


Escape sequences are a nice old trick for changing colors of text files and also for creating macros. For those in the dark, ANSI art is a simple text file that just contains ascii characters and it also uses ANSI escape sequences to change colors of characters and also for cursor placement. They can also reassign charactors to keys, or even make an entire command run from one key.
First, you need ANSI.SYS loaded in the config.sys file. In dos, it's usually in "C:\dos\", in Windows 9x it's in "C:\windows\command\". The prompt command is the easiest way to test this out. It has a function that allows you to use escape sequences.

Use this string to change the foreground (text) to green: prompt $e[32m

Use this to change it back to white (Resets all attributes): prompt $e[0m$p$g (Add "$P$G" after this if you want the regular prompt back)

This changes text to green, background to magenta, and makes the text bright (Also adds the current path and a greater than symbol with $p and $g): prompt $e[32m$e45m$e[5m$p$g

Note, the "m" after the "$e[0" in any escape sequence MUST be lower-case. All other characters are not case sensitive. Here is a list of all the other colors:

Use "3x" for text and "4x" for backgrounds.

0 = black
1 = red
2 = green
3 = yellow
4 = blue
5 = magenta
6 = cyan
7 = white

Also, use "5" by itself for blinking, "1" will make the foreground color bright, and "0" by itself resets to the default of white text and a black background.

Now, the prompt command is not the only way to do this. Simply typing a plain text file that contains the escape sequence will work. However, instead of using "$e" for the escape charactor, you will use the actuall charactor for the escape key. You can't just press "ESC" though. EDIT makes this easy. Simply press "CTRL+P" and then hit the escape key, it will insert an escape character for you into your document. Then carry on with the rest of your escape sequence. You can use "ECHO" followed by an escape sequence in batch files also. Here is a link to a batch file that will let you change screen colors a little easier. "color.zip"


Now, for macros. Previously, the "m" in these previous escape sequences determined that these where color changes. For a macro, use a lower case "p". Here is the format for macro escape sequences.

(To come later... Sorry)