Giter Site home page Giter Site logo

console-color-cpp's Introduction

console-color-cpp

A small single-header library for outputting colored text to the console.

Only Windows is currently supported!

Using

To connect, simply include the header file in your project:

#include "console-color.hpp"

To output text, a standard output stream is used. For unification the operator << is used.

The simplest example looks like this:

#include "console-color.hpp"

using namespace cs;
using namespace std;

int main()
{
    cout << (("Hello World!"_cs << color(0xF2F61D)) << endl;
    return 0;
}

It is important that everything that you output to the standard stream must be wrapped in brackets!

// wrong
cout << ""_cs << color();

// good
cout << (""_cs << color());

You can output string one by one. Each expression of the form "" _cs << color() must be wrapped in brackets:

cout << ((""_cs << color()) << (""_cs << color())) << endl;

An expression of the form "" _cs << color() can be written as "" _cs.use(color()).

Also from any string you can make a string with color:

color_string str("Hi!");

// or

string s_string("Other string");
color_string str(s_string);

Before outputting a string, you can give it the color with which it will be displayed:

str << color(255, 0, 0);

// or

str.use(color(255, 0, 0));

Colors can be set using either a 32 bit number (HEX) or in RGB format.

License

MIT

console-color-cpp's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.