Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle console foreground and background #4

Open
dwmkerr opened this issue Sep 2, 2013 · 2 comments
Open

Handle console foreground and background #4

dwmkerr opened this issue Sep 2, 2013 · 2 comments

Comments

@dwmkerr
Copy link
Owner

dwmkerr commented Sep 2, 2013

Respect console foreground and background.
http://www.codeproject.com/Articles/335909/Embedding-a-Console-in-a-C-Application?msg=4496572

@camalot
Copy link

camalot commented Jan 12, 2015

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.

Gist: ConsoleControl.cs

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.

@dwmkerr
Copy link
Owner Author

dwmkerr commented Jan 13, 2015

@camalot thanks for updating the issue with this info, really appreciate you taking the time to do that! I'll look into this issue again with the extract insight you've given, who knows, I may be able to close it soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants