-
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
fmt/color.h: fmt::format_to not implemented for fmt::text_style #1842
Labels
Comments
I also just ran into this issue. My work around though not completely templated looks like this: template <size_t N> struct ansi_esc_sequence {
uint8_t tail;
uint8_t opts[N];
};
template <size_t N> struct fmt::formatter<ansi_esc_sequence<N>> : public fmt::formatter<string_view> {
template <typename FormatContext>
auto format(const ansi_esc_sequence<N>& p, FormatContext& ctx) noexcept {
if constexpr (N > 0) {
return fmt::format_to(ctx.out(), "\033[{}{}"sv, fmt::join(&p.opts[0], &p.opts[0] + N, ";"),
(char)p.tail);
}
else {
return fmt::format_to(ctx.out(), "\033[{}"sv, (char)p.tail);
}
}
}; It's a bit of a pain to specify the colors w/ the ansi sequence this way, definitely in full agreement it was strange to try to avoid this by using color.h only to find format_to wasn't implemented. |
The color API is for terminal output thus it supports only a subset of functions. |
Naios
added a commit
to Naios/fmt
that referenced
this issue
Aug 30, 2020
* Fix variable size basic_memory_buffer colorization * Rewrite the color unit tests to test the same colors against multiple backends * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Aug 31, 2020
* Fix variable size basic_memory_buffer colorization * Rewrite the color unit tests to test the same colors against multiple backends * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Aug 31, 2020
* Fix variable size basic_memory_buffer colorization * Rewrite the color unit tests to test the same colors against multiple backends * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Aug 31, 2020
* Fix variable size basic_memory_buffer colorization * Rewrite the color unit tests to test the same colors against multiple backends * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Aug 31, 2020
* Fix variable size basic_memory_buffer colorization * Rewrite the color unit tests to test the same colors against multiple backends * Fix an unused arguments warning on GCC that blocks the CI otherwise * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Aug 31, 2020
* Fix variable size basic_memory_buffer colorization * Rewrite the color unit tests to test the same colors against multiple backends * Fix an unused arguments warning on GCC that blocks the CI otherwise * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Aug 31, 2020
* Fix variable size basic_memory_buffer colorization * Rewrite the color unit tests to test the same colors against multiple backends * Fix an unused arguments warning on GCC that blocks the CI otherwise * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Aug 31, 2020
* Fix variable size basic_memory_buffer colorization * Rewrite the color unit tests to test the same colors against multiple backends * Fix an unused arguments warning on GCC that blocks the CI otherwise * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Sep 1, 2020
* Fix variable size basic_memory_buffer colorization * Fix an unused arguments warning on GCC that blocks the CI otherwise * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Sep 1, 2020
* Fix variable size basic_memory_buffer colorization * Fix an unused arguments warning on GCC that blocks the CI otherwise * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Sep 1, 2020
* Fix variable size basic_memory_buffer colorization * Fix an unused arguments warning on GCC that blocks the CI otherwise * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Sep 1, 2020
* Fix variable size basic_memory_buffer colorization * Fix an unused arguments warning on GCC that blocks the CI otherwise * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Sep 1, 2020
* Fix variable size basic_memory_buffer colorization * Fix an unused arguments warning on GCC that blocks the CI otherwise * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Sep 4, 2020
* Fix variable size basic_memory_buffer colorization * Fix an unused arguments warning on GCC that blocks the CI otherwise * Ref fmtlib#1842 * Ref fmtlib#1593
Naios
added a commit
to Naios/fmt
that referenced
this issue
Sep 4, 2020
* Fix variable size basic_memory_buffer colorization * Fix an unused arguments warning on GCC that blocks the CI otherwise * Ref fmtlib#1842 * Ref fmtlib#1593
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
e66ba16
Currently it is not possible to format a colorized string to a
fmt::memory_buffer
usingfmt::format_to(memory_buffer, fmt::text_style(...
or through any other function because the overload is missing.It would be great if the missing overload for
fmt::format_to(memory_buffer, fmt::text_style
could be added.Overall the color API is inconsistent with the format API and not all format functions support a
fmt::text_style
overload. Maybe the color API could be aligned in general with the format API.The text was updated successfully, but these errors were encountered: