winVT100
Posted: Wed Nov 11, 2009 12:42 pm
Well, I got bored. I wanted to make a simple cross-platform video game, and figured that to keep myself from getting stuck on making it look pretty I would go with text-mode graphics, since they're all already done for me. Needless to say, my plan backfired, since instead of wasting my time making pretty pictures, I wasted my time making pretty colors. Out of my time-wasting was born the winVT100 library, a std::cout/std::wcout replacement that intercepts the VT100 escape codes (like "^[[44;37;1") and at least tries to perform the appropriate action (the Windows command prompt doesn't support blinking, instead using bright backgrounds, as well as the fact that underlining is being a pain).
Usage is absurdly simple: #include <vtiostream> and instead of sending to std::cout, you sent to VT100::cout. Because it simply wraps the std::basic_filebuf template it supports everything std::cout does, and (obviously) then some. Under non-Windows operating systems it just defines VT100 as std, so conditional compiling is done by the "library."
At the moment it supports most of the ^[[*m codes, and cursor positioning via ^[[*;*H (or ^[[H for home).
I'm sure something like this already exists, but I was too lazy to find it and already had half of the code there. I just had to tie it together in this easy-to-use package.
The source code can be found here. I would appreciate comments and suggestions. It's all under the BSD license.
Usage is absurdly simple: #include <vtiostream> and instead of sending to std::cout, you sent to VT100::cout. Because it simply wraps the std::basic_filebuf template it supports everything std::cout does, and (obviously) then some. Under non-Windows operating systems it just defines VT100 as std, so conditional compiling is done by the "library."
At the moment it supports most of the ^[[*m codes, and cursor positioning via ^[[*;*H (or ^[[H for home).
I'm sure something like this already exists, but I was too lazy to find it and already had half of the code there. I just had to tie it together in this easy-to-use package.
The source code can be found here. I would appreciate comments and suggestions. It's all under the BSD license.