// // Header Files ///////////////////////////////////////////////////////// // #include // for console I/O #include // for curses interface using namespace std; // // Global Constant Definitions ////////////////////////////////////////// // const int SUCCESSFUL_ROUTINE = 0; const int FAILED_ROUTINE = -1; // // Global Function Prototypes /////////////////////////////////////////// // void startCurses(); void endCurses(); // // Main Program Definition ////////////////////////////////////////////// // int main() { // initialize variables char c; // initialize curses startCurses(); if(has_colors() == FALSE) { endCurses(); cout << "Your terminal does not support color" << endl; return FAILED_ROUTINE; } // Start color start_color(); init_pair(1, COLOR_RED, COLOR_YELLOW); attron(COLOR_PAIR(1)); mvaddstr(10,5," Voila! In Color! "); attroff(COLOR_PAIR(1)); // make screen stay c = getch(); // close Program endCurses(); system("PAUSE"); return SUCCESSFUL_ROUTINE; // Return 0 to the operating system // to indicate succesful program completion // } // end of main function void startCurses() { // Initialize the curses library initscr(); // // Enable keyboard mapping keypad(stdscr, TRUE); // // Inhibit converting a newline into a carriage return // and a newline on output nonl(); // // Accept input characters without the [ENTER] key cbreak(); // // Inhibit input echoing // (i.e., key pressed will not be shown on the screen) noecho(); // // Forces wait until available character // or time delay (of parameter - 0.1 second), // whichever comes first // NOTE: halfdelay is not used because the program // will be waiting for user responses // halfdelay(1); } void endCurses() { // Shuts down curses interface endwin(); /* do your non-curses wrapup here */ system("clear"); cout << "All Done!" << endl; system("pause"); exit(0); }