|
|
terminfo is both a set of routines that make use of the capabilities of a wide range of terminals and a database that contains descriptions of the terminals that can be used with ETI. Its use as a database is our concern here. See ``terminfo programming'' for details on its use as a set of routines.
A screen management program with ETI routines refers to the terminfo database at run time to obtain the information it needs about the terminal being used--what we will call the current terminal from here on.
Suppose, for instance, that you are using a Teletype 5425 terminal to run the simple ETI program shown in ``A simple ETI program''. To execute properly, the program needs to know how many lines and columns the terminal screen has to print the BullsEye in the middle of it. The description of the Teletype 5425 in the terminfo database has this information, as well as other information about the terminal's capabilities and how it performs various operations -- for example, how its control characters are interpreted. All ETI needs to know before it goes looking for the information is the name of your terminal.
You tell the program the name by putting it in the environment variable $TERM when you log in or by setting and exporting $TERM in your .profile file (see profile(4)). Knowing $TERM, an ETI program run on the current terminal can search the terminfo database to find the correct terminal description.
For example, assume that the following lines are in a .profile:
TERM=5425 export TERM tput init
The first line names the terminal type, and the second line exports it. (See profile(4).) The third line of the example tells the UNIX system to initialize the current terminal. That is, it makes sure that the terminal is set up according to its description in the terminfo database. (The order of these lines is important. $TERM must be defined and exported first, so that when tput(1) is called the proper initialization for the current terminal takes place.) If you had these lines in your .profile and you ran an ETI program, the program would get the information that it needs about your terminal from the file /usr/share/lib/terminfo/5/5425 in the database, which provides a match for $TERM. For more information about the terminfo database, see ``terminfo programming''.