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

Add support for builtin terminal colors. #974

Merged
merged 13 commits into from
Dec 15, 2018

Conversation

Rakete1111
Copy link
Contributor

@Rakete1111 Rakete1111 commented Dec 9, 2018

Fixes #968. This PR adds a terminal_color enum:

fmt::print(fg(fmt::terminal_color::red), "stop\n");

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but please separate terminal color and rgb. Thanks for the PR!

include/fmt/color.h Show resolved Hide resolved
include/fmt/color.h Outdated Show resolved Hide resolved
Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more comments.

include/fmt/color.h Outdated Show resolved Hide resolved
include/fmt/color.h Show resolved Hide resolved
include/fmt/color.h Outdated Show resolved Hide resolved
include/fmt/color.h Outdated Show resolved Hide resolved
@vitaut
Copy link
Contributor

vitaut commented Dec 12, 2018

gcc 4.4 is unhappy because it doesn't support unrestricted unions.

FMT_CONSTEXPR color_type() FMT_NOEXCEPT
: is_rgb(), value{} {}
FMT_CONSTEXPR color_type(color rgb_color) FMT_NOEXCEPT
: is_rgb(true), value{} {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why call value{} if it is initialized below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was some another attempt to fix gcc 4.4 that we don't need anymore :). I'll remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vitaut Nevermind my previous comment. They are initialized because they have to be for constexpr and it seems like VS2013 doesn't implement directly initializing the union in a member initializer list. So I have to leave it like it is :(

@vitaut vitaut merged commit 93fd473 into fmtlib:master Dec 15, 2018
@vitaut
Copy link
Contributor

vitaut commented Dec 15, 2018

Merged, thanks!

@vitaut
Copy link
Contributor

vitaut commented Apr 18, 2019

@Rakete1111, could you please review the updated CONTIBUTING document, particularly the part about licensing, and let me know if you agree with it being applied both to your contributions to {fmt}? The library is likely to be relicensed (#1073) so I'm collecting approval from all earlier contributors. Thanks!

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

Successfully merging this pull request may close these issues.

Support ASCII color escape code numbers
2 participants