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

overloads to support colorizing compiled format strings #4166

Closed
wants to merge 4 commits into from

Conversation

moshelooks
Copy link

Adds a new header compile-color.h with overloads of format, format_to, and print to support passing in a text_style together with a compiled format string.

I did a bit of refactoring in color.h to support this via a new detail::apply_style() function because otherwise it would need a bunch of copy-pasting into the new header.

It's generally great that fmt splits functionality across headers so you only pay for what you use. But here it's maybe unfortunate because you can include both color.h and compile.h and still be unable to colorize compiled format strings with compile-color.h.

I had the idea of in e.g. color.h doing something like

#ifdef FMT_COMPILE_H
#include "compile-color.h
#endif

and likewise in compile.h with #ifdef FMT_COLOR_H but want to see if you have other/better ideas first or maybe just want to leave it as-is.

Best, Moshe

@vitaut
Copy link
Contributor

vitaut commented Sep 20, 2024

Thanks for the PR but usually it doesn't make a lot of sense to combine format string compilation with colored output. If you really want to do it you can use fmt::styled (https://www.godbolt.org/z/W8Pqb4Ps9) or define your own output functions.

@vitaut vitaut closed this Sep 20, 2024
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.

2 participants