-
Notifications
You must be signed in to change notification settings - Fork 56
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
color and ANSI escape code #184
Comments
in cpp-terminal we have: int main(int /*argc*/, char** /*argv*/)
{
std::cout << Term::color(Term::fg::red) << "Hello, "; // 16 colors
std::cout << Term::color_8bit_fg(100) << "Colorful "; // 256 colors
std::cout << Term::color_24bit(211, 54, 130) << "World!"; // true colors
std::cout << std::endl;
return 0;
} soon we also have What exactly would you like to see? we can make overloads if you would prefer to have everything in a single function. |
This form is nice :) I like it.. I was was refereing to implementation too, it takes care of the old Windows standard so we could have a look and see how it's done On other think it has is the ability to deal with clog cerr, that's it could be nice to have a the ability to turn on off the colorization for any reason |
Yeah we need to look into the implementation for older windows versions as discussed in #173. Technically we can turn off colors when the terminal is not interactive, that would require some work though. I guess that turning off colors through some kind of flag / option should be implemented by the user since there are many ways to do it. |
I think the library linked turn it on and off if it tty or not It's not enought to turn it on/off based on tty it would be very nice to have a way to turn off/on on demand. I think the library linked do it |
well a user can simple create a wrapper themselves, I wouldn't like to force colors off on non TTY. It might be possible that the program runs in a CI task that supports coloring output regardless. we already have |
Moved the discussion to #188. |
I'm thinking about this kind of things And for people who suffer some visual problem, they could disable the colors. Other people like to see life in black and white.. As we are dealing with color it would be nice to have such feature.. |
I'm currently implementing autocolor for that. It's using RGB structs that can simply change their stored value. you would do
you can just implement something like struct colors {
Term::RGB color;
};
int main() {
colors col;
if(Term::is_stdin_a_tty()) {
col.color = bit4_to_rgb(Term::fg::red);
} else {
col.color = empty_rgb();
}
} What about that? Otherwise what would you propose? I wouldn't check some random ENV as that might be overlooked by developers who haven't read the code. |
Hey @flagarde anything else you want to to see in the library? |
I trying to add the color for old windows. |
It seems the cerr is not taken into account on the library. It would be very nice to deal with hi to as you did with cout |
Really nice! I hope that you find a well solution, I'm currently working on the window class update, because I need the managed renderer for a few of my projects. If you need help, feel free to make a draft PR and I can take a look ^^ |
Maybe we could adapt this library https://github.com/ikalnytskyi/termcolor it looks very convenient and not so big and
cpp-terminal
have already some function provided.. From the license it seems you could take some part of the code to integrate it.I like he syntax
It seems possible to include all the escape code in this way
The text was updated successfully, but these errors were encountered: