curhell2.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <curses.h>
int main(void) {
WINDOW * mainwin;
if ( (mainwin = initscr()) == NULL ) {
fprintf(stderr, "Error initialising ncurses.\n");
exit(EXIT_FAILURE);
}
start_color();
mvaddstr(6, 32, " Hello, world! ");
if ( has_colors() && COLOR_PAIRS >= 13 ) {
int n = 1;
init_pair(1, COLOR_RED, COLOR_BLACK);
init_pair(2, COLOR_GREEN, COLOR_BLACK);
init_pair(3, COLOR_YELLOW, COLOR_BLACK);
init_pair(4, COLOR_BLUE, COLOR_BLACK);
init_pair(5, COLOR_MAGENTA, COLOR_BLACK);
init_pair(6, COLOR_CYAN, COLOR_BLACK);
init_pair(7, COLOR_BLUE, COLOR_WHITE);
init_pair(8, COLOR_WHITE, COLOR_RED);
init_pair(9, COLOR_BLACK, COLOR_GREEN);
init_pair(10, COLOR_BLUE, COLOR_YELLOW);
init_pair(11, COLOR_WHITE, COLOR_BLUE);
init_pair(12, COLOR_WHITE, COLOR_MAGENTA);
init_pair(13, COLOR_BLACK, COLOR_CYAN);
while ( n <= 13 ) {
color_set(n, NULL);
mvaddstr(6 + n, 32, " Hello, world! ");
n++;
}
}
refresh();
sleep(3);
delwin(mainwin);
endwin();
refresh();
return EXIT_SUCCESS;
}
Please send all comments, suggestions, bug reports etc to mail@paulgriffiths.net