ANSI escape codes wrapped in C++ string streams.
It's everything you need for advanced terminal control, wrapped in light headers ready for inclusion.
Ansi-Escape
, or AESC
, is an effort to wrap common terminal controls and colors for prettier terminal output.
It is built and tested on macOS, but probably will work in other *NIX systems as well.
To maximize compatibility, we choose to support C++11, with CMake-3.9 as a build dependency.
AESC
implemented most ANSI escape sequences, including text coloring and cursor controlling
there are example codes in the examples/ directory, see Install for more information.
Find detailed list of available APIs at docs and wikipedia
#include <iostream>
#include "aesc.hpp"
using namespace std;
using aesc::color;
int main() {
cout << red << " foreground is red" << endl;
cout << bright::red << bright::background::cyan
<< " background bright cyan, foreground bright red" << endl;
cout << aesc::color256::RGB::foreground(2, 3, 0) << "256 color RGB test sequence"
<< endl;
cout << aesc::truecolor::RGB::foreground(130, 250, 0)
<< "24-bit true color RGB test sequence" << aesc::render::reset << endl;
}
See the provided example at examples/show_color.cpp
Install it with Homebrew, or build it using CMake
brew tap hsuantinglu/utils
brew install ansi-escape
CMake is the official build system. At least version 3.9 is needed.
mkdir build; cd build/
# Config and build
cmake .. && make showcolor
# execute example
./examples/showcolor