On Sun, 13 Sep 1998, James wrote: > how do i get coloured text in ncurses? i've tried making a colour pair > and attron() and attrset() but the best i got was the following in > black on flashing white (the text was 'Hello!'): > > 27462Hello! > > (i can't remember what the numbers were, but there were some numbers). Did you call start_color() and check it? Have a good read of the Linux Programmers Guide 0.4 if you haven't already. It has a very large section on ncurses. If you can't find try poking around in sunsite.unc.edu or one of it's mirrors. I also came across a good tutorial on the ncurses while looking for something else. Point your browser to : http://www.aaronsrod.com/freemoney/ncurses-intro.html #include <stdio.h> #include <ncurses.h> int main(void) { initscr(); if(has_colors()) { start_color(); /* tacky colour scheme*/ init_pair(1, COLOR_BLUE, COLOR_GREEN); init_pair(2, COLOR_RED, COLOR_YELLOW); } else fprintf(stderr, "no colours for this terminal entry"), exit(-1); attr_on(COLOR_PAIR(1)); mvaddstr(0,0, "Grrrrrrrrrrrrrrrrrr"); attr_on(COLOR_PAIR(2)|A_BOLD); mvaddstr(1,0, "Grrrrrrrrrrrrrrrrrr"); refresh(); /* exit */ endwin(); return 0; }
