Sista v3.0.0-alpha.1
Sista is a C++ lightweight OS-agnostic library for terminal animations and videogames
Loading...
Searching...
No Matches
Namespaces | Functions
ansi.cpp File Reference

Implementation of ANSI functions and classes. More...

#include "ansi.hpp"
#include <iostream>
#include <sstream>
Include dependency graph for ansi.cpp:

Namespaces

namespace  sista
 Sista library namespace.
 

Functions

void sista::setForegroundColor (ForegroundColor)
 Sets the foreground color using a predefined ForegroundColor enum.
 
void sista::setBackgroundColor (BackgroundColor)
 Sets the background color using a predefined BackgroundColor enum.
 
void sista::setAttribute (Attribute)
 Sets a text attribute using a predefined Attribute enum.
 
void sista::resetAttribute (Attribute)
 Resets a text attribute using a predefined Attribute enum.
 
void sista::resetAnsi ()
 Resets all ANSI settings to default values.
 
void sista::setForegroundColor (const RGBColor &)
 Sets the foreground color using an RGBColor struct.
 
void sista::setBackgroundColor (const RGBColor &)
 Sets the background color using an RGBColor struct.
 
void sista::setForegroundColor (unsigned char, unsigned char, unsigned char)
 Sets the foreground color using RGB values.
 
void sista::setBackgroundColor (unsigned char, unsigned char, unsigned char)
 Sets the background color using RGB values.
 
void sista::setForegroundColor (unsigned char)
 Sets the foreground color using a 256-color palette index.
 
void sista::setBackgroundColor (unsigned char)
 Sets the background color using a 256-color palette index.
 
std::string sista::fgColorStr (ForegroundColor)
 Converts a ForegroundColor enum to its corresponding ANSI escape code string.
 
std::string sista::bgColorStr (BackgroundColor)
 Converts a BackgroundColor enum to its corresponding ANSI escape code string.
 
std::string sista::attrStr (Attribute)
 Converts an Attribute enum to its corresponding ANSI escape code string.
 
std::string sista::fgColorStr (const RGBColor &)
 Converts an RGBColor struct to its corresponding ANSI escape code string for foreground color.
 
std::string sista::bgColorStr (const RGBColor &)
 Converts RGB values to their corresponding ANSI escape code string for foreground color.
 
std::string sista::fgColorStr (unsigned char, unsigned char, unsigned char)
 Converts RGB values to their corresponding ANSI escape code string for foreground color.
 
std::string sista::bgColorStr (unsigned char, unsigned char, unsigned char)
 Converts RGB values to their corresponding ANSI escape code string for background color.
 
void sista::setScreenMode (ScreenMode)
 Sets a specific screen mode.
 
void sista::unsetScreenMode (ScreenMode)
 Unsets a specific screen mode.
 

Detailed Description

Implementation of ANSI functions and classes.

This file contains the implementation of functions and classes for handling ANSI escape codes, including setting foreground and background colors, text attributes, and screen modes.

The implementation includes support for both standard colors and RGB colors, as well as managing ANSI settings through the ANSISettings class.

The code is designed to work with C++17 and later standards.

Author
FLAK-ZOSO
Date
2022-2025
Version
3.0.0
Note
Many niche features are not implemented, see references for more details.
Not all terminals support all ANSI features.
See also
https://en.wikipedia.org/wiki/ANSI_escape_code
https://gist.github.com/ConnerWill/d4b6c776b509add763e17f9f113fd25b