PreviousGeneric Line Drawing Generic Display AttributesNext"

Chapter 25: 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.

25.1 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.

25.2 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. In the UNIX environment, the COBOL RTS interprets the attribute byte and controls the terminal via the terminfo entry values for the terminal.

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 on DOS, Windows and OS/2 and white foreground on black background on UNIX, unless defined otherwise in the terminfo database. If using UNIX, see the chapter Terminfo Database and Terminal Devices in your Object COBOL User Guide for further details.

25.2.1 Types of Encoding

There are four types of encoding for the attribute byte:

UNIX:
You can override the UNIX default encoding to provide easier portability of new applications between the PC and UNIX environments by using generic attribute encoding. For existing applications, select explicit PC encoding by calling the routine CBL_SCR_SET_PC_ATTRIBUTES. The terminfo entry for the display determines whether monochrome or color encoding is used.

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

25.2.2 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
3 Intensity
2-0 Normal or underline select

Examples:

x"82" = flashing, otherwise normal
x"07" = normal

Other bit combinations are:

  bits 6, 5, 4
all set
bits 6, 5, 4
all unset
bits 6, 5, 4;
other settings
bits 2, 1 ,0
unset
reverse video no display normal display
bits 2, 1 unset bit 0 set underlined display
all other
settings
normal display

"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 (Decimal=007/Hex=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.

25.2.3 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.

Bit
Attribute
7 Blink
6-4 Background color
3 Intensity of foreground
2-0 Foreground (text) color

Bits 6, 5 and 4 control the background color as follows:

Bits 6 5 4
Effect
0 0 0 black
0 0 1 blue
0 1 0 green
0 1 1 cyan
1 0 0 red
1 0 1 magenta
1 1 0 brown
1 1 1 light gray

Bits 2, 1, and 0 control the foreground (text) color as follows:

Bits
2 1 0

Bit 3 Unset

Bit 3 Set
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
black
blue
green
cyan
red
magenta
brown
light gray
dark gray
light blue
light green
light cyan
light red
light magenta
yellow
white

Examples:

Value
Effect
1 0 1 0 1 1 0 1
(Decimal=173,
Hex=x"AD")
Light magenta flashing text on a green background.
0 0 0 0 0 1 0 0
(Decimal=4,
Hex=x"04")
Red text on a black background.
0 0 0 1 0 1 1 1
(Decimal=23,
Hex=x"17")
Light gray text on a blue background.

25.2.4 UNIX Attribute Encoding

UNIX:
The default UNIX attribute byte has no color encoding and encodes purely monochrome attributes as follows:

Bit
Attribute
7-4 Must be set to 0
3 Blink
2 Reverse video
1 Underline
0 Highlight

Each bit indicates one type of attribute. You can set these bits by using the library call-by-number routine x"A7 ". You can set more than one bit of the attribute byte to give a combination of attributes, for example, underline and blinking. The attributes available to you and the combinations that are valid are dependent on the type of terminal you are using and the completeness of your terminfo entry.

25.3 Highlighting on UNIX

UNIX:
By default on UNIX, when a COBOL program displays text subject to a HIGHLIGHT or LOWLIGHT clause, the RTS uses respectively the bold or dim mode specified in the terminfo entry for the terminal. If the bold or dim mode is not specified, then the HIGHLIGHT or LOWLIGHT clause respectively has no effect.

The default behaviour was different for COBOL products before version 3.2. For these earlier versions, when a COBOL program displayed text subject to a HIGHLIGHT clause the effect depended on whether the dim mode was specified in the terminfo entry for the terminal. If dim mode was specified, then the RTS used the default mode for highlighted text and the dim mode for normal text. If the dim mode was not specified, then the RTS used the bold mode for highlighted text and default mode for normal text. The LOWLIGHT clause had no effect and text appeared as for normal text.

You can select the old default behaviour by setting the COBATTR environment variable.

25.4 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" function 16 Turn User Attribute On/Off
X"A7" functions 20/21 System Attributes

These routines are described here. Before using any of the X"A7" routines for screen handling, use the CBL_CLR_SCR routine.

25.4.1 Description of Routines


X"A7" functions 6/7 - User Attribute

Reads and sets user attribute.

Syntax:
call x"A7" using     function-code                      
user-attribute 
           returning status-code
Parameters:

function-code       pic x comp-x.
user-attribute      pic x comp-x.
status-code         See Key in the Preface
On Entry:

function-code Defines the action:

6 Read user attribute
7 Set user attribute
user-attribute For function 7, the value to set the user attribute.

On Exit:

user-attribute For function 6, the value of the current user attribute.

Comments:

You can use this library routine to change the user attribute dynamically on UNIX. You should use the same caution when using this routine as when using any other, using only regular COBOL syntax wherever possible.

Before using this routine, use the CBL_CLEAR_SCR routine, to prevent possible errors.

See also:

Using the User Attribute
X"A7" function 16 - Turn user Attribute On/Off
X"A7" functions 20/21 - System Attributes


X"A7" function 16

Turns the user attribute on or off.

Syntax:
call x"A7" using function-code                   parameter
Parameters:

function-code       pic x comp-x.
parameter           pic x comp-x.
On Entry:

function-code Value 16
parameter Indicates the action wanted:

0 Turns the User attribute on
1 Turns the User attribute off

On Exit:

None

Comments:

On UNIX, you can only turn the user attribute on. However, you can emulate turning the user byte off by setting the attribute type to normal by calling the x"A7" routine function 7 to set the user attribute to normal and then calling x"A7" function 16 with a value of 0 in parameter.

Before using this routine, use the CBL_CLEAR_SCR routine, to prevent possible errors.

See also:

Using the User Attribute
X"A7" functions 6/7 - User Attribute


X"A7" functions 20/21 - System Attributes

Reads and sets system attributes.

Syntax:
call X"A7" using     function-code                      
sys-attr-array 
           returning status-code
Parameters:

function-code pic x comp-x.
sys-attr-array Group item defined as:
sys-attr          pic x comp-x occurs 16 times.
status-code See Key in the Preface
On Entry:

function-code Defines the action:

20 Read system attributes
21 Set system attributes
sys-attr-array Contains the system attributes to set. The attributes are used for:

sys-attr-1 Invisible
sys-attr-2 Reverse video
sys-attr-3 Normal
sys-attr-4 Highlighted
sys-attr-5 Normal underlined
sys-attr-6 Highlighted underlined
sys-attr-7 System normal
sys-attr-8 Flashing highlighted
sys-attr-9 Unused
sys-attr-10 User reverse
sys-attr-11 User normal
sys-attr-12 User highlighted
sys-attr-13 Unused
sys-attr-14 Unused
sys-attr-15 Unused
sys-attr-16 Operating system normal

On Exit:

sys-attr-array Contains the system attributes read.

Comments:

System attributes are used by some parts of the system to display screens in various colors or shades (depending on the type of screen). This means that by changing the system attributes, you can colorize displays to a particular choice. These calls can be used if you use components such as Panels which require attribute values as part of their parameters.

If you want to alter any of the attributes you should first read the current setting of the attributes, update the attribute array with any changes you want to make and then set the attributes. Doing things this way ensures that you do not affect the settings of any of the attributes which you are not interested in.

Before using this routine, use the CBL_CLEAR_SCR routine, to prevent possible errors.

See also:

X"A7" functions 6/7 - User Attribute


Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousGeneric Line Drawing Generic Display AttributesNext"