ETI windows

ETI low-level interface (curses) to high-level functions

In the following sections, we will consider the ETI high-level functions, which create and manipulate panels, menus, and forms. All application programs that use these high-level functions require a set of low-level ETI (curses) calls that properly initialize and terminate the programs. For convenience, you may want to isolate these calls in appropriate routines. ``Sample routines for low-level ETI (curses) interface'' shows one way you might do this. It lists routines to start low-level ETI, terminate it, and handle fatal errors.

   static char *	PGM	= (char *) 0;	/* program name	*/
   static int	CURSES	= FALSE;	/* is curses initialized ?	*/

static void start_curses () /* curses initialization */ { CURSES = TRUE; initscr (); nonl (); raw (); noecho (); wclear (stdscr); }

static void end_curses () /* curses termination */ { if (CURSES) { CURSES = FALSE; endwin (); } }

static void error (f, s) /* fatal error handler */ char * f; char * s; { end_curses (); printf ("%s: ", PGM); printf (f, s); printf ("\n"); exit (1); }

Sample routines for low-level ETI (curses) interface

These house-keeping routines use two global variables, PGM and CURSES. PGM is initialized with the program's name, while the Boolean CURSES is initialized with FALSE because curses itself has not yet been invoked.

Function start_curses calls the low-level routines previously mentioned and sets CURSES to TRUE to indicate that it has initialized curses. Function end_curses checks if curses is initialized and, if so, sets the variable CURSES to FALSE and terminates curses. The check is necessary because endwin returns an error if called when curses is not initialized.

Function error is a universal fatal error handler--called whether curses is initialized or not. It first calls end_curses to terminate it if it is on, and then prints the program's name (PGM) and message passed to it. Finally, it terminates the program itself using exit.

Previous topic: subwin

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