HP 9000 Series 300 Tutorials Manual page 221

Device i/o and user interfacing hp-ux concepts and tutorials
Hide thumbs Also See for HP 9000 Series 300:
Table of Contents

Advertisement

accordingly. For a list of terminfo capabilities and their descriptions, see
terminfo(5) in the HP-UX Reference.
The example program termhl at the end of this tutorial shows simple use of
terminfo. It is similar to highlight, but uses terminfo instead of curses.
This version can be used as a filter. The strings used to enter bold and
underline mode, and to disable all highlighting attributes are demonstrated.
The program was made more complex than necessary in order to illustrate
several terminfo properties. For example, vidattr could have been used
instead of directly outputting enter _bold_mode, enter _underline_mode, and
exi t_attribute_mode. In fact, the program could easily be made more robust
by using vidattr because there are several ways to change video attributes.
However, this program was structured only to illustrate typical use of terminfo
routines.
The function tputs(cap,affcnt,outc) adds padding information to the
capability cap. Some capabilities contain strings such as $<20>, which means
to pad for 20 milliseconds. tputs adds enough pad characters to produce the
desired delay. cap is the string capability to be output; affcnt is the number
of lines affected by the output (for example, insert_line may have to copy all
lines below the current line, and may require time proportional to the number
of lines being copied). By convention, affcnt is 1 if no lines are affected rather
than 0 because affcnt is multiplied by the amount of time required per item,
and a zero time may be undesirable. outc is the name of a routine that is to
be called with each character being sent.
In many simple programs, affcnt is set to 1, and outc just calls putchar. For
such programs, the terminfo routine putp(cap) is a convenient abbreviation.
The example program t ermhl could be simplified by using putp.
Note the special check for the underline_char capability. Some terminals,
rather than having a code to start underlining and a code to stop underlining,
use a code to underline the current character. t ermhl keeps track of the
current mode, and outputs underline_char, if necessary, whenever the current
character is to be underlined. Low-level details such as this are a major reason
why curses routines are preferred over terminfo routines. curses takes care
of all the different terminal key board and display functions and highlighting
sequences instead of forcing such details onto the application program.
Using Curses and Terminfo
1-23

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Hp 9000 series 800

Table of Contents