1#ifndef __CPP_CONSOLE_COLOR_HPP__
2#define __CPP_CONSOLE_COLOR_HPP__
21 return "\033[" + std::to_string(color) +
"m" + str +
"\033[0m";
36std::string
colorize(
const std::string& str,
unsigned char color,
37 bool foreground =
true) {
39 return "\033[" + std::to_string(foreground ? 38 : 48) +
";5;" +
40 std::to_string(color) +
"m" + str +
"\033[0m";
54std::string
colorize(
const std::string& str,
unsigned char r,
unsigned char g,
55 unsigned char b,
bool foreground =
true) {
57 return "\033[" + std::to_string(foreground ? 38 : 48) +
";2;" +
58 std::to_string(r) +
";" + std::to_string(g) +
";" +
59 std::to_string(b) +
"m" + str +
"\033[0m";
69 if (
isANSIEnabled()) std::cout <<
"\033[" << std::to_string(color) <<
"m";
83void setColor(
unsigned char color,
bool foreground =
true) {
85 std::cout <<
"\033[" << (foreground ?
"38" :
"48") <<
";5;"
86 << std::to_string(color) <<
"m";
96void setColor(
unsigned char r,
unsigned char g,
unsigned char b,
97 bool foreground =
true) {
99 std::cout <<
"\033[" << (foreground ?
"38" :
"48") <<
";2;"
100 << std::to_string(r) <<
";" << std::to_string(g) <<
";"
101 << std::to_string(b) <<
"m";
Namespace Containing all console commands.
Definition ansi.hpp:16
Graphics
Enumeration of builtin colors for ANSI escape codes, along with other graphics modes.
Definition graphics.hpp:19
void setColor(Graphics color)
Sets the color of the text to a predefined color.
Definition color.hpp:68
bool isANSIEnabled()
Checks if ANSI Codes are enable in windows.
Definition ansi.hpp:22
std::string colorize(const std::string &str, Graphics color)
Colors the text color to a predefined color.
Definition color.hpp:19