fmt
Loading...
Searching...
No Matches
fmt::TextStyle Class Referenceexport
module fmt

Public Member Functions

constexpr TextStyle (Emphasis em=Emphasis()) noexcept
constexpr auto operator|= (TextStyle rhs) -> TextStyle &
constexpr auto operator== (TextStyle rhs) const noexcept -> bool
constexpr auto operator!= (TextStyle rhs) const noexcept -> bool
constexpr auto hasForeground () const noexcept -> bool
constexpr auto hasBackground () const noexcept -> bool
constexpr auto hasEmphasis () const noexcept -> bool
constexpr auto getForeground () const noexcept -> detail::ColorType
constexpr auto getBackground () const noexcept -> detail::ColorType
constexpr auto getEmphasis () const noexcept -> Emphasis

Friends

constexpr auto operator| (TextStyle lhs, TextStyle rhs) -> TextStyle
constexpr auto fg (detail::ColorType foreground) -> TextStyle
constexpr auto bg (detail::ColorType background) -> TextStyle

Detailed Description

A text style: a foreground colour, a background colour and emphases.

Built with fg, bg and the emphasis enumerators, combined with |:

auto style = fmt::fg(fmt::color::kRed) | fmt::emphasis::kBold;

Combining two styles that both set the same colour slot is an error, since the result would be ambiguous.

Exceptions
std::invalid_argumentif | would combine two terminal colours, or a terminal colour with an RGB colour, for the same slot.

◆ bg

auto bg ( detail::ColorType background) -> TextStyle
friend

Creates a style that sets the background colour.

Parameters
backgrounda color, terminal_color or rgb.
Returns
a style that can be combined with others using |.
See also
fg

◆ fg

auto fg ( detail::ColorType foreground) -> TextStyle
friend

Creates a style that sets the foreground, that is the text, colour.

Parameters
foregrounda color, terminal_color or rgb.
Returns
a style that can be combined with others using |.

Example:

auto style = fmt::fg(fmt::color::kRed) | fmt::emphasis::kBold;
See also
bg

The documentation for this class was generated from the following file:
  • /home/mccakit/desktop/mccakit-fmt/fmt/src/fmt/iface/color.cppm