Classes | Namespaces | Enumerations | Functions
color.h File Reference
#include "format.h"
Include dependency graph for color.h:

Go to the source code of this file.

Classes

struct  detail::ansi_color_escape< Char >
 
struct  detail::color_type
 
union  detail::color_type::color_union
 
struct  formatter< detail::styled_arg< T >, Char >
 
struct  rgb
 
struct  detail::styled_arg< T >
 
class  text_style
 

Namespaces

 detail
 

Enumerations

enum  color : uint32_t {
  color::alice_blue = 0xF0F8FF, color::antique_white = 0xFAEBD7, color::aqua = 0x00FFFF, color::aquamarine = 0x7FFFD4,
  color::azure = 0xF0FFFF, color::beige = 0xF5F5DC, color::bisque = 0xFFE4C4, color::black = 0x000000,
  color::blanched_almond = 0xFFEBCD, color::blue = 0x0000FF, color::blue_violet = 0x8A2BE2, color::brown = 0xA52A2A,
  color::burly_wood = 0xDEB887, color::cadet_blue = 0x5F9EA0, color::chartreuse = 0x7FFF00, color::chocolate = 0xD2691E,
  color::coral = 0xFF7F50, color::cornflower_blue = 0x6495ED, color::cornsilk = 0xFFF8DC, color::crimson = 0xDC143C,
  color::cyan = 0x00FFFF, color::dark_blue = 0x00008B, color::dark_cyan = 0x008B8B, color::dark_golden_rod = 0xB8860B,
  color::dark_gray = 0xA9A9A9, color::dark_green = 0x006400, color::dark_khaki = 0xBDB76B, color::dark_magenta = 0x8B008B,
  color::dark_olive_green = 0x556B2F, color::dark_orange = 0xFF8C00, color::dark_orchid = 0x9932CC, color::dark_red = 0x8B0000,
  color::dark_salmon = 0xE9967A, color::dark_sea_green = 0x8FBC8F, color::dark_slate_blue = 0x483D8B, color::dark_slate_gray = 0x2F4F4F,
  color::dark_turquoise = 0x00CED1, color::dark_violet = 0x9400D3, color::deep_pink = 0xFF1493, color::deep_sky_blue = 0x00BFFF,
  color::dim_gray = 0x696969, color::dodger_blue = 0x1E90FF, color::fire_brick = 0xB22222, color::floral_white = 0xFFFAF0,
  color::forest_green = 0x228B22, color::fuchsia = 0xFF00FF, color::gainsboro = 0xDCDCDC, color::ghost_white = 0xF8F8FF,
  color::gold = 0xFFD700, color::golden_rod = 0xDAA520, color::gray = 0x808080, color::green = 0x008000,
  color::green_yellow = 0xADFF2F, color::honey_dew = 0xF0FFF0, color::hot_pink = 0xFF69B4, color::indian_red = 0xCD5C5C,
  color::indigo = 0x4B0082, color::ivory = 0xFFFFF0, color::khaki = 0xF0E68C, color::lavender = 0xE6E6FA,
  color::lavender_blush = 0xFFF0F5, color::lawn_green = 0x7CFC00, color::lemon_chiffon = 0xFFFACD, color::light_blue = 0xADD8E6,
  color::light_coral = 0xF08080, color::light_cyan = 0xE0FFFF, color::light_golden_rod_yellow = 0xFAFAD2, color::light_gray = 0xD3D3D3,
  color::light_green = 0x90EE90, color::light_pink = 0xFFB6C1, color::light_salmon = 0xFFA07A, color::light_sea_green = 0x20B2AA,
  color::light_sky_blue = 0x87CEFA, color::light_slate_gray = 0x778899, color::light_steel_blue = 0xB0C4DE, color::light_yellow = 0xFFFFE0,
  color::lime = 0x00FF00, color::lime_green = 0x32CD32, color::linen = 0xFAF0E6, color::magenta = 0xFF00FF,
  color::maroon = 0x800000, color::medium_aquamarine = 0x66CDAA, color::medium_blue = 0x0000CD, color::medium_orchid = 0xBA55D3,
  color::medium_purple = 0x9370DB, color::medium_sea_green = 0x3CB371, color::medium_slate_blue = 0x7B68EE, color::medium_spring_green = 0x00FA9A,
  color::medium_turquoise = 0x48D1CC, color::medium_violet_red = 0xC71585, color::midnight_blue = 0x191970, color::mint_cream = 0xF5FFFA,
  color::misty_rose = 0xFFE4E1, color::moccasin = 0xFFE4B5, color::navajo_white = 0xFFDEAD, color::navy = 0x000080,
  color::old_lace = 0xFDF5E6, color::olive = 0x808000, color::olive_drab = 0x6B8E23, color::orange = 0xFFA500,
  color::orange_red = 0xFF4500, color::orchid = 0xDA70D6, color::pale_golden_rod = 0xEEE8AA, color::pale_green = 0x98FB98,
  color::pale_turquoise = 0xAFEEEE, color::pale_violet_red = 0xDB7093, color::papaya_whip = 0xFFEFD5, color::peach_puff = 0xFFDAB9,
  color::peru = 0xCD853F, color::pink = 0xFFC0CB, color::plum = 0xDDA0DD, color::powder_blue = 0xB0E0E6,
  color::purple = 0x800080, color::rebecca_purple = 0x663399, color::red = 0xFF0000, color::rosy_brown = 0xBC8F8F,
  color::royal_blue = 0x4169E1, color::saddle_brown = 0x8B4513, color::salmon = 0xFA8072, color::sandy_brown = 0xF4A460,
  color::sea_green = 0x2E8B57, color::sea_shell = 0xFFF5EE, color::sienna = 0xA0522D, color::silver = 0xC0C0C0,
  color::sky_blue = 0x87CEEB, color::slate_blue = 0x6A5ACD, color::slate_gray = 0x708090, color::snow = 0xFFFAFA,
  color::spring_green = 0x00FF7F, color::steel_blue = 0x4682B4, color::tan = 0xD2B48C, color::teal = 0x008080,
  color::thistle = 0xD8BFD8, color::tomato = 0xFF6347, color::turquoise = 0x40E0D0, color::violet = 0xEE82EE,
  color::wheat = 0xF5DEB3, color::white = 0xFFFFFF, color::white_smoke = 0xF5F5F5, color::yellow = 0xFFFF00,
  color::yellow_green = 0x9ACD32
}
 
