#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <curses.h>
int main() { initscr();
if(!has_colors()) { endwin(); fprintf(stderr,"ERROR:No color support on this terminal\n"); exit(1); } else { printw("%s","color support"); refresh(); sleep(2); } if(start_color()!=OK) { endwin(); fprintf(stderr,"ERROR:Could not initialize colors!\n"); exit(2); } clear(); mvprintw(5,5,"There are %d COLORS and %d COLOR_PAIRS available",COLORS,COLOR_PAIRS); refresh();sleep(2);
init_pair(1,COLOR_RED,COLOR_BLACK); init_pair(2,COLOR_RED,COLOR_GREEN); init_pair(3,COLOR_GREEN,COLOR_RED); init_pair(4,COLOR_YELLOW,COLOR_BLUE); init_pair(5,COLOR_BLACK,COLOR_WHITE); init_pair(6,COLOR_MAGENTA,COLOR_BLUE); init_pair(7,COLOR_CYAN,COLOR_WHITE);
int i; for(i=1;i<8;i++) { attroff(A_BOLD); attrset(COLOR_PAIR(i)); mvprintw(5+i,5,"Color pair : %d ",i); attrset(A_BOLD); mvprintw(5+i,25,"Bold Color pair :%d ",i); refresh();sleep(2); }
endwin(); exit(EXIT_SUCCESS); }
|