DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Simple input and output

Output attributes

When we talked about addch, we said that it writes a single character of the type chtype to stdscr. chtype has two parts: a part with information about the character itself and another part with information about a set of attributes associated with the character. The attributes allow a character to be printed in reverse video, bold, underlined, in colors and so on.

stdscr always has a set of current attributes that it associates with each character as it is written. However, using the routine attrset and related ETI routines described below, you can change the current attributes. Below is a list of the attributes and what they mean:

(See ``Color manipulation'' below for information on using colors.)

To use these attributes, you must pass them as arguments to attrset and related routines; they can also be ORed with the bitwise OR (| ) to addch.


NOTE: Not all terminals are capable of displaying all attributes. If a particular terminal cannot display a requested attribute, an ETI program attempts to find a substitute attribute. If none is possible, the attribute is ignored.

Let's consider a use of one of these attributes. To display a word in bold, you would use the following code:

    ...
   printw("A word in ");
   attrset(A_BOLD);
   printw("boldface");
   attrset(0);
   printw(" really stands out.\n");
    ...
   refresh();

Attributes can be turned on singly, such as attrset(A_BOLD) in the example, or in combination. To turn on blinking bold text, for example, you would use attrset(A_BLINK|A_BOLD). Individual attributes can be turned on and off with the ETI routines attron and attroff without affecting other attributes. attrset(0) turns all attributes off.

Notice the attribute called A_STANDOUT. You might use it to make text attract the attention of a user. The particular hardware attribute used for standout is the most visually pleasing attribute a terminal has. Standout is typically implemented as reverse video or bold. Many programs do not really need a specific attribute, such as bold or reverse video, but instead just need to highlight some text. For such applications, the A_STANDOUT attribute is recommended. Two convenient functions, standout and standend can be used to turn on and off this attribute. standend, in fact, turns off all attributes.

In addition to the attributes listed above, there are two bit masks called A_CHARTEXT and A_ATTRIBUTES. You can use these bit masks with the ETI function inch and the C logical AND ( & ) operator to extract the character or attributes of a position on a terminal screen. See the discussion of inch on the curses(3ocurses) manual pages.

Following are descriptions of attrset and the other ETI routines that you can use to manipulate attributes.


Next topic: attron, attrset, and attroff
Previous topic: scanw

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