enum  emphasis : uint8_t {
  emphasis::bold = 1, emphasis::faint = 1 << 1, emphasis::italic = 1 << 2, emphasis::underline = 1 << 3,
  emphasis::blink = 1 << 4, emphasis::reverse = 1 << 5, emphasis::conceal = 1 << 6, emphasis::strikethrough = 1 << 7
}
 
enum  terminal_color : uint8_t {
  terminal_color::black = 30, terminal_color::red, terminal_color::green, terminal_color::yellow,
  terminal_color::blue, terminal_color::magenta, terminal_color::cyan, terminal_color::white,
  terminal_color::bright_black = 90, terminal_color::bright_red, terminal_color::bright_green, terminal_color::bright_yellow,
  terminal_color::bright_blue, terminal_color::bright_magenta, terminal_color::bright_cyan, terminal_color::bright_white
}
 

Functions

FMT_CONSTEXPR auto bg (detail::color_type background) noexcept -> text_style
 
FMT_CONSTEXPR auto fg (detail::color_type foreground) noexcept -> text_style
 
template<typename S , typename... Args, typename Char = char_t<S>>
auto format (const text_style &ts, const S &format_str, const Args &... args) -> std::basic_string< Char >
 
template<typename OutputIt , typename S , typename... Args, bool enable = detail::is_output_iterator<OutputIt, char_t<S>>::value && detail::is_string<S>::value>
auto format_to (OutputIt out, const text_style &ts, const S &format_str, Args &&... args) -> typename std::enable_if< enable, OutputIt >::type
 
template<typename Char >
FMT_CONSTEXPR auto detail::make_background_color (detail::color_type background) noexcept -> ansi_color_escape< Char >
 
template<typename Char >
FMT_CONSTEXPR auto detail::make_emphasis (emphasis em) noexcept -> ansi_color_escape< Char >
 
template<typename Char >
FMT_CONSTEXPR auto detail::make_foreground_color (detail::color_type foreground) noexcept -> ansi_color_escape< Char >
 
