/Terminal_Coloring

A Header only Lib to change the text Foreground and Background.

Primary LanguageC++

Terminal_Coloring

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.

How to Use ?

  1. Download this Terlor.hpp file and add it to your working directory.
  2. #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();

Tested on IDEs: 🧑🏻‍💻

  • 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

Few Examples :

Loading_Bar [ Will Update Later ]

image

image

image


CHANGE LOG V 3📑

  • 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

Please provide any feedback/issues you've.

If you can help improvve the Code please Do so. 😺

DEV. : Hritik Shahi ( ICFAI UNIVERSITY )

TESTER : Alok Raj ( ICFAI UNIVERSITY )