Sista v3.0.0-alpha.1
Sista is a C++ lightweight OS-agnostic library for terminal animations and videogames
|
Represents a set of ANSI settings including colors and attributes. More...
#include <ansi.hpp>
Public Member Functions | |
ANSISettings () | |
ANSISettings (const RGBColor &, const RGBColor &, const Attribute &) | |
Parameterized constructor with RGBColor for both foreground and background. | |
ANSISettings (const ForegroundColor &, const BackgroundColor &, const Attribute &) | |
Parameterized constructor with ForegroundColor and BackgroundColor enums. | |
ANSISettings (const RGBColor &, const BackgroundColor &, const Attribute &) | |
Parameterized constructor with ForegroundColor enum and RGBColor for background. | |
ANSISettings (const ForegroundColor &, const RGBColor &, const Attribute &) | |
Parameterized constructor with RGBColor for foreground and BackgroundColor enum. | |
ANSISettings (const RGBColor &, const RGBColor &, const std::bitset< 10 > &) | |
Parameterized constructor with RGBColor for both foreground and background, and a bitset for attributes. | |
ANSISettings (const ForegroundColor &, const RGBColor &, const std::bitset< 10 > &) | |
Parameterized constructor with ForegroundColor and RGBColor, and a bitset for attributes. | |
ANSISettings (const RGBColor &, const BackgroundColor &, const std::bitset< 10 > &) | |
Parameterized constructor with RGBColor and BackgroundColor, and a bitset for attributes. | |
ANSISettings (const ForegroundColor &, const BackgroundColor &, std::initializer_list< Attribute >) | |
Parameterized constructor with ForegroundColor and BackgroundColor, and an initializer list for attributes. | |
ANSISettings (const ForegroundColor &, const RGBColor &, std::initializer_list< Attribute >) | |
Parameterized constructor with ForegroundColor and RGBColor, and an initializer list for attributes. | |
ANSISettings (const RGBColor &, const BackgroundColor &, std::initializer_list< Attribute >) | |
Parameterized constructor with RGBColor and BackgroundColor, and an initializer list for attributes. | |
ANSISettings (const ForegroundColor &, const BackgroundColor &, const std::bitset< 10 > &) | |
Parametrized constructor with an initializer for the bitset attribute. | |
ANSISettings (const RGBColor &, const RGBColor &, std::initializer_list< Attribute >) | |
Parametrized constructor with an initializer list for the bitset attribute. | |
ANSISettings (const std::variant< ForegroundColor, RGBColor > &, const std::variant< BackgroundColor, RGBColor > &, const std::variant< Attribute, std::bitset< 10 > > &) | |
Parametrized constructor with all variants. | |
void | apply () const |
Applies the ANSI settings to the terminal. | |
void | reset () const |
Resets all ANSI settings to default values. | |
Public Attributes | |
std::variant< ForegroundColor, RGBColor > | foregroundColor |
Foreground color, can be ForegroundColor or RGBColor. | |
std::variant< BackgroundColor, RGBColor > | backgroundColor |
Background color, can be BackgroundColor or RGBColor. | |
std::variant< Attribute, std::bitset< 10 > > | attribute |
Text attribute setting. | |
Represents a set of ANSI settings including colors and attributes.
This struct holds the foreground color, background color, and text attribute settings for ANSI escape codes. It provides constructors for various combinations of color types (predefined enums and RGB colors) and a method to apply these settings to the terminal.
sista::ANSISettings::ANSISettings | ( | ) |
Default constructor initializing to white foreground, black background, and reset attribute.
sista::ANSISettings::ANSISettings | ( | const ForegroundColor & | foregroundColor_, |
const BackgroundColor & | backgroundColor_, | ||
const Attribute & | attribute_ | ||
) |
Parameterized constructor with ForegroundColor and BackgroundColor enums.
foregroundColor_ | The ForegroundColor for the foreground. |
backgroundColor_ | The BackgroundColor for the background. |
attribute_ | The text Attribute. |
sista::ANSISettings::ANSISettings | ( | const RGBColor & | foregroundColor_, |
const BackgroundColor & | backgroundColor_, | ||
const Attribute & | attribute_ | ||
) |
sista::ANSISettings::ANSISettings | ( | const ForegroundColor & | foregroundColor_, |
const RGBColor & | backgroundColor_, | ||
const Attribute & | attribute_ | ||
) |
sista::ANSISettings::ANSISettings | ( | const ForegroundColor & | foregroundColor_, |
const RGBColor & | backgroundColor_, | ||
const std::bitset< 10 > & | attribute_ | ||
) |
sista::ANSISettings::ANSISettings | ( | const RGBColor & | foregroundColor_, |
const BackgroundColor & | backgroundColor_, | ||
const std::bitset< 10 > & | attribute_ | ||
) |
sista::ANSISettings::ANSISettings | ( | const ForegroundColor & | foregroundColor_, |
const BackgroundColor & | backgroundColor_, | ||
std::initializer_list< Attribute > | attribute_ | ||
) |
Parameterized constructor with ForegroundColor and BackgroundColor, and an initializer list for attributes.
foregroundColor_ | The ForegroundColor for the foreground. |
backgroundColor_ | The BackgroundColor for the background. |
attribute_ | The text attributes as an initializer list. |
sista::ANSISettings::ANSISettings | ( | const ForegroundColor & | foregroundColor_, |
const RGBColor & | backgroundColor_, | ||
std::initializer_list< Attribute > | attribute_ | ||
) |
sista::ANSISettings::ANSISettings | ( | const RGBColor & | foregroundColor_, |
const BackgroundColor & | backgroundColor_, | ||
std::initializer_list< Attribute > | attribute_ | ||
) |
sista::ANSISettings::ANSISettings | ( | const ForegroundColor & | foregroundColor_, |
const BackgroundColor & | backgroundColor_, | ||
const std::bitset< 10 > & | attribute_ | ||
) |
Parametrized constructor with an initializer for the bitset attribute.
foregroundColor_ | The ForegroundColor for the foreground. |
backgroundColor_ | The BackgroundColor for the background. |
attribute_ | The text attributes as a bitset. |
sista::ANSISettings::ANSISettings | ( | const std::variant< ForegroundColor, RGBColor > & | , |
const std::variant< BackgroundColor, RGBColor > & | , | ||
const std::variant< Attribute, std::bitset< 10 > > & | |||
) |
void sista::ANSISettings::apply | ( | ) | const |
Applies the ANSI settings to the terminal.
This method applies the stored foreground color, background color, and text attribute settings to the terminal by calling the appropriate functions to set each property.
The settings will be visible on characters printed after this call.
void sista::ANSISettings::reset | ( | ) | const |
Resets all ANSI settings to default values.
This method resets the terminal's text attributes by disabling the ones that were set in this ANSISettings instance.
It also tries to reset the foreground color to WHITE and the background color to BLACK, which are the defaults.
std::variant<Attribute, std::bitset<10> > sista::ANSISettings::attribute |
Text attribute setting.
This variant holds either a single Attribute enum value or a bitset representing multiple attributes.
The bitset uses the following mapping:
Bit 9: STRIKETHROUGH
Setting a bit to 1 enables the corresponding attribute.
std::variant<BackgroundColor, RGBColor> sista::ANSISettings::backgroundColor |
Background color, can be BackgroundColor or RGBColor.
This variant holds either a predefined BackgroundColor enum value or an RGBColor struct for custom colors.
std::variant<ForegroundColor, RGBColor> sista::ANSISettings::foregroundColor |
Foreground color, can be ForegroundColor or RGBColor.
This variant holds either a predefined ForegroundColor enum value or an RGBColor struct for custom colors.