spdlog
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions
color.h File Reference

Go to the source code of this file.

#include "format.h"

Classes

struct  rgb
 
struct  color_type
 
union  color_type::color_union
 
class  text_style
 
struct  ansi_color_escape< Char >
 

Macros

#define FMT_DEPRECATED_NONMSVC   FMT_DEPRECATED
 

Enumerations

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

Functions

FMT_CONSTEXPR text_style fg (detail::color_type foreground) FMT_NOEXCEPT
 
FMT_CONSTEXPR text_style bg (detail::color_type background) FMT_NOEXCEPT
 
FMT_CONSTEXPR text_style operator| (emphasis lhs, emphasis rhs) FMT_NOEXCEPT
 
template<typename Char >
FMT_CONSTEXPR ansi_color_escape< Char > make_foreground_color (detail::color_type foreground) FMT_NOEXCEPT
 
template<typename Char >
FMT_CONSTEXPR ansi_color_escape< Char > make_background_color (detail::color_type background) FMT_NOEXCEPT
 
template<typename Char >
FMT_CONSTEXPR ansi_color_escape< Char > make_emphasis (emphasis em) FMT_NOEXCEPT
 
template<typename Char >
void fputs (const Char *chars, FILE *stream) FMT_NOEXCEPT
 
template<>
void fputs< wchar_t > (const wchar_t *chars, FILE *stream) FMT_NOEXCEPT
 
template<typename Char >
void reset_color (FILE *stream) FMT_NOEXCEPT
 
template<>
void reset_color< wchar_t > (FILE *stream) FMT_NOEXCEPT
 
template<typename Char >
void reset_color (buffer< Char > &buffer) FMT_NOEXCEPT
 
template<typename Char >
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)
 
template<typename S , typename Char = char_t<S>>
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)
 
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 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 Char = char_t<S>>
std::basic_string< Char > vformat (const text_style &ts, const S &format_str, basic_format_args< buffer_context< type_identity_t< Char > > > args)
 
template<typename S , typename... Args, typename Char = char_t<S>>
std::basic_string< Char > format (const text_style &ts, const S &format_str, const Args &... args)
 
template<typename OutputIt , typename Char , FMT_ENABLE_IF(detail::is_output_iterator< OutputIt, Char >::value) >
OutputIt vformat_to (OutputIt out, const text_style &ts, basic_string_view< Char > format_str, basic_format_args< buffer_context< type_identity_t< Char > > > args)
 
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
 

Macro Definition Documentation

◆ FMT_DEPRECATED_NONMSVC

#define FMT_DEPRECATED_NONMSVC   FMT_DEPRECATED

Definition at line 17 of file color.h.

Enumeration Type Documentation

◆ color

enum class 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 23 of file color.h.

◆ emphasis

enum class emphasis : uint8_t
strong
Enumerator
bold 
italic 
underline 
strikethrough 

Definition at line 186 of file color.h.

◆ terminal_color

enum class 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 167 of file color.h.

Function Documentation

◆ bg()

FMT_CONSTEXPR text_style bg ( detail::color_type  background)
inline

Creates a text style from the background color.

Definition at line 363 of file color.h.

◆ fg()

FMT_CONSTEXPR text_style fg ( detail::color_type  foreground)
inline

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

Definition at line 358 of file color.h.

◆ format()

template<typename S , typename... Args, typename Char = char_t<S>>
std::basic_string< Char > format ( const text_style ts,
const S &  format_str,
const Args &...  args 
)
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 583 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 617 of file color.h.

◆ fputs()

template<typename Char >
void fputs ( const Char *  chars,
FILE *  stream 
)
inline

Definition at line 467 of file color.h.

◆ fputs< wchar_t >()

template<>
void fputs< wchar_t > ( const wchar_t chars,
FILE *  stream 
)
inline

Definition at line 472 of file color.h.

◆ make_background_color()

template<typename Char >
FMT_CONSTEXPR ansi_color_escape< Char > make_background_color ( detail::color_type  background)

Definition at line 456 of file color.h.

◆ make_emphasis()

template<typename Char >
FMT_CONSTEXPR ansi_color_escape< Char > make_emphasis ( emphasis  em)

Definition at line 462 of file color.h.

◆ make_foreground_color()

template<typename Char >
FMT_CONSTEXPR ansi_color_escape< Char > make_foreground_color ( detail::color_type  foreground)

Definition at line 450 of file color.h.

◆ operator|()

FMT_CONSTEXPR text_style operator| ( emphasis  lhs,
emphasis  rhs 
)
inline

Definition at line 367 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 557 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 538 of file color.h.

◆ reset_color() [1/2]

template<typename Char >
void reset_color ( buffer< Char > &  buffer)
inline

Definition at line 485 of file color.h.

◆ reset_color() [2/2]

template<typename Char >
void reset_color ( FILE *  stream)
inline

Definition at line 476 of file color.h.

◆ reset_color< wchar_t >()

template<>
void reset_color< wchar_t > ( FILE *  stream)
inline

Definition at line 480 of file color.h.

◆ vformat()

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

Definition at line 562 of file color.h.

◆ vformat_to() [1/2]

template<typename Char >
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 at line 491 of file color.h.

◆ vformat_to() [2/2]

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

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

Definition at line 594 of file color.h.

◆ vprint()

template<typename S , typename Char = char_t<S>>
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 at line 517 of file color.h.