/* Ncurses Example - "Hello World" By j00n1x (c) 2003 */ #include #include #include #include int main() { // Stuff they tell you to do in the manpages for setting up // a default window. initscr(); cbreak(); noecho(); nonl(); intrflush(stdscr, FALSE); // NB: stdscr is a global var with ncurses keypad(stdscr, TRUE); // stdscr points to the default window start_color(); init_pair(1, COLOR_YELLOW, COLOR_BLUE); // NB: colour pairs are // global arrays (palettes) // You have to set a palette // before you can use it. // palette 0 = white on black. // and cannot be changed. move(12, 30); // NB: y first, then x. bkgdset(COLOR_PAIR(1) | A_BOLD); // use palette 1 with A_BOLD printw("Hello World"); // just like printf() bkgdset(COLOR_PAIR(0)); printw("\n"); move(23, 0); printw("Done.\n"); refresh(); // updates the screen. endwin(); // kills the window }