87#define HIDE_CURSOR "\x1b[?25l"
98#define SHOW_CURSOR "\x1b[?25h"
182 std::bitset<10> bits;
183 for (
auto attr : attrs) {
184 bits.set(
static_cast<int>(attr));
208 RGBColor(
unsigned char,
unsigned char,
unsigned char);
401 std::string
fgColorStr(
unsigned char,
unsigned char,
unsigned char);
414 std::string
bgColorStr(
unsigned char,
unsigned char,
unsigned char);
598 const std::variant<BackgroundColor, RGBColor>&,
599 const std::variant<
Attribute, std::bitset<10>>&);
Sista library namespace.
Definition: ansi.cpp:26
void resetAnsi()
Resets all ANSI settings to default values.
Definition: ansi.cpp:47
void resetAttribute(Attribute attribute)
Resets a text attribute using a predefined Attribute enum.
Definition: ansi.cpp:39
std::bitset< 10 > make_attr_bitset(std::initializer_list< Attribute > attrs)
Helper function to create a bitset from an initializer list of Attributes.
Definition: ansi.hpp:181
Attribute
Enumeration of text attributes for ANSI escape codes.
Definition: ansi.hpp:159
std::string attrStr(Attribute attribute)
Converts an Attribute enum to its corresponding ANSI escape code string.
Definition: ansi.cpp:82
ForegroundColor
Enumeration of foreground colors for ANSI escape codes.
Definition: ansi.hpp:122
ScreenMode
Represents various ANSI screen modes.
Definition: ansi.hpp:424
@ COLOR_16_COLORS_GRAPHICS_640_350
@ COLOR_16_COLORS_GRAPHICS_640_480
@ MONOCROME_GRAPHICS_640_200
@ MONOCROME_GRAPHICS_320_200
@ MONOCROME_2_COLORS_GRAPHICS_640_480
@ MONOCROME_2_COLORS_GRAPHICS_640_350
@ COLOR_256_COLORS_GRAPHICS_320_200
@ FOUR_COLORS_GRAPHICS_320_200
@ COLOR_16_COLORS_GRAPHICS_640_200
std::string bgColorStr(BackgroundColor color)
Converts a BackgroundColor enum to its corresponding ANSI escape code string.
Definition: ansi.cpp:79
void unsetScreenMode(ScreenMode mode)
Unsets a specific screen mode.
Definition: ansi.cpp:117
void setBackgroundColor(BackgroundColor color)
Sets the background color using a predefined BackgroundColor enum.
Definition: ansi.cpp:33
std::string fgColorStr(ForegroundColor color)
Converts a ForegroundColor enum to its corresponding ANSI escape code string.
Definition: ansi.cpp:76
void setForegroundColor(ForegroundColor color)
Sets the foreground color using a predefined ForegroundColor enum.
Definition: ansi.cpp:30
BackgroundColor
Enumeration of background colors for ANSI escape codes.
Definition: ansi.hpp:140
void setScreenMode(ScreenMode mode)
Sets a specific screen mode.
Definition: ansi.cpp:114
void setAttribute(Attribute attribute)
Sets a text attribute using a predefined Attribute enum.
Definition: ansi.cpp:36
Represents a set of ANSI settings including colors and attributes.
Definition: ansi.hpp:471
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.
Definition: ansi.cpp:151
std::variant< ForegroundColor, RGBColor > foregroundColor
Foreground color, can be ForegroundColor or RGBColor.
Definition: ansi.hpp:481
std::variant< BackgroundColor, RGBColor > backgroundColor
Background color, can be BackgroundColor or RGBColor.
Definition: ansi.hpp:491
ANSISettings()
Definition: ansi.cpp:121
void reset() const
Resets all ANSI settings to default values.
Definition: ansi.cpp:174
std::variant< Attribute, std::bitset< 10 > > attribute
Text attribute setting.
Definition: ansi.hpp:516
Represents an RGB color with red, green, and blue components in True Color (24-bit).
Definition: ansi.hpp:196
unsigned char green
Definition: ansi.hpp:198
RGBColor()
Default constructor initializing color to black (0,0,0).
Definition: ansi.cpp:27
unsigned char red
Definition: ansi.hpp:197
unsigned char blue
Definition: ansi.hpp:199