A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ararslan/termcolor-c below:

ararslan/termcolor-c: A header-only ANSI C library for writing colored text to the terminal

A header-only ANSI C library for writing colored text to the terminal, based on Termcolor for C++.

Like Termcolor, it uses ANSI escape codes to modify text attributes. This should work on most terminals, at least for POSIX-like systems. Note that unlike Termcolor, Windows is not yet supported here.

Add termcolor-c.h to your project and #include it. The library is also installable using clib.

The idea behind termcolor, which is mimicked in termcolor-c, is to manipulate the underlying stream to which text is written. As an example:

#include <stdio.h>
#include "termcolor-c.h"

int main(int argc, char** argv) {
    fputs("Hello, colorful world\n", text_red(stdout));
    reset_colors(stdout);
    return 0;
}

If you compile this and run it, you'll find that "Hello, colorful world" has been printed to STDOUT in red. Note that if you don't call reset_colors, text in the terminal will continue to be red even after the program has finished executing.

Licensed under the terms of the 2-clause "simplified" BSD license. See LICENSE.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4