Handle console foreground and background
dwmkerr opened this issue · 2 comments
Respect console foreground and background.
http://www.codeproject.com/Articles/335909/Embedding-a-Console-in-a-C-Application?msg=4496572
I am not sure how Windows Handles console colors, but I have been doing some work on the the source of ConsoleControl for basically redirecting a shell from linux (Android actually) and added support for how linux handles the coloring. It is done with ^[{arg};{fg};{bg}mCONSOLE_OUTPUT^[0m
{arg} defines things like bold, italic, strike, blink, etc. (I have not implemented that). I am ignoring the arg.
{fg} is a value that indicates the forecolor
{bg} is a value that indicated the background color.
^[0m indicates the color should go back to "normal".
^[ is [ESCAPE] character 0x1B.
Here is a gist with how I implemented it. Keep in mind there are some other changes too. Like I implemented a command history, and a "fat" caret. But WriteOutput that only takes "output" will parse the content, splitting it on ^[ ("\e") and change the RTB forecolor based on that.
As I said, I don't know how the Windows Console indicates colors, as I don't have a need for those currently, but thought I would share what I did. I know this issue is a bit old, but I figured it couldn't hurt to share it.