Textformatpp is a lightweight C++ library to write colored and formated code onto the linux terminal/cli.
It has intentionally no class overhead to keep it as lightweight as possible and it is only capsuled into the 'text' namespaces.
I was inspired by this stackoverflow post to make a good color/simple format library for C++ error and test messages on linux terminal.
- Coloring text (black, red, green, yellow, blue, magenta, cyan, white)
- foreground and background support
- bold, underline and inverse text
- multiline support
- Copy the source and header file from /src into your project and import the header.
test.cpp is a reference how it works and can compiled and run with the Makefile
make run
The library is capsuled at the namespace text. I don't recommend to use the using
text;
statement.
Below are also some examples:
std::cout << text::green("Hello World!") << std::endl; // green text at console output
std::cout << text::green("Multi line Example", true) << std::endl; // enables multiline support
std::cout << "Test" << std::endl; // green text
std::cout << "Hello" << text::disable_multiline() << std::endl; // green text, disables multiline
std::cout << "Normal" << std::endl; // normal console output (not green);
std::cout << text::bold(text::underline(text::red)) << std::endl; // bold and green
- port to other languages when finished
If some errors appears please write a issue that I can fix it.
MIT