FMT_CONSTEXPR auto operator| (emphasis lhs, emphasis rhs) noexcept -> text_style
 
template<typename S , typename... Args, FMT_ENABLE_IF(detail::is_string< S >::value) >
void print (const text_style &ts, const S &format_str, const Args &... args)
 
template<typename S , typename... Args, FMT_ENABLE_IF(detail::is_string< S >::value) >
void print (std::FILE *f, const text_style &ts, const S &format_str, const Args &... args)
 
template<typename Char >
void detail::reset_color (buffer< Char > &buffer)
 
template<typename T >
FMT_CONSTEXPR auto styled (const T &value, text_style ts) -> detail::styled_arg< remove_cvref_t< T >>
 
template<typename S , typename Char = char_t<S>>
auto vformat (const text_style &ts, const S &format_str, basic_format_args< buffer_context< type_identity_t< Char >>> args) -> std::basic_string< Char >
 
template<typename Char >
void detail::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)
 
template<typename OutputIt , typename Char , FMT_ENABLE_IF(detail::is_output_iterator< OutputIt, Char >::value) >
auto vformat_to (OutputIt out, const text_style &ts, basic_string_view< Char > format_str, basic_format_args< buffer_context< type_identity_t< Char >>> args) -> OutputIt
 
void vprint (std::FILE *f, const text_style &ts, string_view fmt, format_args args)
 

Enumeration Type Documentation

◆ color

enum color : uint32_t
strong
Enumerator
alice_blue 
antique_white 
aqua 
aquamarine 
azure 
beige 
bisque 
black 
blanched_almond 
blue 
blue_violet 
brown 
burly_wood 
cadet_blue 
chartreuse 
chocolate 
coral 
cornflower_blue 
cornsilk 
crimson 
cyan 
dark_blue 
dark_cyan 
dark_golden_rod 
dark_gray 
dark_green 
dark_khaki 
dark_magenta 
dark_olive_green 
dark_orange 
dark_orchid 
dark_red 
dark_salmon 
dark_sea_green 
dark_slate_blue 
dark_slate_gray 
dark_turquoise 
dark_violet 
deep_pink 
deep_sky_blue 
dim_gray 
dodger_blue 
fire_brick 
floral_white 
forest_green 
fuchsia 
gainsboro 
ghost_white 
gold 
golden_rod 
gray 
green 
green_yellow 
honey_dew 
hot_pink 
indian_red 
indigo 
ivory 
khaki 
lavender 
lavender_blush 
lawn_green 
lemon_chiffon 
light_blue 
light_coral 
light_cyan 
light_golden_rod_yellow 
light_gray 
light_green 
light_pink 
light_salmon 
light_sea_green 
light_sky_blue 
light_slate_gray 
light_steel_blue 
light_yellow 
lime 
lime_green 
linen 
magenta 
maroon 
medium_aquamarine 
medium_blue 
medium_orchid 
medium_purple 
medium_sea_green 
medium_slate_blue 
medium_spring_green 
medium_turquoise 
medium_violet_red 
midnight_blue 
mint_cream 
misty_rose 
moccasin 
navajo_white 
navy 
old_lace 
olive 
olive_drab 
orange 
orange_red 
orchid 
pale_golden_rod 
pale_green 
pale_turquoise 
pale_violet_red 
papaya_whip 
peach_puff 
peru 
pink 
plum 
powder_blue 
purple 
rebecca_purple 
red 
rosy_brown 
royal_blue 
saddle_brown 
salmon 
sandy_brown 
sea_green 
sea_shell 
sienna 
silver 
sky_blue 
slate_blue 
slate_gray 
snow 
spring_green 
steel_blue 
tan 
teal 
thistle 
tomato 
turquoise 
violet 
wheat 
white 
white_smoke 
yellow 
yellow_green 

Definition at line 16 of file color.h.

◆ emphasis

enum emphasis : uint8_t
strong
Enumerator
bold 
faint 
italic 
underline 
blink 
reverse 
conceal 
strikethrough 

Definition at line 179 of file color.h.

◆ terminal_color

enum terminal_color : uint8_t
strong
Enumerator
black 
red 
green 
yellow 
blue 
magenta 
cyan 
white 
bright_black 
bright_red 
bright_green 
bright_yellow 
bright_blue 
bright_magenta 
bright_cyan 
bright_white 

