-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Added support for rgb color output. #767
Conversation
Remotion
commented
Jun 7, 2018
include/fmt/colors.h
Outdated
} | ||
|
||
|
||
enum hex : uint32_t { // use enum class ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would probably be better as an enum class. Also, maybe rename it to something more descriptive, like color
? I'm also not sure of the CamelCasing of the variants, and if it's consistent with the rest of the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would probably be better as an enum class.
Probably but I really do not want this to be too long.
fmt::print(fmt::Coral, "message {}\n", msg);
fmt::print(fmt::colors::Coral, "message {}\n", msg);
Also color names are from this list
Color Names Supported by All Browsers
Also Visual Studio and VS Code can directly show colors in the editor using this names.
Unfortunately I could not find a way to support hex colors like #FFFFFF in C++.
Alternative would be to use color names like this, but this is even less readable.
fmt::print(fmt::darkgoldenrod, "message {}\n", msg);
// fmt::print(fmt::DarkGoldenRod, "message {}\n", msg);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant was more like using snake_case
instead of CamelCase
since the library and C++ code in general tends to prefer the former over the latter. But you're right about those extensions, they seem to require the color names to be lowercase
or CamelCase
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @eliaskosunen's points that it should be a enum class color
with snake case enum constants for consistency with the rest of the code:
enum class colors : uint32_t {
alice_blue = ...
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. One minor comment inline and could you add a section to https://raw.githubusercontent.com/fmtlib/fmt/master/doc/api.rst describing this functionality in a separate PR.
include/fmt/colors.h
Outdated
} | ||
|
||
|
||
enum hex : uint32_t { // use enum class ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @eliaskosunen's points that it should be a enum class color
with snake case enum constants for consistency with the rest of the code:
enum class colors : uint32_t {
alice_blue = ...
};
Renamed from hex to color. Changed colr names to snake case.
Merged with minor tweaks, thanks! |