This library allows you to easily format your strings in two ways:
- Variable formatting
- Color formatting
Variable formatting allows you to insert your variables inside a string, and color formatting allows you to change the color of the outputted message.
To use variable formatting you simply put %v at the place where you want to insert the variable. Supports most types.
To use color formatting inside your string you do {color:desired_color=text}, you can also insert %v there. Everything else besides these {...} will get gray color.
Color formatter library currently supports these functions:
Sets current console color to the specified color.
void console::colorset(int color);
Writes a string to a console with specified color.
void console::colorwrite(int color, std::string str);
Formats a message with optional colors.
void console::colorformat(std::string str, vars...);
You can see and use each and every available colors in the colors map. To get an integer corresponding to that color:
int color = console::colors["purple"]; // 5
int a = 10, b = 20, c = a + b;
console::colorformat("{color:light_blue=%v} + {color:light_blue=%v} = {color:light_green=%v}\n", a, b, c);
console::colorformat("{color:orange=[WARN]} %v\n", "warn message here...");
console::colorformat("{color:pink=Hello}, {color:cyan=world}!\n");
console::colorformat("Pi: {color:light_red=%v}\n", 3.141593f);