Skip to content

A header-only library that can make your life much easier with color formatting.

License

Notifications You must be signed in to change notification settings

AlienTheBetrayer/ColorFormatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Color formatter

About

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.

How to use

Variable formatting

To use variable formatting you simply put %v at the place where you want to insert the variable. Supports most types.

Color formatting

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.

Features

Color formatter library currently supports these functions:

console::colorset

Sets current console color to the specified color.

void console::colorset(int color);

console::colorwrite

Writes a string to a console with specified color.

void console::colorwrite(int color, std::string str);

console::colorformat

Formats a message with optional colors.

void console::colorformat(std::string str, vars...);

Colors map

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

Examples

a + b = c

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);

Warn

console::colorformat("{color:orange=[WARN]} %v\n", "warn message here...");

Hello, world!

console::colorformat("{color:pink=Hello}, {color:cyan=world}!\n");

Number Pi

console::colorformat("Pi: {color:light_red=%v}\n", 3.141593f);

About

A header-only library that can make your life much easier with color formatting.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages