termstyle 1.0.0-pre.3
An open-source C++ header file that enables developers to easily define and apply customizable style presets for terminal outputs such as warnings, infos, and errors.
Loading...
Searching...
No Matches
termstyle Namespace Reference

Namespace for the termstyle library. More...

Classes

struct  Col256
 Struct for storing 256-color codes. More...
 
struct  Color
 Struct for storing different types of colors. More...
 
struct  ColRGB
 Struct for storing RGB color codes. More...
 
struct  Config
 Configuration namespace. More...
 
class  OnExit
 The OnExit class is a helper class that performs an action when it goes out of scope. More...
 
struct  PresetConfig
 Struct for storing preset configurations. More...
 
class  StyledCout
 A class that provides styled output to the standard output stream. More...
 
struct  StyleString
 Struct for storing styled strings. More...
 

Enumerations

enum class  Codes : int {
  RESTORE = 0 , BRIGHT = 1 , DIM = 2 , ITALIC = 3 ,
  UNDERLINE = 4 , FLASH = 5 , REVERSE = 7 , HIDDEN = 8 ,
  STRIKE = 9 , BRIGHT_RESET = 22 , DIM_RESET = 22 , ITALIC_RESET = 23 ,
  UNDERLINE_RESET = 24 , FLASH_RESET = 25 , REVERSE_RESET = 27 , HIDDEN_RESET = 28 ,
  STRIKE_RESET = 29 , FOREGROUND_BLACK = 30 , FOREGROUND_RED = 31 , FOREGROUND_GREEN = 32 ,
  FOREGROUND_YELLOW = 33 , FOREGROUND_BLUE = 34 , FOREGROUND_PURPLE = 35 , FOREGROUND_CYAN = 36 ,
  FOREGROUND_WHITE = 37 , FOREGROUND_RESET = 39 , BACKGROUND_BLACK = 40 , BACKGROUND_RED = 41 ,
  BACKGROUND_GREEN = 42 , BACKGROUND_YELLOW = 43 , BACKGROUND_BLUE = 44 , BACKGROUND_PURPLE = 45 ,
  BACKGROUND_CYAN = 46 , BACKGROUND_WHITE = 47 , BACKGROUND_RESET = 49
}
 Enum class for ANSI escape codes.
 
enum class  ColorMode : int { FOREGROUND = 38 , BACKGROUND = 48 }
 Enum class for color modes.
 
enum class  ColorType : int { COL16 = 0 , COL256 = 1 , COLRGB = 2 }
 Enum class for color types.
 
enum class  ParseMode : int { ALL = 0 , PREFIX = 1 , SUFFIX = 2 }
 Enum class for parse modes.
 

Functions

template<typename T >
std::string code2string (const std::vector< T > &codelist) noexcept
 
std::string code2string (const Codes &col)
 
bool validateColorID (int ID)
 Validates a color 256 ID.
 
std::string col256_2string (std::vector< Col256 > codelist) noexcept
 
std::string col256_2string (const Col256 &col) noexcept
 
std::string colrgb_2string (const ColRGB &col) noexcept
 
std::string parseColortype (std::vector< Color > codelist) noexcept
 
std::string parse (const PresetConfig &preset, ParseMode mode=ParseMode::ALL) noexcept
 
void addPreset (std::string name, PresetConfig preset)
 Adds a preset with the given name and configuration.
 
void print (std::string preset, std::string text="")
 
StyledCout style (const std::string &preset)
 

Variables

std::map< std::string, PresetConfigpresets = {}
 A map that stores preset configurations.
 
OnExit onExitInstance
 

Detailed Description

Namespace for the termstyle library.

Function Documentation

◆ parse()

std::string termstyle::parse ( const PresetConfig & preset,
ParseMode mode = ParseMode::ALL )
noexcept

Parses the given preset configuration using the specified mode.

Parameters
presetThe preset configuration to parse.
modeThe parse mode to use (default: ParseMode::ALL).
Returns
A string representing the parsed configuration.

◆ parseColortype()

std::string termstyle::parseColortype ( std::vector< Color > codelist)
noexcept

Parses a list of colors and returns a string representing the color type.

Parameters
codelistThe list of colors to be parsed.
Returns
A string representing the color type.

Variable Documentation

◆ presets

std::map<std::string, PresetConfig> termstyle::presets = {}

A map that stores preset configurations.

This map is used to store preset configurations for termstyle. The keys are strings representing the names of the presets, and the values are instances of the PresetConfig class.