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

Renamed enum color to colors. #774

Closed
wants to merge 3 commits into from
Closed

Conversation

Remotion
Copy link
Contributor

@Remotion Remotion commented Jun 8, 2018

Added enum colors conversion to rgb struct.
Added colors_test.cpp.

Now it looks a bit strange.
We have enum color from format.h and enum class colors from colors.h.

@Remotion Remotion force-pushed the colors2 branch 2 times, most recently from 07f36d2 to 7d13715 Compare June 8, 2018 23:00
Added enum colors conversion to rgb struct.
Added colors_test.cpp.
@Remotion Remotion force-pushed the colors2 branch 2 times, most recently from 0a04018 to ef2f510 Compare June 8, 2018 23:02
@eliaskosunen
Copy link
Contributor

(v)print_colored and enum color should probably be entirely replaced by this. They aren't even documented, so I don't think it would be a breaking change. This would also allow renaming the enum to the more logical singular-form color.

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.

I suggest keeping the name color because enum names are normally singular in the standard (see http://eel.is/c++draft/utilities#meta.endian and http://eel.is/c++draft/atomics#order) except for bitmask types.

@Remotion
Copy link
Contributor Author

Remotion commented Jun 9, 2018

Agree name color is better but then there are 2 different enums with same name.
How can this be resolved then ? Rename or remove enum color from format.h ?

@vitaut
Copy link
Contributor

vitaut commented Jun 9, 2018

I suggest removing the old color and print_colored. Those are undocumented and experimental anyway and the new functionality seems strictly more general.

@Remotion
Copy link
Contributor Author

Remotion commented Jun 9, 2018

What about fmt::printf(rgb, ""); ? I could add this too but then colors.h will need to include printf.h.

Another more complicated idea would be to allow multiple colors per line.

// Something like this ?
fmt::print("{:color::red}, {:color::green}, {:color::blue} \n","red","green","blue");
```

@vitaut
Copy link
Contributor

vitaut commented Jun 9, 2018

I don't think we need fmt::printf(rgb, ""). The whole point of printf is to simplify transition from legacy printf and the latter doesn't have color support.

Renamed enum colors back to color.
@Remotion
Copy link
Contributor Author

What do we miss here ?

specify foreground color 'fd'.
Example:
fmt::print(fmt::color::red, "Elapsed time: {0:.2f} seconds", 1.23);
*/
template <typename... Args>
inline void print(rgb fd, string_view format_str, const Args & ... args) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why have both print and print_rgb?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

print_rgb is now removed.

@eliaskosunen
Copy link
Contributor

You could try fixing the g++ 4.8 build. https://github.com/Remotion/fmt-fork/blob/74107c9bd8c1df2b74d3cb4c0d98f0dcc60813d7/include/fmt/colors.h#L39-L43

FMT_CONSTEXPR expands to constexpr when relaxed C++14 constexpr is available and inline otherwise. Because constexpr functions are implicitly inline, you should remove the extra inline.

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 Travis build seems broken.

@vitaut
Copy link
Contributor

vitaut commented Jun 23, 2018

Merged in ce50063 with minor tweaks to prevent breaking the API (we can remove the old color API during the next major release). Thanks!

@vitaut vitaut closed this Jun 23, 2018
@eliaskosunen
Copy link
Contributor

Is it really necessary to wait for the next major release, though? The previous color API was not documented anywhere, so the feature wasn't really stabilized and it wouldn't really be a breaking change to remove it.

@vitaut
Copy link
Contributor

vitaut commented Jun 23, 2018

It is still part of the public API, so I'd rather remove it in stages. Maybe not in the major version but at least we need to provide a good migration plan.

@vitaut
Copy link
Contributor

vitaut commented Jun 24, 2018

I added a comment that the old color code is deprecated (https://github.com/fmtlib/fmt/blob/master/include/fmt/core.h#L1185) and we can make FMT_EXTENDED_COLORS the default in one of the minor versions.

@vitaut
Copy link
Contributor

vitaut commented Mar 21, 2019

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

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.

3 participants