Definition at line 160 of file color.h.

Function Documentation

◆ bg()

FMT_CONSTEXPR auto bg ( detail::color_type  background) -> text_style
inlinenoexcept

Creates a text style from the background color.

Definition at line 320 of file color.h.

◆ fg()

FMT_CONSTEXPR auto fg ( detail::color_type  foreground) -> text_style
inlinenoexcept

Creates a text style from the foreground (text) color.

Definition at line 314 of file color.h.

◆ format()

template<typename S , typename... Args, typename Char = char_t<S>>
auto format ( const text_style ts,
const S format_str,
const Args &...  args 
) -> std::basic_string<Char>
inline

\rst Formats arguments and returns the result as a string using ANSI escape sequences to specify text formatting.

Example**::

#include <fmt/color.h> std::string message = fmt::format(fmt::emphasis::bold | fg(fmt::color::red), "The answer is {}", 42); \endrst

Definition at line 543 of file color.h.

◆ format_to()

template<typename OutputIt , typename S , typename... Args, bool enable = detail::is_output_iterator<OutputIt, char_t<S>>::value && detail::is_string<S>::value>
auto format_to ( OutputIt  out,
const text_style ts,
const S format_str,
Args &&...  args 
) -> typename std::enable_if<enable, OutputIt>::type
inline

\rst Formats arguments with the given text_style, writes the result to the output iterator out and returns the iterator past the end of the output range.

Example**::

std::vector<char> out; fmt::format_to(std::back_inserter(out), fmt::emphasis::bold | fg(fmt::color::red), "{}", 42); \endrst

Definition at line 579 of file color.h.

◆ operator|()

FMT_CONSTEXPR auto operator| ( emphasis  lhs,
emphasis  rhs 
) -> text_style
inlinenoexcept

Definition at line 325 of file color.h.

◆ print() [1/2]

template<typename S , typename... Args, FMT_ENABLE_IF(detail::is_string< S >::value) >
void print ( const text_style ts,
const S format_str,
const Args &...  args 
)

\rst Formats a string and prints it to stdout using ANSI escape sequences to specify text formatting.

Example**::

fmt::print(fmt::emphasis::bold | fg(fmt::color::red), "Elapsed time: {0:.2f} seconds", 1.23); \endrst

Definition at line 516 of file color.h.

◆ print() [2/2]

template<typename S , typename... Args, FMT_ENABLE_IF(detail::is_string< S >::value) >
void print ( std::FILE *  f,
const text_style ts,
const S format_str,
const Args &...  args 
)

\rst Formats a string and prints it to the specified file stream using ANSI escape sequences to specify text formatting.

Example**::

fmt::print(fmt::emphasis::bold | fg(fmt::color::red), "Elapsed time: {0:.2f} seconds", 1.23); \endrst

Definition at line 497 of file color.h.

◆ styled()

template<typename T >
FMT_CONSTEXPR auto styled ( const T &  value,
text_style  ts 
) -> detail::styled_arg<remove_cvref_t<T>>

\rst Returns an argument that will be formatted using ANSI escape sequences, to be used in a formatting function.

Example**::

fmt::print("Elapsed time: {0:.2f} seconds", fmt::styled(1.23, fmt::fg(fmt::color::green) | fmt::bg(fmt::color::blue))); \endrst

Definition at line 635 of file color.h.

◆ vformat()

template<typename S , typename Char = char_t<S>>
auto vformat ( const text_style ts,
const S format_str,
basic_format_args< buffer_context< type_identity_t< Char >>>  args 
) -> std::basic_string<Char>
inline

Definition at line 521 of file color.h.

◆ vformat_to()

template<typename OutputIt , typename Char , FMT_ENABLE_IF(detail::is_output_iterator< OutputIt, Char >::value) >
auto vformat_to ( OutputIt  out,
const text_style ts,
basic_string_view< Char >  format_str,
basic_format_args< buffer_context< type_identity_t< Char >>>  args 
) -> OutputIt

Formats a string with the given text_style and writes the output to out.

Definition at line 554 of file color.h.

◆ vprint()

void vprint ( std::FILE *  f,
const text_style ts,
string_view  fmt,
format_args  args 
)
inline

Definition at line 469 of file color.h.



plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:49