Chapter 7: IBM PC Display Attributes

This chapter describes display attributes for text-based environments or for text emulation within a graphical environment. It does not relate to graphical objects or text within graphical objects.

Text Attributes

Whenever a text character is displayed on the terminal it has a set of attributes associated with it which describes how the text character appears on the screen. The character might appear in color with specific foreground and background colors; it might appear as brighter or dimmer than normal text, with reversed foreground and background colors, flashing or some other attributes. The attributes available depend on the hardware and software associated with the terminal, but many commonly available attributes can be displayed by a portable COBOL application without any knowledge of the physical terminal characteristics.

Your COBOL programs can display text with these attributes using COBOL ACCEPT and DISPLAY statements that specify the attributes in associated clauses. COBOL programs can also specify display attributes via various call interfaces, such as that for Panels.

Attribute Encoding

When specifying attributes via a call interface, it is convenient to encode the attributes for each text character into a corresponding attribute byte. In the IBM PC environment, the one-byte encoding is interpreted directly by the hardware.

The screen attribute is the conceptual attribute byte that is associated with a particular text character, one for each character position on the screen. Some call interfaces have a physical array of screen attributes that can be set directly.

Whenever Adis accesses the screen or Panels it updates the screen attribute for each text character referenced. If the ACCEPT or DISPLAY statement specifies any attributes for the referenced text then those are used for the screen attributes. If no attributes are specified, then Adis uses the default RTS attribute or the user attribute , if enabled, for the screen attribute for each referenced text character. If Adis clears the screen, for example using the BLANK SCREEN clause, or when Panels initialises a panel or a scrolled line, the screen attributes are set to the default or user attribute.

The default RTS attribute is brown foreground on black background.

Types of Encoding

There are three types of encoding for the attribute byte:

See below for details on both monochrome and color PC attribute encoding.

IBM PC Monochrome Attribute Encoding

DOS, Windows and OS/2:

The following table shows the structure of the attribute byte for a personal computer with a monochrome display. Bit 0 is the least significant and rightmost bit of the byte, bit 7 is the most significant bit. The effects of setting (making equal to 1) and unsetting (making equal to 0) each bit in the attribute byte are shown.

On DOS, Windows and OS/2 you can set these attributes using COBOL system library routines described.

Bit Attribute
7 Blink
6-4 Turns off display or sets reverse video:
Value Effect
7 reverse video
0 no display
other normal
3 Intensity
2-0 Normal or underline select:
Value Effect
1 underlined
other normal
Examples:

"Normal" text on a monochrome display (non-highlighted text on black background) can be obtained by a number of different bit settings, since several bits which are used to control color are ignored by the monochrome display. However, only one combination produces this "normal" text on both monochrome and color displays:

"Normal" setting= 0 0 0 0 0 1 1 1 (x"07")

To ensure consistent results from programs that are used on both color and monochrome displays, you should make certain that you use this setting to achieve "normal" text.

IBM PC Color Attribute Encoding

DOS, Windows and OS/2:

The following tables show the structure of the attribute byte for a personal computer with a color display. The effects of setting (making equal to 1) and unsetting (making equal to 0) these bits are shown.

On DOS, Windows and OS/2 you can set these attributes using COBOL system library routines.

Bits Attribute
7 Blink
6-4 Background color:
Value Color
0 black
1 blue
2 green
3 cyan
4 red
5 magenta
6 brown
7 light gray
3 Intensity of foreground
2-0 Foreground (text) color:
Value Bit 3 Unset Bit 3 Set
0 black dark gray
1 blue light blue
2 green light green
3 cyan light cyan
4 red light red
5 magenta light magenta
6 brown yellow
7 light gray white
Examples:

Attribute Routines

The following routines are available to help you use attributes in your character user interfaces:

X"A7" functions 6/7 User Attribute
X"A7" functions 16 Turn User Attribute On/Off
X"A7" functions 20/21 System Attributes

These routines are fully described in the online help.


Copyright © 2009 Micro Focus (IP) Ltd. All rights reserved.