15 #ifdef FMT_DEPRECATED_COLORS 21 template <
typename... Args>
23 const Args & ...
args) {
26 template <
typename... Args>
28 const Args & ... args) {
29 vprint_colored(c, format_str, make_format_args<wformat_context>(args...));
33 char escape[] =
"\x1b[30m";
34 escape[3] =
static_cast<char>(
'0' +
c);
41 wchar_t escape[] = L
"\x1b[30m";
42 escape[3] =
static_cast<wchar_t>(
'0' +
c);
43 std::fputws(escape,
stdout);
226 :
r(r_),
g(g_),
b(b_) {}
228 :
r((hex >> 16) & 0xFF),
g((hex >> 8) & 0xFF),
b((hex) & 0xFF) {}
242 : is_rgb(),
value{} {}
244 : is_rgb(
true),
value{} {
248 : is_rgb(
true),
value{} {
250 | (
static_cast<uint32_t>(rgb_color.g) << 8) | rgb_color.b;
253 : is_rgb(),
value{} {
268 : set_foreground_color(), set_background_color(),
ems(em) {}
271 if (!set_foreground_color) {
280 if (!set_background_color) {
290 static_cast<uint8_t>(rhs.
ems));
300 if (!set_foreground_color) {
309 if (!set_background_color) {
319 static_cast<uint8_t>(rhs.
ems));
329 return set_foreground_color;
332 return set_background_color;
338 assert(has_foreground() &&
"no foreground specified for this style");
339 return foreground_color;
342 assert(has_background() &&
"no background specified for this style");
343 return background_color;
346 assert(has_emphasis() &&
"no emphasis specified for this style");
353 : set_foreground_color(),
354 set_background_color(),
357 foreground_color = text_color;
358 set_foreground_color =
true;
360 background_color = text_color;
361 set_background_color =
true;
391 template <
typename Char>
397 if (!text_color.is_rgb) {
405 std::size_t
index = 0;
406 buffer[index++] =
static_cast<Char
>(
'\x1b');
407 buffer[index++] =
static_cast<Char
>(
'[');
410 buffer[index++] =
static_cast<Char
>(
'1');
413 buffer[index++] =
static_cast<Char
>(
'0' + value / 10u);
414 buffer[index++] =
static_cast<Char
>(
'0' + value % 10u);
416 buffer[index++] =
static_cast<Char
>(
'm');
417 buffer[index++] =
static_cast<Char
>(
'\0');
421 for (
int i = 0; i < 7; i++) {
422 buffer[i] =
static_cast<Char
>(esc[i]);
424 rgb color(text_color.value.rgb_color);
425 to_esc(color.
r,
buffer + 7,
';');
426 to_esc(color.
g,
buffer + 11,
';');
427 to_esc(color.
b,
buffer + 15,
'm');
428 buffer[19] =
static_cast<Char
>(0);
442 std::size_t
index = 0;
443 for (
int i = 0; i < 4; ++i) {
446 buffer[index++] =
static_cast<Char
>(
'\x1b');
447 buffer[index++] =
static_cast<Char
>(
'[');
448 buffer[index++] =
static_cast<Char
>(
'0' + em_codes[i]);
449 buffer[index++] =
static_cast<Char
>(
'm');
451 buffer[index++] =
static_cast<Char
>(0);
460 out[0] =
static_cast<Char
>(
'0' + c / 100);
461 out[1] =
static_cast<Char
>(
'0' + c / 10 % 10);
462 out[2] =
static_cast<Char
>(
'0' + c % 10);
463 out[3] =
static_cast<Char
>(delimiter);
467 template <
typename Char>
473 template <
typename Char>
479 template <
typename Char>
485 template <
typename Char>
492 std::fputws(chars,
stream);
495 template <
typename Char>
519 bool has_style =
false;
522 internal::fputs<Char>(
527 internal::fputs<Char>(
532 internal::fputs<Char>(
537 internal::reset_color<Char>(
f);
548 template <
typename String,
typename... Args>
550 std::FILE *
f,
const text_style &ts,
const String &format_str,
551 const Args &... args) {
566 template <
typename String,
typename... Args>
568 const text_style &ts,
const String &format_str,
569 const Args &... args) {
577 #endif // FMT_COLOR_H_
FMT_CONSTEXPR text_style & operator&=(const text_style &rhs)
FMT_CONSTEXPR emphasis get_emphasis() const FMT_NOEXCEPT
FMT_CONSTEXPR text_style fg(internal::color_type foreground) FMT_NOEXCEPT
void reset_color(FILE *stream) FMT_NOEXCEPT
FMT_CONSTEXPR bool has_emphasis() const FMT_NOEXCEPT
internal::color_type background_color
#define FMT_CONSTEXPR_DECL
FMT_CONSTEXPR text_style bg(internal::color_type background) FMT_NOEXCEPT
QTextStream & hex(QTextStream &s)
FMT_CONSTEXPR text_style & operator|=(const text_style &rhs)
FMT_CONSTEXPR bool has_foreground() const FMT_NOEXCEPT
FMT_CONSTEXPR_DECL rgb(uint8_t r_, uint8_t g_, uint8_t b_)
static const wchar_t WRESET_COLOR[]
#define FMT_END_NAMESPACE
internal::color_type foreground_color
std::enable_if<!is_compile_string< S >::value >::type check_format_string(const S &)
FMT_CONSTEXPR ansi_color_escape(emphasis em) FMT_NOEXCEPT
FMT_CONSTEXPR text_style operator|(emphasis lhs, emphasis rhs) FMT_NOEXCEPT
void reset_color< wchar_t >(FILE *stream) FMT_NOEXCEPT
internal::basic_buffer< FMT_CHAR(S)> buffer
FMT_CONSTEXPR internal::color_type get_background() const FMT_NOEXCEPT
static const char BACKGROUND_COLOR[]
std::enable_if< internal::is_string< String >::value >::type print(std::FILE *f, const text_style &ts, const String &format_str, const Args &...args)
FMT_CONSTEXPR color_type(terminal_color term_color) FMT_NOEXCEPT
FMT_CONSTEXPR ansi_color_escape(internal::color_type text_color, const char *esc) FMT_NOEXCEPT
friend FMT_CONSTEXPR text_style operator&(text_style lhs, const text_style &rhs)
static FMT_CONSTEXPR void to_esc(uint8_t c, Char *out, char delimiter) FMT_NOEXCEPT
FMT_CONSTEXPR ansi_color_escape< Char > make_foreground_color(internal::color_type foreground) FMT_NOEXCEPT
FMT_CONSTEXPR color_type(color rgb_color) FMT_NOEXCEPT
bool set_foreground_color
JAVACC_STRING_TYPE String
void fputs< wchar_t >(const wchar_t *chars, FILE *stream) FMT_NOEXCEPT
static const char RESET_COLOR[]
FMT_CONSTEXPR ansi_color_escape< Char > make_emphasis(emphasis em) FMT_NOEXCEPT
bool set_background_color
format_arg_store< Context, Args... > make_format_args(const Args &...args)
friend FMT_CONSTEXPR text_style operator|(text_style lhs, const text_style &rhs)
void fputs(const Char *chars, FILE *stream) FMT_NOEXCEPT
FMT_CONSTEXPR value(int val=0)
FMT_CONSTEXPR ansi_color_escape< Char > make_background_color(internal::color_type background) FMT_NOEXCEPT
FMT_CONSTEXPR_DECL rgb(color hex)
FMT_CONSTEXPR color_type() FMT_NOEXCEPT
void vprint(std::FILE *f, const text_style &ts, const S &format, basic_format_args< typename buffer_context< Char >::type > args)
const GenericPointer< typename T::ValueType > T2 value
FMT_CONSTEXPR internal::color_type get_foreground() const FMT_NOEXCEPT
union internal::color_type::color_union value
FMT_CONSTEXPR_DECL rgb(uint32_t hex)
static const char FOREGROUND_COLOR[]
std::string escape(std::string const &str)
FMT_CONSTEXPR color_type(rgb rgb_color) FMT_NOEXCEPT
FMT_CONSTEXPR text_style(bool is_foreground, internal::color_type text_color) FMT_NOEXCEPT
FMT_CONSTEXPR text_style(emphasis em=emphasis()) FMT_NOEXCEPT
FMT_CONSTEXPR bool has_background() const FMT_NOEXCEPT