/** * ***************************************************************************** * file name : term_control.cpp * author : Hung Q. Ngo * description: a couple of functions which returns a string of terminal control * escape sequences * ***************************************************************************** */ #include #include "term_control.h" using namespace std; /** * ----------------------------------------------------------------------------- * output a terminal control code string which formats the text background * & foreground colors & text attributes * ----------------------------------------------------------------------------- */ string term_cc(term_colors_t fg, term_colors_t bg, term_attrib_t attr) { ostringstream oss; oss << uint8_t(0x1b) << '[' << char(attr) << ";3" << char(fg) << ";4" << char(bg) << 'm'; return oss.str(); } /** * ----------------------------------------------------------------------------- * output a TCES which clears the screen * ----------------------------------------------------------------------------- */ string term_clear() { ostringstream oss; oss << uint8_t(0x1b) << "[2J"; return oss.str(); }