jgonzalezdr / ColorConsoleLib

ColorConsoleLib is a library that adds colorization capabilities to the C++ standard output and error streams (cout/wcout and cerr/wcerr).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Color Console Library

Build status codecov

About

ColorConsoleLib is a library that adds text coloring capabilities to the C++ standard output and error streams (cout/wcout and cerr/wcerr).

Usage

ColorConsoleLib provides compatible replacements for the C++ standard cout, cerr, wcout and wcerr output streams in the ColorConsole namespace that add text coloring capabilities by accepting Colors to the insertion operator (<<).

#include "ColorConsole.hpp"

using namespace ColorConsole;

int main( int argc, const char* argv[] )
{
  cout << Color::FG_LIGHT_BLUE << "Hello World!" << endl;

  return 0;
}

There are 16 foreground Colors (which names start with FG_) that can be mixed with 17 background Colors (which names start with BG_) using the OR operation (|).

Color Table

Note:

The background Color FG_BLACK interpretation depends on the terminal. Some interpret it as black, others as transparent (showing the underlying console color).

The background Color FG_NONE interpretation depends on the terminal. Some interpret it as transparent (showing the underlying console color), others as black.

The special Color RESET can be used to return the console to the original "non-colored" mode.

Alternatively, the set_color() member function can be used, which behaves just like inserting a Color in the stream.

Example Output

Example Output

Building from Source

Build Requirements

  • CMake (≥ v3.13, tested with v3.17.2)
  • CppUTest [Optional, not needed if tests are disabled] (tested with v3.9.alpha0)
  • On Windows:
  • On Linux:
    • GCC (tested with v7.5.0, v8.4.0 and v9.3.0)
    • LCOV [Optional, needed if tests and coverage are enabled using GCC] (tested with v1.14)

CMake Project Options

OPTION Description
-DCMAKE_BUILD_TYPE Selects build type
(only for single-config generators)
Debug
Release(default)
RelWithDebInfo (Release with debug info)
MinSizeRel(Release with size optimization)
Coverage(Debug with code coverage enabled)
-DBUILD_SHARED_LIB Enables generation of shared library
ON(default)
OFF
-DBUILD_STATIC_LIB Enables generation of static library
ON(default)
OFF
-DENABLE_TEST Enables compilation and execution of tests
ON(default)
OFF
-DCPPUTEST_HOME Path to your CppUTest installation directory
<filesystem path>
-DLCOV_HOME Path to your LCOV installation directory
<filesystem path>
-DENABLE_INSTALLER Enables generation of installer packages
ON(default)
OFF
-DBUILD_EXAMPLES Enables building examples
ON(default)
OFF
-DCOVERAGE Enables code coverage in tests
(only for multi-config generators)
ON(default)
OFF
-DCOVERAGE_VERBOSE Enables verbose code coverage
ON
OFF(default)
-DCI_MODE Enables Continous Integration mode
ON
OFF(default)

About

ColorConsoleLib is a library that adds colorization capabilities to the C++ standard output and error streams (cout/wcout and cerr/wcerr).

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C++ 72.3%Language:CMake 20.5%Language:PowerShell 4.7%Language:C 2.4%Language:Shell 0.0%Language:Makefile 0.0%