Skip to content

[Lib][Functional][Stable] A minimal C++11 header-only file for adding colors to your std::cout functions

License

Notifications You must be signed in to change notification settings

Lecrapouille/TerminalColor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TerminalColor

A single C++11 header-only file for adding colors to your std::cout function. This project has been inspired by https://github.com/agauniyal/rang and agauniyal/rang#103

Example

#define WARNING_COLOR   termcolor::color(termcolor::style::bold, termcolor::fg::red)
#define ERROR_COLOR     termcolor::color(termcolor::style::bold, termcolor::fg::green)
#define DEFAULT_COLOR   termcolor::color()

termcolor::enable();
std::cout << WARNING_COLOR << "- Warning\n"
          << ERROR_COLOR << "+ Error"
          << DEFAULT_COLOR << std::endl;

termcolor::disable();
std::cout << WARNING_COLOR << "- Warning\n"
          << ERROR_COLOR << "+ Error"
          << DEFAULT_COLOR << std::endl;

Will produce something like this in your console:

- Warning
+ Error
- Warning
+ Error

If you want to ignore color requests call termcolor::disable(); To enable color back: termcolor::enable();. For more examples see the unit-test file.

Project using this library

https://github.com/Lecrapouille/SimForth

alt tag

About

[Lib][Functional][Stable] A minimal C++11 header-only file for adding colors to your std::cout functions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages