/* ** Copyright (C) Katrin Lang ** Licensed under GPL v3 or later */ #include #include #include #include #include int main(){ int rainbow[]= {COLOR_RED, COLOR_YELLOW, COLOR_GREEN, COLOR_CYAN, COLOR_BLUE, COLOR_MAGENTA}; setlocale(LC_ALL,""); initscr(); /* Start curses mode */ if(has_colors() == FALSE){ /* FALSE is defined already in ncurses.h */ endwin(); printf("Your terminal does not support color\n"); exit(EXIT_FAILURE); } /* Curses initializes all the colors supported by terminal when start_color() is called. These can be accessed by the define constants like COLOR_BLACK etc. Now to actually start using colors, you have to define pairs. Colors are always used in pairs. That means you have to use the function init_pair() to define the foreground and background for the pair number you give. After that that pair number can be used as a normal attribute with COLOR_PAIR()function. This may seem to be cumbersome at first. But this elegant solution allows us to manage color pairs very easily. */ start_color(); init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK); init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK); init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK); init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK); init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK); init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); curs_set(0); //remove cursor for(int i= 0; i