ANSI escape codes

closed account (42hU7k9E)
I need help with ANSI escape codes, i heard they are werry usefull, but i can't find nothing on google to learn about them. I am pretty new to programming so sorry if this is a stupid question.

So please if you have a good link to a tutorial or something, write it here.
closed account (z05DSL3A)
http://en.wikipedia.org/wiki/ANSI_escape_code
closed account (42hU7k9E)
I have seen that, but how do i write it so that the computer will understand? :s
closed account (z05DSL3A)
Example code to clear the screen:
1
2
char clearScreen[] = { 0x1b, '[', '2', 'J', 0 };
cout << clearScreen;

Will not work on a standard Windows Command window.
closed account (42hU7k9E)
It's true, it only outputs an arrow [ 2 j :) What should I do to make it work?
Google returns 76,600 results for "ansi escape codes"; you'll be alright. ;)
closed account (z05DSL3A)
Kajec, Try reading the Wikipedia article!
You need to be running ANSI.SYS for those VT100 escape codes to work in a DOS console.

Presuming you are using Windows 2000 or later, somewhere in your console startup's autoexec.nt or config.nt file, you need to include the line

DEVICE=C:\WINDOWS\system32\ansi.sys


However, you are better off avoiding direct use of ANSI/VT100 control codes and programming the terminal properly. Google "msdn console functions" for stuff on Windows.

If you want to get really fancy, I recommend you check out the Curses library.

PDCurses
Win32, DOS, OS/2, Plan 9, etc.
http://pdcurses.sourceforge.net/

NCurses
POSIX
http://www.gnu.org/software/ncurses/

NCURSES Programming HOWTO
Getting started with Curses
http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

Remember that using the XSI standard Curses libraries means that it controls the console, so you shouldn't use the C and C++ standard console I/O streams concurrently. (You can use them elsewhere, of course, just don't mix them with console I/O.)

Hope this helps.
Last edited on
Topic archived. No new replies allowed.