#include "CursesObj.h" #include "curses.h" CursesObj::CursesObj() { // Colours 0 to 7 are defined by curses. But we need grey as well // Define a suitable constant here (and create the colour later) const int COLOR_GREY = 8; initscr(); /* initialize the curses library */ nonl(); /* tell curses not to do NL->CR/NL on output */ cbreak(); /* take input chars one at a time, no wait for \n */ nodelay(stdscr, FALSE); noecho(); /* echo input - in color */ curs_set(0); intrflush(stdscr, FALSE); if (has_colors()) { start_color(); /* * Simple color assignment, often all we need. Color pair 0 cannot * be redefined. This example uses the same value for the color * pair as for the foreground color, though of course that is not * necessary: */ init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_YELLOW, COLOR_BLACK); init_pair(4, COLOR_BLUE, COLOR_BLACK); init_pair(5, COLOR_CYAN, COLOR_BLACK); init_pair(6, COLOR_MAGENTA, COLOR_BLACK); init_pair(7, COLOR_WHITE, COLOR_BLACK); // Create 'grey' and then use it as foreground colour init_color(8, 1, 333, 333); init_pair(8, COLOR_GREY, COLOR_BLACK); } } CursesObj::~CursesObj() { clear(); refresh(); endwin(); } CursesObj &CursesObj::Instance() { static CursesObj instance; return instance; }