Photon 1.0.0
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
15
16enum class color : uint32_t
17{
18 alice_blue = 0xF0F8FF, // rgb(240,248,255)
19 antique_white = 0xFAEBD7, // rgb(250,235,215)
20 aqua = 0x00FFFF, // rgb(0,255,255)
21 aquamarine = 0x7FFFD4, // rgb(127,255,212)
22 azure = 0xF0FFFF, // rgb(240,255,255)
23 beige = 0xF5F5DC, // rgb(245,245,220)
24 bisque = 0xFFE4C4, // rgb(255,228,196)
25 black = 0x000000, // rgb(0,0,0)
26 blanched_almond = 0xFFEBCD, // rgb(255,235,205)
27 blue = 0x0000FF, // rgb(0,0,255)
28 blue_violet = 0x8A2BE2, // rgb(138,43,226)
29 brown = 0xA52A2A, // rgb(165,42,42)
30 burly_wood = 0xDEB887, // rgb(222,184,135)
31 cadet_blue = 0x5F9EA0, // rgb(95,158,160)
32 chartreuse = 0x7FFF00, // rgb(127,255,0)
33 chocolate = 0xD2691E, // rgb(210,105,30)
34 coral = 0xFF7F50, // rgb(255,127,80)
35 cornflower_blue = 0x6495ED, // rgb(100,149,237)
36 cornsilk = 0xFFF8DC, // rgb(255,248,220)
37 crimson = 0xDC143C, // rgb(220,20,60)
38 cyan = 0x00FFFF, // rgb(0,255,255)
39 dark_blue = 0x00008B, // rgb(0,0,139)
40 dark_cyan = 0x008B8B, // rgb(0,139,139)
41 dark_golden_rod = 0xB8860B, // rgb(184,134,11)
42 dark_gray = 0xA9A9A9, // rgb(169,169,169)
43 dark_green = 0x006400, // rgb(0,100,0)
44 dark_khaki = 0xBDB76B, // rgb(189,183,107)
45 dark_magenta = 0x8B008B, // rgb(139,0,139)
46 dark_olive_green = 0x556B2F, // rgb(85,107,47)
47 dark_orange = 0xFF8C00, // rgb(255,140,0)
48 dark_orchid = 0x9932CC, // rgb(153,50,204)
49 dark_red = 0x8B0000, // rgb(139,0,0)
50 dark_salmon = 0xE9967A, // rgb(233,150,122)
51 dark_sea_green = 0x8FBC8F, // rgb(143,188,143)
52 dark_slate_blue = 0x483D8B, // rgb(72,61,139)
53 dark_slate_gray = 0x2F4F4F, // rgb(47,79,79)
54 dark_turquoise = 0x00CED1, // rgb(0,206,209)
55 dark_violet = 0x9400D3, // rgb(148,0,211)
56 deep_pink = 0xFF1493, // rgb(255,20,147)
57 deep_sky_blue = 0x00BFFF, // rgb(0,191,255)
58 dim_gray = 0x696969, // rgb(105,105,105)
59 dodger_blue = 0x1E90FF, // rgb(30,144,255)
60 fire_brick = 0xB22222, // rgb(178,34,34)
61 floral_white = 0xFFFAF0, // rgb(255,250,240)
62 forest_green = 0x228B22, // rgb(34,139,34)
63 fuchsia = 0xFF00FF, // rgb(255,0,255)
64 gainsboro = 0xDCDCDC, // rgb(220,220,220)
65 ghost_white = 0xF8F8FF, // rgb(248,248,255)
66 gold = 0xFFD700, // rgb(255,215,0)
67 golden_rod = 0xDAA520, // rgb(218,165,32)
68 gray = 0x808080, // rgb(128,128,128)
69 green = 0x008000, // rgb(0,128,0)
70 green_yellow = 0xADFF2F, // rgb(173,255,47)
71 honey_dew = 0xF0FFF0, // rgb(240,255,240)
72 hot_pink = 0xFF69B4, // rgb(255,105,180)
73 indian_red = 0xCD5C5C, // rgb(205,92,92)
74 indigo = 0x4B0082, // rgb(75,0,130)
75 ivory = 0xFFFFF0, // rgb(255,255,240)
76 khaki = 0xF0E68C, // rgb(240,230,140)
77 lavender = 0xE6E6FA, // rgb(230,230,250)
78 lavender_blush = 0xFFF0F5, // rgb(255,240,245)
79 lawn_green = 0x7CFC00, // rgb(124,252,0)
80 lemon_chiffon = 0xFFFACD, // rgb(255,250,205)
81 light_blue = 0xADD8E6, // rgb(173,216,230)
82 light_coral = 0xF08080, // rgb(240,128,128)
83 light_cyan = 0xE0FFFF, // rgb(224,255,255)
84 light_golden_rod_yellow = 0xFAFAD2, // rgb(250,250,210)
85 light_gray = 0xD3D3D3, // rgb(211,211,211)
86 light_green = 0x90EE90, // rgb(144,238,144)
87 light_pink = 0xFFB6C1, // rgb(255,182,193)
88 light_salmon = 0xFFA07A, // rgb(255,160,122)
89 light_sea_green = 0x20B2AA, // rgb(32,178,170)
90 light_sky_blue = 0x87CEFA, // rgb(135,206,250)
91 light_slate_gray = 0x778899, // rgb(119,136,153)
92 light_steel_blue = 0xB0C4DE, // rgb(176,196,222)
93 light_yellow = 0xFFFFE0, // rgb(255,255,224)
94 lime = 0x00FF00, // rgb(0,255,0)
95 lime_green = 0x32CD32, // rgb(50,205,50)
96 linen = 0xFAF0E6, // rgb(250,240,230)
97 magenta = 0xFF00FF, // rgb(255,0,255)
98 maroon = 0x800000, // rgb(128,0,0)
99 medium_aquamarine = 0x66CDAA, // rgb(102,205,170)
100 medium_blue = 0x0000CD, // rgb(0,0,205)
101 medium_orchid = 0xBA55D3, // rgb(186,85,211)
102 medium_purple = 0x9370DB, // rgb(147,112,219)
103 medium_sea_green = 0x3CB371, // rgb(60,179,113)
104 medium_slate_blue = 0x7B68EE, // rgb(123,104,238)
105 medium_spring_green = 0x00FA9A, // rgb(0,250,154)
106 medium_turquoise = 0x48D1CC, // rgb(72,209,204)
107 medium_violet_red = 0xC71585, // rgb(199,21,133)
108 midnight_blue = 0x191970, // rgb(25,25,112)
109 mint_cream = 0xF5FFFA, // rgb(245,255,250)
110 misty_rose = 0xFFE4E1, // rgb(255,228,225)
111 moccasin = 0xFFE4B5, // rgb(255,228,181)
112 navajo_white = 0xFFDEAD, // rgb(255,222,173)
113 navy = 0x000080, // rgb(0,0,128)
114 old_lace = 0xFDF5E6, // rgb(253,245,230)
115 olive = 0x808000, // rgb(128,128,0)
116 olive_drab = 0x6B8E23, // rgb(107,142,35)
117 orange = 0xFFA500, // rgb(255,165,0)
118 orange_red = 0xFF4500, // rgb(255,69,0)
119 orchid = 0xDA70D6, // rgb(218,112,214)
120 pale_golden_rod = 0xEEE8AA, // rgb(238,232,170)
121 pale_green = 0x98FB98, // rgb(152,251,152)
122 pale_turquoise = 0xAFEEEE, // rgb(175,238,238)
123 pale_violet_red = 0xDB7093, // rgb(219,112,147)
124 papaya_whip = 0xFFEFD5, // rgb(255,239,213)
125 peach_puff = 0xFFDAB9, // rgb(255,218,185)
126 peru = 0xCD853F, // rgb(205,133,63)
127 pink = 0xFFC0CB, // rgb(255,192,203)
128 plum = 0xDDA0DD, // rgb(221,160,221)
129 powder_blue = 0xB0E0E6, // rgb(176,224,230)
130 purple = 0x800080, // rgb(128,0,128)
131 rebecca_purple = 0x663399, // rgb(102,51,153)
132 red = 0xFF0000, // rgb(255,0,0)
133 rosy_brown = 0xBC8F8F, // rgb(188,143,143)
134 royal_blue = 0x4169E1, // rgb(65,105,225)
135 saddle_brown = 0x8B4513, // rgb(139,69,19)
136 salmon = 0xFA8072, // rgb(250,128,114)
137 sandy_brown = 0xF4A460, // rgb(244,164,96)
138 sea_green = 0x2E8B57, // rgb(46,139,87)
139 sea_shell = 0xFFF5EE, // rgb(255,245,238)
140 sienna = 0xA0522D, // rgb(160,82,45)
141 silver = 0xC0C0C0, // rgb(192,192,192)
142 sky_blue = 0x87CEEB, // rgb(135,206,235)
143 slate_blue = 0x6A5ACD, // rgb(106,90,205)
144 slate_gray = 0x708090, // rgb(112,128,144)
145 snow = 0xFFFAFA, // rgb(255,250,250)
146 spring_green = 0x00FF7F, // rgb(0,255,127)
147 steel_blue = 0x4682B4, // rgb(70,130,180)
148 tan = 0xD2B48C, // rgb(210,180,140)
149 teal = 0x008080, // rgb(0,128,128)
150 thistle = 0xD8BFD8, // rgb(216,191,216)
151 tomato = 0xFF6347, // rgb(255,99,71)
152 turquoise = 0x40E0D0, // rgb(64,224,208)
153 violet = 0xEE82EE, // rgb(238,130,238)
154 wheat = 0xF5DEB3, // rgb(245,222,179)
155 white = 0xFFFFFF, // rgb(255,255,255)
156 white_smoke = 0xF5F5F5, // rgb(245,245,245)
157 yellow = 0xFFFF00, // rgb(255,255,0)
158 yellow_green = 0x9ACD32 // rgb(154,205,50)
159}; // enum class color
160
161enum class terminal_color : uint8_t
162{
163 black = 30,
164 red,
165 green,
166 yellow,
167 blue,
168 magenta,
169 cyan,
170 white,
171 bright_black = 90,
179};
180
181enum class emphasis : uint8_t
182{
183 bold = 1,
184 faint = 1 << 1,
185 italic = 1 << 2,
186 underline = 1 << 3,
187 blink = 1 << 4,
188 reverse = 1 << 5,
189 conceal = 1 << 6,
190 strikethrough = 1 << 7,
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{
198 : r(0), g(0), b(0)
199 {
200 }
201 FMT_CONSTEXPR rgb(uint8_t r_, uint8_t g_, uint8_t b_)
202 : r(r_), g(g_), b(b_)
203 {
204 }
206 : r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b(hex & 0xFF)
207 {
208 }
210 : r((uint32_t(hex) >> 16) & 0xFF),
211 g((uint32_t(hex) >> 8) & 0xFF),
212 b(uint32_t(hex) & 0xFF)
213 {
214 }
215 uint8_t r;
216 uint8_t g;
217 uint8_t b;
218};
219
221
222// color is a struct of either a rgb color or a terminal color.
224{
226 : is_rgb(), value{}
227 {
228 }
229 FMT_CONSTEXPR color_type(color rgb_color) noexcept
230 : is_rgb(true), value{}
231 {
232 value.rgb_color = static_cast<uint32_t>(rgb_color);
233 }
234 FMT_CONSTEXPR color_type(rgb rgb_color) noexcept
235 : is_rgb(true), value{}
236 {
237 value.rgb_color = (static_cast<uint32_t>(rgb_color.r) << 16) |
238 (static_cast<uint32_t>(rgb_color.g) << 8) | rgb_color.b;
239 }
241 : is_rgb(), value{}
242 {
243 value.term_color = static_cast<uint8_t>(term_color);
244 }
245 bool is_rgb;
247 uint8_t term_color;
248 uint32_t rgb_color;
250};
251
253
256{
257public:
262
264 {
266 {
269 }
270 else if (rhs.set_foreground_color)
271 {
272 if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb)
273 FMT_THROW(format_error("can't OR a terminal color"));
274 foreground_color.value.rgb_color |= rhs.foreground_color.value.rgb_color;
275 }
276
278 {
281 }
282 else if (rhs.set_background_color)
283 {
284 if (!background_color.is_rgb || !rhs.background_color.is_rgb)
285 FMT_THROW(format_error("can't OR a terminal color"));
286 background_color.value.rgb_color |= rhs.background_color.value.rgb_color;
287 }
288
289 ems = static_cast<emphasis>(static_cast<uint8_t>(ems) |
290 static_cast<uint8_t>(rhs.ems));
291 return *this;
292 }
293
295 const text_style& rhs)
296 {
297 return lhs |= rhs;
298 }
299
300 FMT_CONSTEXPR bool has_foreground() const noexcept
301 {
303 }
304 FMT_CONSTEXPR bool has_background() const noexcept
305 {
307 }
308 FMT_CONSTEXPR bool has_emphasis() const noexcept
309 {
310 return static_cast<uint8_t>(ems) != 0;
311 }
312 FMT_CONSTEXPR detail::color_type get_foreground() const noexcept
313 {
314 FMT_ASSERT(has_foreground(), "no foreground specified for this style");
315 return foreground_color;
316 }
317 FMT_CONSTEXPR detail::color_type get_background() const noexcept
318 {
319 FMT_ASSERT(has_background(), "no background specified for this style");
320 return background_color;
321 }
323 {
324 FMT_ASSERT(has_emphasis(), "no emphasis specified for this style");
325 return ems;
326 }
327
328private:
329 FMT_CONSTEXPR text_style(bool is_foreground,
330 detail::color_type text_color) noexcept
332 {
333 if (is_foreground)
334 {
335 foreground_color = text_color;
337 }
338 else
339 {
340 background_color = text_color;
342 }
343 }
344
345 friend FMT_CONSTEXPR text_style fg(detail::color_type foreground) noexcept;
346
347 friend FMT_CONSTEXPR text_style bg(detail::color_type background) noexcept;
348
349 detail::color_type foreground_color;
350 detail::color_type background_color;
354};
355
357FMT_CONSTEXPR inline text_style fg(detail::color_type foreground) noexcept
358{
359 return text_style(true, foreground);
360}
361
363FMT_CONSTEXPR inline text_style bg(detail::color_type background) noexcept
364{
365 return text_style(false, background);
366}
367
369{
370 return text_style(lhs) | rhs;
371}
372
374
375template <typename Char>
377{
378 FMT_CONSTEXPR ansi_color_escape(detail::color_type text_color,
379 const char* esc) noexcept
380 {
381 // If we have a terminal color, we need to output another escape code
382 // sequence.
383 if (!text_color.is_rgb)
384 {
385 bool is_background = esc == string_view("\x1b[48;2;");
386 uint32_t value = text_color.value.term_color;
387 // Background ASCII codes are the same as the foreground ones but with
388 // 10 more.
389 if (is_background)
390 value += 10u;
391
392 size_t index = 0;
393 buffer[index++] = static_cast<Char>('\x1b');
394 buffer[index++] = static_cast<Char>('[');
395
396 if (value >= 100u)
397 {
398 buffer[index++] = static_cast<Char>('1');
399 value %= 100u;
400 }
401 buffer[index++] = static_cast<Char>('0' + value / 10u);
402 buffer[index++] = static_cast<Char>('0' + value % 10u);
403
404 buffer[index++] = static_cast<Char>('m');
405 buffer[index++] = static_cast<Char>('\0');
406 return;
407 }
408
409 for (int i = 0; i < 7; i++)
410 {
411 buffer[i] = static_cast<Char>(esc[i]);
412 }
413 rgb color(text_color.value.rgb_color);
414 to_esc(color.r, buffer + 7, ';');
415 to_esc(color.g, buffer + 11, ';');
416 to_esc(color.b, buffer + 15, 'm');
417 buffer[19] = static_cast<Char>(0);
418 }
420 {
421 uint8_t em_codes[num_emphases] = {};
423 em_codes[0] = 1;
425 em_codes[1] = 2;
427 em_codes[2] = 3;
429 em_codes[3] = 4;
431 em_codes[4] = 5;
433 em_codes[5] = 7;
435 em_codes[6] = 8;
437 em_codes[7] = 9;
438
439 size_t index = 0;
440 for (size_t i = 0; i < num_emphases; ++i)
441 {
442 if (!em_codes[i])
443 continue;
444 buffer[index++] = static_cast<Char>('\x1b');
445 buffer[index++] = static_cast<Char>('[');
446 buffer[index++] = static_cast<Char>('0' + em_codes[i]);
447 buffer[index++] = static_cast<Char>('m');
448 }
449 buffer[index++] = static_cast<Char>(0);
450 }
451 FMT_CONSTEXPR operator const Char*() const noexcept
452 {
453 return buffer;
454 }
455
456 FMT_CONSTEXPR const Char* begin() const noexcept
457 {
458 return buffer;
459 }
460 FMT_CONSTEXPR_CHAR_TRAITS const Char* end() const noexcept
461 {
462 return buffer + std::char_traits<Char>::length(buffer);
463 }
464
465private:
466 static constexpr size_t num_emphases = 8;
467 Char buffer[7u + 3u * num_emphases + 1u];
468
469 static FMT_CONSTEXPR void to_esc(uint8_t c, Char* out, char delimiter) noexcept
470 {
471 out[0] = static_cast<Char>('0' + c / 100);
472 out[1] = static_cast<Char>('0' + c / 10 % 10);
473 out[2] = static_cast<Char>('0' + c % 10);
474 out[3] = static_cast<Char>(delimiter);
475 }
476 static FMT_CONSTEXPR bool has_emphasis(emphasis em, emphasis mask) noexcept
477 {
478 return static_cast<uint8_t>(em) & static_cast<uint8_t>(mask);
479 }
480};
481
482template <typename Char>
484 detail::color_type foreground) noexcept
485{
486 return ansi_color_escape<Char>(foreground, "\x1b[38;2;");
487}
488
489template <typename Char>
491 detail::color_type background) noexcept
492{
493 return ansi_color_escape<Char>(background, "\x1b[48;2;");
494}
495
496template <typename Char>
501
502template <typename Char>
503inline void fputs(const Char* chars, FILE* stream)
504{
505 int result = std::fputs(chars, stream);
506 if (result < 0)
507 FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
508}
509
510template <>
511inline void fputs<wchar_t>(const wchar_t* chars, FILE* stream)
512{
513 int result = std::fputws(chars, stream);
514 if (result < 0)
515 FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
516}
517
518template <typename Char>
519inline void reset_color(FILE* stream)
520{
521 fputs("\x1b[0m", stream);
522}
523
524template <>
525inline void reset_color<wchar_t>(FILE* stream)
526{
527 fputs(L"\x1b[0m", stream);
528}
529
530template <typename Char>
532{
533 auto reset_color = string_view("\x1b[0m");
534 buffer.append(reset_color.begin(), reset_color.end());
535}
536
537template <typename T>
539{
540 const T& value;
542};
543
544template <typename Char>
546{
547 bool has_style = false;
548 if (ts.has_emphasis())
549 {
550 has_style = true;
551 auto emphasis = detail::make_emphasis<Char>(ts.get_emphasis());
552 buf.append(emphasis.begin(), emphasis.end());
553 }
554 if (ts.has_foreground())
555 {
556 has_style = true;
557 auto foreground = detail::make_foreground_color<Char>(ts.get_foreground());
558 buf.append(foreground.begin(), foreground.end());
559 }
560 if (ts.has_background())
561 {
562 has_style = true;
563 auto background = detail::make_background_color<Char>(ts.get_background());
564 buf.append(background.begin(), background.end());
565 }
566 detail::vformat_to(buf, format_str, args, {});
567 if (has_style)
568 detail::reset_color<Char>(buf);
569}
570
572
573template <typename S, typename Char = char_t<S>>
574void vprint(std::FILE* f, const text_style& ts, const S& format, basic_format_args<buffer_context<type_identity_t<Char>>> args)
575{
577 detail::vformat_to(buf, ts, detail::to_string_view(format), args);
578 if (detail::is_utf8())
579 {
580 detail::print(f, basic_string_view<Char>(buf.begin(), buf.size()));
581 }
582 else
583 {
584 buf.push_back(Char(0));
585 detail::fputs(buf.data(), f);
586 }
587}
588
600template <typename S, typename... Args, FMT_ENABLE_IF(detail::is_string<S>::value)>
601void print(std::FILE* f, const text_style& ts, const S& format_str, const Args&... args)
602{
603 vprint(f, ts, format_str,
604 fmt::make_format_args<buffer_context<char_t<S>>>(args...));
605}
606
618template <typename S, typename... Args, FMT_ENABLE_IF(detail::is_string<S>::value)>
619void print(const text_style& ts, const S& format_str, const Args&... args)
620{
621 return print(stdout, ts, format_str, args...);
622}
623
624template <typename S, typename Char = char_t<S>>
625inline std::basic_string<Char> vformat(
626 const text_style& ts, const S& format_str, basic_format_args<buffer_context<type_identity_t<Char>>> args)
627{
629 detail::vformat_to(buf, ts, detail::to_string_view(format_str), args);
630 return fmt::to_string(buf);
631}
632
645template <typename S, typename... Args, typename Char = char_t<S>>
646inline std::basic_string<Char> format(const text_style& ts, const S& format_str, const Args&... args)
647{
648 return fmt::vformat(ts, detail::to_string_view(format_str),
649 fmt::make_format_args<buffer_context<Char>>(args...));
650}
651
655template <typename OutputIt, typename Char, FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value)>
656OutputIt vformat_to(
658{
659 auto&& buf = detail::get_buffer<Char>(out);
660 detail::vformat_to(buf, ts, format_str, args);
661 return detail::get_iterator(buf);
662}
663
676template <typename OutputIt, typename S, typename... Args, bool enable = detail::is_output_iterator<OutputIt, char_t<S>>::value && detail::is_string<S>::value>
677inline auto format_to(OutputIt out, const text_style& ts, const S& format_str, Args&&... args) ->
678 typename std::enable_if<enable, OutputIt>::type
679{
680 return vformat_to(out, ts, detail::to_string_view(format_str),
681 fmt::make_format_args<buffer_context<char_t<S>>>(args...));
682}
683
684template <typename T, typename Char>
685struct formatter<detail::styled_arg<T>, Char> : formatter<T, Char>
686{
687 template <typename FormatContext>
688 auto format(const detail::styled_arg<T>& arg, FormatContext& ctx) const
689 -> decltype(ctx.out())
690 {
691 const auto& ts = arg.style;
692 const auto& value = arg.value;
693 auto out = ctx.out();
694
695 bool has_style = false;
696 if (ts.has_emphasis())
697 {
698 has_style = true;
699 auto emphasis = detail::make_emphasis<Char>(ts.get_emphasis());
700 out = std::copy(emphasis.begin(), emphasis.end(), out);
701 }
702 if (ts.has_foreground())
703 {
704 has_style = true;
705 auto foreground =
706 detail::make_foreground_color<Char>(ts.get_foreground());
707 out = std::copy(foreground.begin(), foreground.end(), out);
708 }
709 if (ts.has_background())
710 {
711 has_style = true;
712 auto background =
713 detail::make_background_color<Char>(ts.get_background());
714 out = std::copy(background.begin(), background.end(), out);
715 }
717 if (has_style)
718 {
719 auto reset_color = string_view("\x1b[0m");
720 out = std::copy(reset_color.begin(), reset_color.end(), out);
721 }
722 return out;
723 }
724};
725
738template <typename T>
740 -> detail::styled_arg<remove_cvref_t<T>>
741{
742 return detail::styled_arg<remove_cvref_t<T>>{value, ts};
743}
744
747
748#endif // FMT_COLOR_H_
Definition core.h:2524
Definition core.h:2338
Definition format.h:955
Definition core.h:483
Definition core.h:1032
void append(const U *begin, const U *end)
Definition format.h:1113
Definition color.h:256
FMT_CONSTEXPR bool has_emphasis() const noexcept
Definition color.h:308
friend FMT_CONSTEXPR text_style fg(detail::color_type foreground) noexcept
Definition color.h:357
friend FMT_CONSTEXPR text_style operator|(text_style lhs, const text_style &rhs)
Definition color.h:294
FMT_CONSTEXPR emphasis get_emphasis() const noexcept
Definition color.h:322
emphasis ems
Definition color.h:353
FMT_CONSTEXPR text_style(emphasis em=emphasis()) noexcept
Definition color.h:258
FMT_CONSTEXPR text_style & operator|=(const text_style &rhs)
Definition color.h:263
bool set_foreground_color
Definition color.h:351
FMT_CONSTEXPR detail::color_type get_foreground() const noexcept
Definition color.h:312
FMT_CONSTEXPR text_style(bool is_foreground, detail::color_type text_color) noexcept
Definition color.h:329
detail::color_type background_color
Definition color.h:350
FMT_CONSTEXPR bool has_foreground() const noexcept
Definition color.h:300
friend FMT_CONSTEXPR text_style bg(detail::color_type background) noexcept
Definition color.h:363
detail::color_type foreground_color
Definition color.h:349
FMT_CONSTEXPR detail::color_type get_background() const noexcept
Definition color.h:317
bool set_background_color
Definition color.h:352
FMT_CONSTEXPR bool has_background() const noexcept
Definition color.h:304
Definition core.h:1598
constexpr FMT_INLINE value()
Definition core.h:1621
void fputs(const Char *chars, FILE *stream)
Definition color.h:503
FMT_CONSTEXPR auto styled(const T &value, text_style ts) -> detail::styled_arg< remove_cvref_t< T > >
Definition color.h:739
FMT_CONSTEXPR text_style operator|(emphasis lhs, emphasis rhs) noexcept
Definition color.h:368
void print(std::FILE *f, const text_style &ts, const S &format_str, const Args &... args)
Definition color.h:601
FMT_CONSTEXPR text_style fg(detail::color_type foreground) noexcept
Definition color.h:357
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:677
FMT_CONSTEXPR ansi_color_escape< Char > make_background_color(detail::color_type background) noexcept
Definition color.h:490
emphasis
Definition color.h:182
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:545
terminal_color
Definition color.h:162
color
Definition color.h:17
@ 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:646
FMT_CONSTEXPR ansi_color_escape< Char > make_foreground_color(detail::color_type foreground) noexcept
Definition color.h:483
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:574
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:625
FMT_CONSTEXPR text_style bg(detail::color_type background) noexcept
Definition color.h:363
void reset_color(FILE *stream)
Definition color.h:519
void reset_color< wchar_t >(FILE *stream)
Definition color.h:525
FMT_CONSTEXPR ansi_color_escape< Char > make_emphasis(emphasis em) noexcept
Definition color.h:497
void fputs< wchar_t >(const wchar_t *chars, FILE *stream)
Definition color.h:511
#define FMT_ASSERT(condition, message)
Definition core.h:403
basic_string_view< char > string_view
Definition core.h:604
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Definition core.h:2506
typename detail::char_t_impl< S >::type char_t
Definition core.h:759
#define FMT_END_DETAIL_NAMESPACE
Definition core.h:231
#define FMT_MODULE_EXPORT_BEGIN
Definition core.h:226
#define FMT_CONSTEXPR
Definition core.h:106
#define FMT_BEGIN_NAMESPACE
Definition core.h:214
#define FMT_BEGIN_DETAIL_NAMESPACE
Definition core.h:228
#define FMT_ENABLE_IF(...)
Definition core.h:364
#define FMT_CONSTEXPR_CHAR_TRAITS
Definition core.h:130
typename type_identity< T >::type type_identity_t
Definition core.h:319
#define FMT_END_NAMESPACE
Definition core.h:219
#define FMT_MODULE_EXPORT_END
Definition core.h:227
#define out
Definition encodings.cpp:5
auto system_error(int error_code, format_string< T... > fmt, T &&... args) -> std::system_error
Definition format.h:4326
#define FMT_STRING(s)
Definition format.h:2155
#define FMT_THROW(x)
Definition format.h:99
Definition args.h:20
FMT_FUNC void print(std::FILE *f, string_view text)
Definition format-inl.h:1620
Definition color.h:377
FMT_CONSTEXPR_CHAR_TRAITS const Char * end() const noexcept
Definition color.h:460
static constexpr size_t num_emphases
Definition color.h:466
static FMT_CONSTEXPR void to_esc(uint8_t c, Char *out, char delimiter) noexcept
Definition color.h:469
FMT_CONSTEXPR ansi_color_escape(detail::color_type text_color, const char *esc) noexcept
Definition color.h:378
Char buffer[7u+3u *num_emphases+1u]
Definition color.h:467
FMT_CONSTEXPR const Char * begin() const noexcept
Definition color.h:456
FMT_CONSTEXPR ansi_color_escape(emphasis em) noexcept
Definition color.h:419
static FMT_CONSTEXPR bool has_emphasis(emphasis em, emphasis mask) noexcept
Definition color.h:476
Definition color.h:224
FMT_CONSTEXPR color_type(color rgb_color) noexcept
Definition color.h:229
union color_type::color_union value
FMT_CONSTEXPR color_type(rgb rgb_color) noexcept
Definition color.h:234
FMT_CONSTEXPR color_type(terminal_color term_color) noexcept
Definition color.h:240
FMT_CONSTEXPR color_type() noexcept
Definition color.h:225
bool is_rgb
Definition color.h:245
Definition Bitmap.h:10
byte b
Definition Bitmap.h:11
byte r
Definition Bitmap.h:11
byte g
Definition Bitmap.h:11
auto format(const detail::styled_arg< T > &arg, FormatContext &ctx) const -> decltype(ctx.out())
Definition color.h:688
Definition core.h:944
Definition color.h:196
FMT_CONSTEXPR rgb(uint32_t hex)
Definition color.h:205
FMT_CONSTEXPR rgb()
Definition color.h:197
FMT_CONSTEXPR rgb(uint8_t r_, uint8_t g_, uint8_t b_)
Definition color.h:201
FMT_CONSTEXPR rgb(color hex)
Definition color.h:209
uint8_t b
Definition color.h:217
uint8_t g
Definition color.h:216
uint8_t r
Definition color.h:215
Definition color.h:539
text_style style
Definition color.h:541
const T & value
Definition color.h:540
i
Definition tag_strings.h:60
em
Definition tag_strings.h:44
Definition color.h:246
uint32_t rgb_color
Definition color.h:248
uint8_t term_color
Definition color.h:247