DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
terminfo programming

What every terminfo program needs

A terminfo program typically includes the header files and routines shown in ``Typical framework of a terminfo program''.

   #include <ocurses.h>
   #include <oterm.h>
   ...
      setupterm( (char*)0, 1, (int*)0 );
      ...
      putp(clear_screen);
      ...
      reset_shell_mode();
      exit(0);

Typical framework of a terminfo program

The header files ocurses.h and oterm.h are required because they contain the definitions of the strings, numbers, and flags used by the terminfo routines. setupterm takes care of initialization. Passing this routine the values (char*)0, 1, and (int*)0 invokes reasonable defaults. If setupterm cannot figure out what kind of terminal you are on, it prints an error message and exits. reset_shell_mode performs functions similar to endwin and should be called before a terminfo program exits.

A global variable like clear_screen is defined by the call to setupterm. It can be output using the terminfo routines putp or tputs, which gives a user more control. This string should not be directly output to the terminal using the C library routine printf [see fprintf(3S)], because it contains padding information. A program that directly outputs strings will fail on terminals that require padding or that use the xon/xoff flow control protocol.

At the terminfo level, the higher level routines like addch and getch are not available. It is up to you to output whatever is needed. For a list of capabilities and a description of what they do, see 4terminfo( )4 routines.


Next topic: Compiling and running a terminfo program
Previous topic: Working with terminfo routines

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