/* nccolour.c - Print out some ncurses colours. * * Compile using: * gcc nccolour.c -o nccolour -lncurses * * Written by Yoran Heling * * Date: 2011-06-11 * License: MIT * Web: http://dev.yorhel.nl/dump/nccolour */ #include #include struct colour { int code; char *desc; } colours[] = { { -1, "default" }, { COLOR_BLACK, "BLACK" }, { COLOR_RED, "RED" }, { COLOR_GREEN, "GREEN" }, { COLOR_YELLOW, "YELLOW" }, { COLOR_BLUE, "BLUE" }, { COLOR_MAGENTA, "MAGENTA" }, { COLOR_CYAN, "CYAN" }, { COLOR_WHITE, "WHITE" }, }; void print_colourpart(int attr, int i) { addstr(" "); attron(attr | COLOR_PAIR(i*6+1)); addstr("FD"); addstr(" "); attron(attr | COLOR_PAIR(i*6+2)); addstr("FB"); attroff(attr | COLOR_PAIR(i*6+2)); addstr(" "); attron(attr | COLOR_PAIR(i*6+3)); addstr("FW"); attroff(attr | COLOR_PAIR(i*6+3)); addstr(" "); attron(attr | COLOR_PAIR(i*6+4)); addstr("BG"); attroff(attr | COLOR_PAIR(i*6+4)); addstr(" "); attron(attr | COLOR_PAIR(i*6+5)); addstr("BD"); attroff(attr | COLOR_PAIR(i*6+5)); } int main(int argc, char **argv) { if(!initscr()) { printf("Error initializing screen.\n"); exit(1); } if(!has_colors()) { printf("This terminal does not support colours.\n"); exit(1); } start_color(); // this prevents ncurses from forcing a white-on-black colour scheme, // regardless of what scheme is used by the terminal. use_default_colors(); attron(A_BOLD); mvaddstr(0, 0, "Colour FD FB FW BG BD BFD BFB BFW BBG BBN"); attroff(A_BOLD); int i; for(i=0; i