spdlog
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1// Formatting library for C++ - color support
2//
3// Copyright (c) 2018 - present, Victor Zverovich and fmt contributors
4// All rights reserved.
5//
6// For the license information refer to format.h.
7
8#ifndef FMT_COLOR_H_
9#define FMT_COLOR_H_
10
11#include "format.h"
12
13// __declspec(deprecated) is broken in some MSVC versions.
14#if FMT_MSC_VER
15# define FMT_DEPRECATED_NONMSVC
16#else
17# define FMT_DEPRECATED_NONMSVC FMT_DEPRECATED
18#endif
19
22
23enum class color : uint32_t {
24 alice_blue = 0xF0F8FF, // rgb(240,248,255)
25 antique_white = 0xFAEBD7, // rgb(250,235,215)
26 aqua = 0x00FFFF, // rgb(0,255,255)
27 aquamarine = 0x7FFFD4, // rgb(127,255,212)
28 azure = 0xF0FFFF, // rgb(240,255,255)
29 beige = 0xF5F5DC, // rgb(245,245,220)
30 bisque = 0xFFE4C4, // rgb(255,228,196)
31 black = 0x000000, // rgb(0,0,0)
32 blanched_almond = 0xFFEBCD, // rgb(255,235,205)
33 blue = 0x0000FF, // rgb(0,0,255)
34 blue_violet = 0x8A2BE2, // rgb(138,43,226)
35 brown = 0xA52A2A, // rgb(165,42,42)
36 burly_wood = 0xDEB887, // rgb(222,184,135)
37 cadet_blue = 0x5F9EA0, // rgb(95,158,160)
38 chartreuse = 0x7FFF00, // rgb(127,255,0)
39 chocolate = 0xD2691E, // rgb(210,105,30)
40 coral = 0xFF7F50, // rgb(255,127,80)
41 cornflower_blue = 0x6495ED, // rgb(100,149,237)
42 cornsilk = 0xFFF8DC, // rgb(255,248,220)
43 crimson = 0xDC143C, // rgb(220,20,60)
44 cyan = 0x00FFFF, // rgb(0,255,255)
45 dark_blue = 0x00008B, // rgb(0,0,139)
46 dark_cyan = 0x008B8B, // rgb(0,139,139)
47 dark_golden_rod = 0xB8860B, // rgb(184,134,11)
48 dark_gray = 0xA9A9A9, // rgb(169,169,169)
49 dark_green = 0x006400, // rgb(0,100,0)
50 dark_khaki = 0xBDB76B, // rgb(189,183,107)
51 dark_magenta = 0x8B008B, // rgb(139,0,139)
52 dark_olive_green = 0x556B2F, // rgb(85,107,47)
53 dark_orange = 0xFF8C00, // rgb(255,140,0)
54 dark_orchid = 0x9932CC, // rgb(153,50,204)
55 dark_red = 0x8B0000, // rgb(139,0,0)
56 dark_salmon = 0xE9967A, // rgb(233,150,122)
57 dark_sea_green = 0x8FBC8F, // rgb(143,188,143)
58 dark_slate_blue = 0x483D8B, // rgb(72,61,139)
59 dark_slate_gray = 0x2F4F4F, // rgb(47,79,79)
60 dark_turquoise = 0x00CED1, // rgb(0,206,209)
61 dark_violet = 0x9400D3, // rgb(148,0,211)
62 deep_pink = 0xFF1493, // rgb(255,20,147)
63 deep_sky_blue = 0x00BFFF, // rgb(0,191,255)
64 dim_gray = 0x696969, // rgb(105,105,105)
65 dodger_blue = 0x1E90FF, // rgb(30,144,255)
66 fire_brick = 0xB22222, // rgb(178,34,34)
67 floral_white = 0xFFFAF0, // rgb(255,250,240)
68 forest_green = 0x228B22, // rgb(34,139,34)
69 fuchsia = 0xFF00FF, // rgb(255,0,255)
70 gainsboro = 0xDCDCDC, // rgb(220,220,220)
71 ghost_white = 0xF8F8FF, // rgb(248,248,255)
72 gold = 0xFFD700, // rgb(255,215,0)
73 golden_rod = 0xDAA520, // rgb(218,165,32)
74 gray = 0x808080, // rgb(128,128,128)
75 green = 0x008000, // rgb(0,128,0)
76 green_yellow = 0xADFF2F, // rgb(173,255,47)
77 honey_dew = 0xF0FFF0, // rgb(240,255,240)
78 hot_pink = 0xFF69B4, // rgb(255,105,180)
79 indian_red = 0xCD5C5C, // rgb(205,92,92)
80 indigo = 0x4B0082, // rgb(75,0,130)
81 ivory = 0xFFFFF0, // rgb(255,255,240)
82 khaki = 0xF0E68C, // rgb(240,230,140)
83 lavender = 0xE6E6FA, // rgb(230,230,250)
84 lavender_blush = 0xFFF0F5, // rgb(255,240,245)
85 lawn_green = 0x7CFC00, // rgb(124,252,0)
86 lemon_chiffon = 0xFFFACD, // rgb(255,250,205)
87 light_blue = 0xADD8E6, // rgb(173,216,230)
88 light_coral = 0xF08080, // rgb(240,128,128)
89 light_cyan = 0xE0FFFF, // rgb(224,255,255)
90 light_golden_rod_yellow = 0xFAFAD2, // rgb(250,250,210)
91 light_gray = 0xD3D3D3, // rgb(211,211,211)
92 light_green = 0x90EE90, // rgb(144,238,144)
93 light_pink = 0xFFB6C1, // rgb(255,182,193)
94 light_salmon = 0xFFA07A, // rgb(255,160,122)
95 light_sea_green = 0x20B2AA, // rgb(32,178,170)
96 light_sky_blue = 0x87CEFA, // rgb(135,206,250)
97 light_slate_gray = 0x778899, // rgb(119,136,153)
98 light_steel_blue = 0xB0C4DE, // rgb(176,196,222)
99 light_yellow = 0xFFFFE0, // rgb(255,255,224)
100 lime = 0x00FF00, // rgb(0,255,0)
101 lime_green = 0x32CD32, // rgb(50,205,50)
102 linen = 0xFAF0E6, // rgb(250,240,230)
103 magenta = 0xFF00FF, // rgb(255,0,255)
104 maroon = 0x800000, // rgb(128,0,0)
105 medium_aquamarine = 0x66CDAA, // rgb(102,205,170)
106 medium_blue = 0x0000CD, // rgb(0,0,205)
107 medium_orchid = 0xBA55D3, // rgb(186,85,211)
108 medium_purple = 0x9370DB, // rgb(147,112,219)
109 medium_sea_green = 0x3CB371, // rgb(60,179,113)
110 medium_slate_blue = 0x7B68EE, // rgb(123,104,238)
111 medium_spring_green = 0x00FA9A, // rgb(0,250,154)
112 medium_turquoise = 0x48D1CC, // rgb(72,209,204)
113 medium_violet_red = 0xC71585, // rgb(199,21,133)
114 midnight_blue = 0x191970, // rgb(25,25,112)
115 mint_cream = 0xF5FFFA, // rgb(245,255,250)
116 misty_rose = 0xFFE4E1, // rgb(255,228,225)
117 moccasin = 0xFFE4B5, // rgb(255,228,181)
118 navajo_white = 0xFFDEAD, // rgb(255,222,173)
119 navy = 0x000080, // rgb(0,0,128)
120 old_lace = 0xFDF5E6, // rgb(253,245,230)
121 olive = 0x808000, // rgb(128,128,0)
122 olive_drab = 0x6B8E23, // rgb(107,142,35)
123 orange = 0xFFA500, // rgb(255,165,0)
124 orange_red = 0xFF4500, // rgb(255,69,0)
125 orchid = 0xDA70D6, // rgb(218,112,214)
126 pale_golden_rod = 0xEEE8AA, // rgb(238,232,170)
127 pale_green = 0x98FB98, // rgb(152,251,152)
128 pale_turquoise = 0xAFEEEE, // rgb(175,238,238)
129 pale_violet_red = 0xDB7093, // rgb(219,112,147)
130 papaya_whip = 0xFFEFD5, // rgb(255,239,213)
131 peach_puff = 0xFFDAB9, // rgb(255,218,185)
132 peru = 0xCD853F, // rgb(205,133,63)
133 pink = 0xFFC0CB, // rgb(255,192,203)
134 plum = 0xDDA0DD, // rgb(221,160,221)
135 powder_blue = 0xB0E0E6, // rgb(176,224,230)
136 purple = 0x800080, // rgb(128,0,128)
137 rebecca_purple = 0x663399, // rgb(102,51,153)
138 red = 0xFF0000, // rgb(255,0,0)
139 rosy_brown = 0xBC8F8F, // rgb(188,143,143)
140 royal_blue = 0x4169E1, // rgb(65,105,225)
141 saddle_brown = 0x8B4513, // rgb(139,69,19)
142 salmon = 0xFA8072, // rgb(250,128,114)
143 sandy_brown = 0xF4A460, // rgb(244,164,96)
144 sea_green = 0x2E8B57, // rgb(46,139,87)
145 sea_shell = 0xFFF5EE, // rgb(255,245,238)
146 sienna = 0xA0522D, // rgb(160,82,45)
147 silver = 0xC0C0C0, // rgb(192,192,192)
148 sky_blue = 0x87CEEB, // rgb(135,206,235)
149 slate_blue = 0x6A5ACD, // rgb(106,90,205)
150 slate_gray = 0x708090, // rgb(112,128,144)
151 snow = 0xFFFAFA, // rgb(255,250,250)
152 spring_green = 0x00FF7F, // rgb(0,255,127)
153 steel_blue = 0x4682B4, // rgb(70,130,180)
154 tan = 0xD2B48C, // rgb(210,180,140)
155 teal = 0x008080, // rgb(0,128,128)
156 thistle = 0xD8BFD8, // rgb(216,191,216)
157 tomato = 0xFF6347, // rgb(255,99,71)
158 turquoise = 0x40E0D0, // rgb(64,224,208)
159 violet = 0xEE82EE, // rgb(238,130,238)
160 wheat = 0xF5DEB3, // rgb(245,222,179)
161 white = 0xFFFFFF, // rgb(255,255,255)
162 white_smoke = 0xF5F5F5, // rgb(245,245,245)
163 yellow = 0xFFFF00, // rgb(255,255,0)
164 yellow_green = 0x9ACD32 // rgb(154,205,50)
165}; // enum class color
166
167enum class terminal_color : uint8_t {
168 black = 30,
169 red,
170 green,
171 yellow,
172 blue,
173 magenta,
174 cyan,
175 white,
176 bright_black = 90,
184};
185
186enum class emphasis : uint8_t {
187 bold = 1,
188 italic = 1 << 1,
189 underline = 1 << 2,
190 strikethrough = 1 << 3
191};
192
193// rgb is a struct for red, green and blue colors.
194// Using the name "rgb" makes some editors show the color in a tooltip.
195struct rgb {
196 FMT_CONSTEXPR rgb() : r(0), g(0), b(0) {}
197 FMT_CONSTEXPR rgb(uint8_t r_, uint8_t g_, uint8_t b_) : r(r_), g(g_), b(b_) {}
199 : r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b(hex & 0xFF) {}
201 : r((uint32_t(hex) >> 16) & 0xFF),
202 g((uint32_t(hex) >> 8) & 0xFF),
203 b(uint32_t(hex) & 0xFF) {}
204 uint8_t r;
205 uint8_t g;
206 uint8_t b;
207};
208
210
211// color is a struct of either a rgb color or a terminal color.
215 value{} {
216 value.rgb_color = static_cast<uint32_t>(rgb_color);
217 }
219 value.rgb_color = (static_cast<uint32_t>(rgb_color.r) << 16) |
220 (static_cast<uint32_t>(rgb_color.g) << 8) | rgb_color.b;
221 }
223 value{} {
224 value.term_color = static_cast<uint8_t>(term_color);
225 }
226 bool is_rgb;
228 uint8_t term_color;
229 uint32_t rgb_color;
231};
232
234
235/** A text style consisting of foreground and background colors and emphasis. */
237 public:
242
247 } else if (rhs.set_foreground_color) {
248 if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb)
249 FMT_THROW(format_error("can't OR a terminal color"));
250 foreground_color.value.rgb_color |= rhs.foreground_color.value.rgb_color;
251 }
252
256 } else if (rhs.set_background_color) {
257 if (!background_color.is_rgb || !rhs.background_color.is_rgb)
258 FMT_THROW(format_error("can't OR a terminal color"));
259 background_color.value.rgb_color |= rhs.background_color.value.rgb_color;
260 }
261
262 ems = static_cast<emphasis>(static_cast<uint8_t>(ems) |
263 static_cast<uint8_t>(rhs.ems));
264 return *this;
265 }
266
268 const text_style& rhs) {
269 return lhs |= rhs;
270 }
271
276
278 operator&(text_style lhs, const text_style& rhs) {
279 return lhs.and_assign(rhs);
280 }
281
289 return static_cast<uint8_t>(ems) != 0;
290 }
291 FMT_CONSTEXPR detail::color_type get_foreground() const FMT_NOEXCEPT {
292 FMT_ASSERT(has_foreground(), "no foreground specified for this style");
293 return foreground_color;
294 }
295 FMT_CONSTEXPR detail::color_type get_background() const FMT_NOEXCEPT {
296 FMT_ASSERT(has_background(), "no background specified for this style");
297 return background_color;
298 }
300 FMT_ASSERT(has_emphasis(), "no emphasis specified for this style");
301 return ems;
302 }
303
304 private:
305 FMT_CONSTEXPR text_style(bool is_foreground,
306 detail::color_type text_color) FMT_NOEXCEPT
309 ems() {
310 if (is_foreground) {
311 foreground_color = text_color;
313 } else {
314 background_color = text_color;
316 }
317 }
318
319 // DEPRECATED!
324 } else if (rhs.set_foreground_color) {
325 if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb)
326 FMT_THROW(format_error("can't AND a terminal color"));
327 foreground_color.value.rgb_color &= rhs.foreground_color.value.rgb_color;
328 }
329
333 } else if (rhs.set_background_color) {
334 if (!background_color.is_rgb || !rhs.background_color.is_rgb)
335 FMT_THROW(format_error("can't AND a terminal color"));
336 background_color.value.rgb_color &= rhs.background_color.value.rgb_color;
337 }
338
339 ems = static_cast<emphasis>(static_cast<uint8_t>(ems) &
340 static_cast<uint8_t>(rhs.ems));
341 return *this;
342 }
343
344 friend FMT_CONSTEXPR_DECL text_style fg(detail::color_type foreground)
346
347 friend FMT_CONSTEXPR_DECL text_style bg(detail::color_type background)
349
350 detail::color_type foreground_color;
351 detail::color_type background_color;
355};
356
357/** Creates a text style from the foreground (text) color. */
358FMT_CONSTEXPR inline text_style fg(detail::color_type foreground) FMT_NOEXCEPT {
359 return text_style(true, foreground);
360}
361
362/** Creates a text style from the background color. */
363FMT_CONSTEXPR inline text_style bg(detail::color_type background) FMT_NOEXCEPT {
364 return text_style(false, background);
365}
366
369 return text_style(lhs) | rhs;
370}
371
373
374template <typename Char> struct ansi_color_escape {
375 FMT_CONSTEXPR ansi_color_escape(detail::color_type text_color,
376 const char* esc) FMT_NOEXCEPT {
377 // If we have a terminal color, we need to output another escape code
378 // sequence.
379 if (!text_color.is_rgb) {
380 bool is_background = esc == string_view("\x1b[48;2;");
381 uint32_t value = text_color.value.term_color;
382 // Background ASCII codes are the same as the foreground ones but with
383 // 10 more.
384 if (is_background) value += 10u;
385
386 size_t index = 0;
387 buffer[index++] = static_cast<Char>('\x1b');
388 buffer[index++] = static_cast<Char>('[');
389
390 if (value >= 100u) {
391 buffer[index++] = static_cast<Char>('1');
392 value %= 100u;
393 }
394 buffer[index++] = static_cast<Char>('0' + value / 10u);
395 buffer[index++] = static_cast<Char>('0' + value % 10u);
396
397 buffer[index++] = static_cast<Char>('m');
398 buffer[index++] = static_cast<Char>('\0');
399 return;
400 }
401
402 for (int i = 0; i < 7; i++) {
403 buffer[i] = static_cast<Char>(esc[i]);
404 }
405 rgb color(text_color.value.rgb_color);
406 to_esc(color.r, buffer + 7, ';');
407 to_esc(color.g, buffer + 11, ';');
408 to_esc(color.b, buffer + 15, 'm');
409 buffer[19] = static_cast<Char>(0);
410 }
412 uint8_t em_codes[4] = {};
413 uint8_t em_bits = static_cast<uint8_t>(em);
414 if (em_bits & static_cast<uint8_t>(emphasis::bold)) em_codes[0] = 1;
415 if (em_bits & static_cast<uint8_t>(emphasis::italic)) em_codes[1] = 3;
416 if (em_bits & static_cast<uint8_t>(emphasis::underline)) em_codes[2] = 4;
417 if (em_bits & static_cast<uint8_t>(emphasis::strikethrough))
418 em_codes[3] = 9;
419
420 size_t index = 0;
421 for (int i = 0; i < 4; ++i) {
422 if (!em_codes[i]) continue;
423 buffer[index++] = static_cast<Char>('\x1b');
424 buffer[index++] = static_cast<Char>('[');
425 buffer[index++] = static_cast<Char>('0' + em_codes[i]);
426 buffer[index++] = static_cast<Char>('m');
427 }
428 buffer[index++] = static_cast<Char>(0);
429 }
430 FMT_CONSTEXPR operator const Char*() const FMT_NOEXCEPT { return buffer; }
431
432 FMT_CONSTEXPR const Char* begin() const FMT_NOEXCEPT { return buffer; }
436
437 private:
438 Char buffer[7u + 3u * 4u + 1u];
439
440 static FMT_CONSTEXPR void to_esc(uint8_t c, Char* out,
441 char delimiter) FMT_NOEXCEPT {
442 out[0] = static_cast<Char>('0' + c / 100);
443 out[1] = static_cast<Char>('0' + c / 10 % 10);
444 out[2] = static_cast<Char>('0' + c % 10);
445 out[3] = static_cast<Char>(delimiter);
446 }
447};
448
449template <typename Char>
451 detail::color_type foreground) FMT_NOEXCEPT {
452 return ansi_color_escape<Char>(foreground, "\x1b[38;2;");
453}
454
455template <typename Char>
457 detail::color_type background) FMT_NOEXCEPT {
458 return ansi_color_escape<Char>(background, "\x1b[48;2;");
459}
460
461template <typename Char>
465
466template <typename Char>
467inline void fputs(const Char* chars, FILE* stream) FMT_NOEXCEPT {
468 std::fputs(chars, stream);
469}
470
471template <>
472inline void fputs<wchar_t>(const wchar_t* chars, FILE* stream) FMT_NOEXCEPT {
473 std::fputws(chars, stream);
474}
475
476template <typename Char> inline void reset_color(FILE* stream) FMT_NOEXCEPT {
477 fputs("\x1b[0m", stream);
478}
479
480template <> inline void reset_color<wchar_t>(FILE* stream) FMT_NOEXCEPT {
481 fputs(L"\x1b[0m", stream);
482}
483
484template <typename Char>
486 auto reset_color = string_view("\x1b[0m");
487 buffer.append(reset_color.begin(), reset_color.end());
488}
489
490template <typename Char>
491void vformat_to(buffer<Char>& buf, const text_style& ts,
492 basic_string_view<Char> format_str,
494 bool has_style = false;
495 if (ts.has_emphasis()) {
496 has_style = true;
497 auto emphasis = detail::make_emphasis<Char>(ts.get_emphasis());
498 buf.append(emphasis.begin(), emphasis.end());
499 }
500 if (ts.has_foreground()) {
501 has_style = true;
502 auto foreground = detail::make_foreground_color<Char>(ts.get_foreground());
503 buf.append(foreground.begin(), foreground.end());
504 }
505 if (ts.has_background()) {
506 has_style = true;
507 auto background = detail::make_background_color<Char>(ts.get_background());
508 buf.append(background.begin(), background.end());
509 }
510 detail::vformat_to(buf, format_str, args, {});
511 if (has_style) detail::reset_color<Char>(buf);
512}
513
515
516template <typename S, typename Char = char_t<S>>
517void vprint(std::FILE* f, const text_style& ts, const S& format,
520 detail::vformat_to(buf, ts, to_string_view(format), args);
521 buf.push_back(Char(0));
522 detail::fputs(buf.data(), f);
523}
524
525/**
526 \rst
527 Formats a string and prints it to the specified file stream using ANSI
528 escape sequences to specify text formatting.
529
530 **Example**::
531
532 fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
533 "Elapsed time: {0:.2f} seconds", 1.23);
534 \endrst
535 */
536template <typename S, typename... Args,
537 FMT_ENABLE_IF(detail::is_string<S>::value)>
538void print(std::FILE* f, const text_style& ts, const S& format_str,
539 const Args&... args) {
540 vprint(f, ts, format_str,
541 fmt::make_args_checked<Args...>(format_str, args...));
542}
543
544/**
545 \rst
546 Formats a string and prints it to stdout using ANSI escape sequences to
547 specify text formatting.
548
549 **Example**::
550
551 fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
552 "Elapsed time: {0:.2f} seconds", 1.23);
553 \endrst
554 */
555template <typename S, typename... Args,
556 FMT_ENABLE_IF(detail::is_string<S>::value)>
557void print(const text_style& ts, const S& format_str, const Args&... args) {
558 return print(stdout, ts, format_str, args...);
559}
560
561template <typename S, typename Char = char_t<S>>
563 const text_style& ts, const S& format_str,
566 detail::vformat_to(buf, ts, to_string_view(format_str), args);
567 return fmt::to_string(buf);
568}
569
570/**
571 \rst
572 Formats arguments and returns the result as a string using ANSI
573 escape sequences to specify text formatting.
574
575 **Example**::
576
577 #include <fmt/color.h>
578 std::string message = fmt::format(fmt::emphasis::bold | fg(fmt::color::red),
579 "The answer is {}", 42);
580 \endrst
581*/
582template <typename S, typename... Args, typename Char = char_t<S>>
583inline std::basic_string<Char> format(const text_style& ts, const S& format_str,
584 const Args&... args) {
585 return fmt::vformat(ts, to_string_view(format_str),
586 fmt::make_args_checked<Args...>(format_str, args...));
587}
588
589/**
590 Formats a string with the given text_style and writes the output to ``out``.
591 */
592template <typename OutputIt, typename Char,
593 FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value)>
594OutputIt vformat_to(
595 OutputIt out, const text_style& ts, basic_string_view<Char> format_str,
597 auto&& buf = detail::get_buffer<Char>(out);
598 detail::vformat_to(buf, ts, format_str, args);
599 return detail::get_iterator(buf);
600}
601
602/**
603 \rst
604 Formats arguments with the given text_style, writes the result to the output
605 iterator ``out`` and returns the iterator past the end of the output range.
606
607 **Example**::
608
609 std::vector<char> out;
610 fmt::format_to(std::back_inserter(out),
611 fmt::emphasis::bold | fg(fmt::color::red), "{}", 42);
612 \endrst
613*/
614template <typename OutputIt, typename S, typename... Args,
615 bool enable = detail::is_output_iterator<OutputIt, char_t<S>>::value&&
616 detail::is_string<S>::value>
617inline auto format_to(OutputIt out, const text_style& ts, const S& format_str,
618 Args&&... args) ->
620 return vformat_to(out, ts, to_string_view(format_str),
621 fmt::make_args_checked<Args...>(format_str, args...));
622}
623
626
627#endif // FMT_COLOR_H_
Definition core.h:749
void append(const U *begin, const U *end)
friend FMT_CONSTEXPR_DECL text_style bg(detail::color_type background) FMT_NOEXCEPT
Definition color.h:363
friend FMT_CONSTEXPR text_style operator|(text_style lhs, const text_style &rhs)
Definition color.h:267
FMT_CONSTEXPR detail::color_type get_background() const FMT_NOEXCEPT
Definition color.h:295
emphasis ems
Definition color.h:354
FMT_CONSTEXPR bool has_emphasis() const FMT_NOEXCEPT
Definition color.h:288
FMT_CONSTEXPR text_style(emphasis em=emphasis()) FMT_NOEXCEPT
Definition color.h:238
FMT_CONSTEXPR text_style & operator|=(const text_style &rhs)
Definition color.h:243
bool set_foreground_color
Definition color.h:352
friend FMT_CONSTEXPR_DECL text_style fg(detail::color_type foreground) FMT_NOEXCEPT
Definition color.h:358
FMT_CONSTEXPR detail::color_type get_foreground() const FMT_NOEXCEPT
Definition color.h:291
FMT_DEPRECATED_NONMSVC friend FMT_CONSTEXPR text_style operator&(text_style lhs, const text_style &rhs)
Definition color.h:278
FMT_CONSTEXPR bool has_foreground() const FMT_NOEXCEPT
Definition color.h:282
FMT_CONSTEXPR text_style(bool is_foreground, detail::color_type text_color) FMT_NOEXCEPT
Definition color.h:305
detail::color_type background_color
Definition color.h:351
FMT_CONSTEXPR text_style & and_assign(const text_style &rhs)
Definition color.h:320
FMT_CONSTEXPR emphasis get_emphasis() const FMT_NOEXCEPT
Definition color.h:299
detail::color_type foreground_color
Definition color.h:350
FMT_DEPRECATED_NONMSVC FMT_CONSTEXPR text_style & operator&=(const text_style &rhs)
Definition color.h:272
bool set_background_color
Definition color.h:353
FMT_CONSTEXPR bool has_background() const FMT_NOEXCEPT
Definition color.h:285
Definition core.h:1120
constexpr FMT_INLINE value()
Definition core.h:1143
void print(std::FILE *f, const text_style &ts, const S &format_str, const Args &... args)
Definition color.h:538
auto format_to(OutputIt out, const text_style &ts, const S &format_str, Args &&... args) -> typename std::enable_if< enable, OutputIt >::type
Definition color.h:617
FMT_CONSTEXPR ansi_color_escape< Char > make_background_color(detail::color_type background) FMT_NOEXCEPT
Definition color.h:456
FMT_CONSTEXPR text_style operator|(emphasis lhs, emphasis rhs) FMT_NOEXCEPT
Definition color.h:367
void reset_color(FILE *stream) FMT_NOEXCEPT
Definition color.h:476
emphasis
Definition color.h:186
FMT_CONSTEXPR text_style fg(detail::color_type foreground) FMT_NOEXCEPT
Definition color.h:358
FMT_CONSTEXPR ansi_color_escape< Char > make_emphasis(emphasis em) FMT_NOEXCEPT
Definition color.h:462
#define FMT_DEPRECATED_NONMSVC
Definition color.h:17
void vformat_to(buffer< Char > &buf, const text_style &ts, basic_string_view< Char > format_str, basic_format_args< buffer_context< type_identity_t< Char > > > args)
Definition color.h:491
FMT_CONSTEXPR ansi_color_escape< Char > make_foreground_color(detail::color_type foreground) FMT_NOEXCEPT
Definition color.h:450
terminal_color
Definition color.h:167
color
Definition color.h:23
@ steel_blue
@ misty_rose
@ cadet_blue
@ saddle_brown
@ papaya_whip
@ lavender
@ blue_violet
@ dark_blue
@ mint_cream
@ medium_purple
@ gainsboro
@ sea_green
@ olive_drab
@ fire_brick
@ deep_pink
@ white_smoke
@ deep_sky_blue
@ ghost_white
@ medium_aquamarine
@ aquamarine
@ chartreuse
@ royal_blue
@ lawn_green
@ dark_slate_blue
@ dark_gray
@ dark_violet
@ medium_turquoise
@ light_cyan
@ medium_spring_green
@ dark_salmon
@ antique_white
@ dark_sea_green
@ pale_green
@ pale_golden_rod
@ light_coral
@ dark_orchid
@ dodger_blue
@ old_lace
@ dark_green
@ light_pink
@ light_blue
@ light_salmon
@ navajo_white
@ spring_green
@ light_sky_blue
@ lime_green
@ alice_blue
@ rosy_brown
@ pale_turquoise
@ rebecca_purple
@ medium_blue
@ light_yellow
@ dim_gray
@ powder_blue
@ light_gray
@ blanched_almond
@ midnight_blue
@ lemon_chiffon
@ indian_red
@ golden_rod
@ slate_blue
@ dark_golden_rod
@ forest_green
@ light_sea_green
@ floral_white
@ medium_slate_blue
@ sandy_brown
@ dark_red
@ hot_pink
@ dark_magenta
@ yellow_green
@ dark_orange
@ light_steel_blue
@ pale_violet_red
@ dark_olive_green
@ cornflower_blue
@ light_slate_gray
@ dark_cyan
@ light_green
@ chocolate
@ medium_sea_green
@ sky_blue
@ burly_wood
@ honey_dew
@ green_yellow
@ light_golden_rod_yellow
@ lavender_blush
@ moccasin
@ turquoise
@ medium_orchid
@ dark_khaki
@ dark_slate_gray
@ peach_puff
@ medium_violet_red
@ orange_red
@ cornsilk
@ sea_shell
@ slate_gray
@ dark_turquoise
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)
Definition color.h:583
void fputs< wchar_t >(const wchar_t *chars, FILE *stream) FMT_NOEXCEPT
Definition color.h:472
FMT_END_DETAIL_NAMESPACE void vprint(std::FILE *f, const text_style &ts, const S &format, basic_format_args< buffer_context< type_identity_t< Char > > > args)
Definition color.h:517
void fputs(const Char *chars, FILE *stream) FMT_NOEXCEPT
Definition color.h:467
std::basic_string< Char > vformat(const text_style &ts, const S &format_str, basic_format_args< buffer_context< type_identity_t< Char > > > args)
Definition color.h:562
void reset_color< wchar_t >(FILE *stream) FMT_NOEXCEPT
Definition color.h:480
FMT_CONSTEXPR text_style bg(detail::color_type background) FMT_NOEXCEPT
Definition color.h:363
#define FMT_ASSERT(condition, message)
Definition core.h:372
typename detail::char_t_impl< S >::type char_t
Definition core.h:610
#define FMT_END_DETAIL_NAMESPACE
Definition core.h:245
#define FMT_MODULE_EXPORT_BEGIN
Definition core.h:242
#define FMT_CONSTEXPR
Definition core.h:99
#define FMT_BEGIN_NAMESPACE
Definition core.h:235
#define FMT_BEGIN_DETAIL_NAMESPACE
Definition core.h:244
#define FMT_ENABLE_IF(...)
Definition core.h:347
#define FMT_CONSTEXPR_CHAR_TRAITS
Definition core.h:116
typename type_identity< T >::type type_identity_t
Definition core.h:330
#define FMT_END_NAMESPACE
Definition core.h:230
#define FMT_MODULE_EXPORT_END
Definition core.h:243
#define FMT_NOEXCEPT
Definition core.h:156
#define FMT_CONSTEXPR_DECL
Definition core.h:100
#define FMT_THROW(x)
Definition format.h:96
T fputs(T... args)
T fputws(T... args)
T length(T... args)
FMT_CONSTEXPR_CHAR_TRAITS const Char * end() const FMT_NOEXCEPT
Definition color.h:433
Char buffer[7u+3u *4u+1u]
Definition color.h:438
FMT_CONSTEXPR ansi_color_escape(detail::color_type text_color, const char *esc) FMT_NOEXCEPT
Definition color.h:375
FMT_CONSTEXPR ansi_color_escape(emphasis em) FMT_NOEXCEPT
Definition color.h:411
static FMT_CONSTEXPR void to_esc(uint8_t c, Char *out, char delimiter) FMT_NOEXCEPT
Definition color.h:440
FMT_CONSTEXPR const Char * begin() const FMT_NOEXCEPT
Definition color.h:432
FMT_CONSTEXPR color_type() FMT_NOEXCEPT
Definition color.h:213
FMT_CONSTEXPR color_type(color rgb_color) FMT_NOEXCEPT
Definition color.h:214
FMT_CONSTEXPR color_type(rgb rgb_color) FMT_NOEXCEPT
Definition color.h:218
FMT_CONSTEXPR color_type(terminal_color term_color) FMT_NOEXCEPT
Definition color.h:222
union color_type::color_union value
bool is_rgb
Definition color.h:226
Definition color.h:195
FMT_CONSTEXPR rgb(uint32_t hex)
Definition color.h:198
FMT_CONSTEXPR rgb()
Definition color.h:196
FMT_CONSTEXPR rgb(uint8_t r_, uint8_t g_, uint8_t b_)
Definition color.h:197
FMT_CONSTEXPR rgb(color hex)
Definition color.h:200
uint8_t b
Definition color.h:206
uint8_t g
Definition color.h:205
uint8_t r
Definition color.h:204