Specs
Beautiful C++ Test Framework
Loading...
Searching...
No Matches
SpecsCpp::Colors Namespace Reference

Namespaces

namespace  Unix
 

Enumerations

enum class  Color {
  None = 0 , Black = 30 , Red = 31 , Green = 32 ,
  Yellow = 33 , Blue = 34 , Purple = 35 , Cyan = 36 ,
  LightGray = 37 , DarkGray = 90 , LightRed = 91 , LightGreen = 92 ,
  LightYellow = 93 , LightBlue = 94 , LightPurple = 95 , LightCyan = 96 ,
  White = 97
}
 

Functions

void PrintColor (std::string_view text, Color foreground=Color::None, Color background=Color::None, Unix::Style style=Unix::Style::Normal)
 

Enumeration Type Documentation

◆ Color

enum class SpecsCpp::Colors::Color
strong
Enumerator
None 
Black 
Red 
Green 
Yellow 
Blue 
Purple 
Cyan 
LightGray 
DarkGray 
LightRed 
LightGreen 
LightYellow 
LightBlue 
LightPurple 
LightCyan 
White 

Definition at line 13 of file PrintColor.h.

Function Documentation

◆ PrintColor()

void SpecsCpp::Colors::PrintColor ( std::string_view  text,
Color  foreground = Color::None,
Color  background = Color::None,
Unix::Style  style = Unix::Style::Normal 
)
inline

Definition at line 86 of file PrintColor.h.

89 {
90 using namespace Unix;
91
92 std::string output = "\033[";
93
94 if (style != Style::Normal) output += std::to_string(static_cast<std::uint8_t>(style));
95
96 if (foreground != Color::None) {
97 if (style != Style::Normal) output += ";";
98 output += std::to_string(static_cast<std::uint8_t>(foreground));
99 }
100
101 if (background != Color::None) {
102 if (style != Style::Normal || foreground != Color::None) output += ";";
103 output += std::to_string(static_cast<std::uint8_t>(background));
104 }
105
106 output += string_format("m{}\033[0m", text);
107
108 std::cout << output;
109 }