|
Porytiles
|
Text styling class supporting formatting, foreground colors, and background colors. More...
#include <text_formatter.hpp>
Public Member Functions | |
| constexpr | Style ()=default |
| Default constructor creating a style with no attributes. | |
| constexpr Style | operator| (const Style &other) const |
| Combines two Style values using the | operator. | |
| constexpr bool | has_bold () const |
| Checks if this Style has bold formatting. | |
| constexpr bool | has_faint () const |
| Checks if this Style has faint formatting. | |
| constexpr bool | has_italic () const |
| Checks if this Style has italic formatting. | |
| constexpr bool | has_underline () const |
| Checks if this Style has underline formatting. | |
| constexpr bool | has_blink () const |
| Checks if this Style has blink formatting. | |
| constexpr bool | has_fg_color () const |
| Checks if this Style has a foreground color set. | |
| constexpr bool | has_bg_color () const |
| Checks if this Style has a background color set. | |
| constexpr bool | is_fg_rgb () const |
| Checks if the foreground color is in RGB mode. | |
| constexpr bool | is_bg_rgb () const |
| Checks if the background color is in RGB mode. | |
| constexpr RgbColor | fg_rgb () const |
| Returns the foreground RGB color. | |
| constexpr RgbColor | bg_rgb () const |
| Returns the background RGB color. | |
| constexpr PredefinedColor | fg_predefined () const |
| Returns the predefined foreground color. | |
| constexpr PredefinedColor | bg_predefined () const |
| Returns the predefined background color. | |
Static Public Attributes | |
| static const Style | none {} |
| No styling applied. | |
| static const Style | bold {Style::FormatFlagTag::bold} |
| Bold text formatting. | |
| static const Style | faint {Style::FormatFlagTag::faint} |
| Faint text formatting. | |
| static const Style | italic {Style::FormatFlagTag::italic} |
| Italic text formatting. | |
| static const Style | underline {Style::FormatFlagTag::underline} |
| Underline text formatting. | |
| static const Style | blink {Style::FormatFlagTag::blink} |
| Blink text formatting. | |
| static const Style | black {Style::FgColorTag::predefined, PredefinedColor::black} |
| Black foreground color. | |
| static const Style | red {Style::FgColorTag::predefined, PredefinedColor::red} |
| Red foreground color. | |
| static const Style | green {Style::FgColorTag::predefined, PredefinedColor::green} |
| Green foreground color. | |
| static const Style | yellow {Style::FgColorTag::predefined, PredefinedColor::yellow} |
| Yellow foreground color. | |
| static const Style | blue {Style::FgColorTag::predefined, PredefinedColor::blue} |
| Blue foreground color. | |
| static const Style | magenta {Style::FgColorTag::predefined, PredefinedColor::magenta} |
| Magenta foreground color. | |
| static const Style | cyan {Style::FgColorTag::predefined, PredefinedColor::cyan} |
| Cyan foreground color. | |
| static const Style | white {Style::FgColorTag::predefined, PredefinedColor::white} |
| White foreground color. | |
| static const Style | bg_black {Style::BgColorTag::predefined, PredefinedColor::black} |
| Black background color. | |
| static const Style | bg_red {Style::BgColorTag::predefined, PredefinedColor::red} |
| Red background color. | |
| static const Style | bg_green {Style::BgColorTag::predefined, PredefinedColor::green} |
| Green background color. | |
| static const Style | bg_yellow {Style::BgColorTag::predefined, PredefinedColor::yellow} |
| Yellow background color. | |
| static const Style | bg_blue {Style::BgColorTag::predefined, PredefinedColor::blue} |
| Blue background color. | |
| static const Style | bg_magenta {Style::BgColorTag::predefined, PredefinedColor::magenta} |
| Magenta background color. | |
| static const Style | bg_cyan {Style::BgColorTag::predefined, PredefinedColor::cyan} |
| Cyan background color. | |
| static const Style | bg_white {Style::BgColorTag::predefined, PredefinedColor::white} |
| White background color. | |
Friends | |
| constexpr Style | rgb_fg_style (std::uint8_t r, std::uint8_t g, std::uint8_t b) |
| Creates a Style value with a custom RGB foreground color. | |
| constexpr Style | rgb_bg_style (std::uint8_t r, std::uint8_t g, std::uint8_t b) |
| Creates a Style value with a custom RGB background color. | |
Text styling class supporting formatting, foreground colors, and background colors.
Style is a class that allows multiple styling attributes to be combined using the | operator. It supports:
Styles can be combined using the | operator to apply multiple attributes simultaneously:
The class maintains backward compatibility with the previous enum-based API while providing more flexibility for combining foreground and background colors.
Definition at line 66 of file text_formatter.hpp.
|
constexprdefault |
Default constructor creating a style with no attributes.
|
inlineconstexpr |
Returns the predefined background color.
Definition at line 276 of file text_formatter.hpp.
|
inlineconstexpr |
Returns the background RGB color.
Definition at line 254 of file text_formatter.hpp.
|
inlineconstexpr |
Returns the predefined foreground color.
Definition at line 265 of file text_formatter.hpp.
|
inlineconstexpr |
Returns the foreground RGB color.
Definition at line 243 of file text_formatter.hpp.
|
inlineconstexpr |
Checks if this Style has a background color set.
Definition at line 212 of file text_formatter.hpp.
|
inlineconstexpr |
Checks if this Style has blink formatting.
Definition at line 192 of file text_formatter.hpp.
|
inlineconstexpr |
Checks if this Style has bold formatting.
Definition at line 152 of file text_formatter.hpp.
|
inlineconstexpr |
Checks if this Style has faint formatting.
Definition at line 162 of file text_formatter.hpp.
|
inlineconstexpr |
Checks if this Style has a foreground color set.
Definition at line 202 of file text_formatter.hpp.
|
inlineconstexpr |
Checks if this Style has italic formatting.
Definition at line 172 of file text_formatter.hpp.
|
inlineconstexpr |
Checks if this Style has underline formatting.
Definition at line 182 of file text_formatter.hpp.
|
inlineconstexpr |
Checks if the background color is in RGB mode.
Definition at line 232 of file text_formatter.hpp.
|
inlineconstexpr |
Checks if the foreground color is in RGB mode.
Definition at line 222 of file text_formatter.hpp.
Combines two Style values using the | operator.
Merges styling attributes from two Style values:
| other | The Style value to combine with |
Definition at line 113 of file text_formatter.hpp.
|
friend |
Creates a Style value with a custom RGB background color.
Constructs a Style value with an RGB background color using the provided red, green, and blue channel values. The resulting Style can be combined with formatting flags and foreground colors using the | operator:
| r | Red channel value (0-255) |
| g | Green channel value (0-255) |
| b | Blue channel value (0-255) |
Definition at line 380 of file text_formatter.hpp.
|
friend |
Creates a Style value with a custom RGB foreground color.
Constructs a Style value with an RGB foreground color using the provided red, green, and blue channel values. The resulting Style can be combined with formatting flags and background colors using the | operator:
| r | Red channel value (0-255) |
| g | Green channel value (0-255) |
| b | Blue channel value (0-255) |
Definition at line 359 of file text_formatter.hpp.
|
static |
Black background color.
Definition at line 87 of file text_formatter.hpp.
|
static |
Blue background color.
Definition at line 91 of file text_formatter.hpp.
|
static |
Cyan background color.
Definition at line 93 of file text_formatter.hpp.
|
static |
Green background color.
Definition at line 89 of file text_formatter.hpp.
|
static |
Magenta background color.
Definition at line 92 of file text_formatter.hpp.
|
static |
Red background color.
Definition at line 88 of file text_formatter.hpp.
|
static |
White background color.
Definition at line 94 of file text_formatter.hpp.
|
static |
Yellow background color.
Definition at line 90 of file text_formatter.hpp.
|
static |
Black foreground color.
Definition at line 77 of file text_formatter.hpp.
|
static |
Blink text formatting.
Definition at line 74 of file text_formatter.hpp.
|
static |
Blue foreground color.
Definition at line 81 of file text_formatter.hpp.
|
static |
Bold text formatting.
Definition at line 70 of file text_formatter.hpp.
|
static |
Cyan foreground color.
Definition at line 83 of file text_formatter.hpp.
|
static |
Faint text formatting.
Definition at line 71 of file text_formatter.hpp.
|
static |
Green foreground color.
Definition at line 79 of file text_formatter.hpp.
|
static |
Italic text formatting.
Definition at line 72 of file text_formatter.hpp.
|
static |
Magenta foreground color.
Definition at line 82 of file text_formatter.hpp.
|
static |
No styling applied.
Definition at line 69 of file text_formatter.hpp.
|
static |
Red foreground color.
Definition at line 78 of file text_formatter.hpp.
|
static |
Underline text formatting.
Definition at line 73 of file text_formatter.hpp.
|
static |
White foreground color.
Definition at line 84 of file text_formatter.hpp.
|
static |
Yellow foreground color.
Definition at line 80 of file text_formatter.hpp.