A Header only Lib to change the text Foreground and Background. Made using Windows API for Windows OS and ANSI Escape Codes for Linux OS.
It's for C++ only. You can easily modify it use it for C.
- Download this
Terlor.hpp
file and add it to your working directory. #include "Terlor.hpp"
into a translation unit.
Like this on WINDOWS :
#include <iostream>
#include "Terlor.hpp"
int main()
{
// Change text Foreground
arc::setTextColor(Color::GREEN);
std::cout << "Colored text\n";
arc::resetColor();
// To change Text Background
arc::setTextColor(BG::WHITE);
std::cout<<"WHITE BG\n";
arc::resetColor();
}
There's so much Color to Select From. See after using the Scope resolution operator Color::
,BG::
or Look Directly in the Header File.
AND LIKE THIS FOR LINUX OR MAC OS :
#include <iostream>
#include "Terlor.hpp"
int main()
{
arc::setTextColor(Color::RED);
std::cout<<"RED\n";
arc::resetColor();
// SET BACKGROUND COLOR
arc::setTextColor(BG::CYAN);
std::cout<<"CYAN BG\n";
arc::resetColor();
-
VS code ✅
-
Visual Studio ✅
-
Dev C++ ✅
-
Sublime Test ✅
-
JetBrains ✅
Works here fine so should work with almost every IDEs 🔥
Warning
Follow the Instruction Closely.
Note
Color Intensity Might be Little Different for Different Teriminals
- Increased Readability for Windows Functions
- Fixed BG Color not Working for LINUX and MAC OS.
- Added Linux and Mac OS Support
- NOW Working on GCC x86
- Optimizations