Applications can manipulate text based consoles or terminals, and change their colors, set cursor position. The supported approaches are:
ANSI escape code
.SetConsoleTextAttribute
.but, is there any lightweight and portable C/C++ library which handles differences between operating systems just for colors and cursor? and do nothing if it was technically impossible but best effort.
Note: I'm not searching for heavy external tools to emulate unix-like terminals (like Cygwin, Msys-rxvt, ...). I think a simple portability will be achieved with Windows APIs and ANSI escape codes. And not ncurses because it's heavy and has many functionality to full control console and I think it needs emulation.
Alright, i finally found a portable and easy to use library: rlutil.h
Usage:
#include <iostream>
#include "rlutil.h"
int main()
{
for (int i = 0; i < 16; i++)
{
rlutil::setColor(i);
std::cout << i << " ";
}
std::cout << std::endl;
return 0;
}
but, i will be glad for other suggestions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With