DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
ETI program examples

The colors program

This program creates two windows. All characters displayed in the first window will be in red, on a blue background. All characters displayed in the second window will be in yellow, on a magenta background.

#include <ocurses.h>

#define PAIR1 1 #define PAIR2 2

main() { WINDOW *win1, *win2;

initscr(); if ((start_color()) == OK) { /* create windows */

win1 = newwin (5, 40, 0, 0); win2 = newwin (5, 40, 15, 40);

/* create two color pairs */

init_pair (PAIR1, COLOR_RED, COLOR_BLUE); init_pair (PAIR2, COLOR_YELLOW, COLOR_MAGENTA);

/* turn on color attributes for each window */

wattron (win1, COLOR_PAIR (PAIR1)); wattron (win2, COLOR_PAIR (PAIR2));

/* print some text in each window and exit */

waddstr (win1, "This should be red on blue"); waddstr (win2, "This should be yellow on magenta"); wnoutrefresh (win1); wnoutrefresh (win2); doupdate();

/* wait for any key before terminating */

wgetch (win2); }

endwin(); }


Previous topic: The window program

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004