Generic Line Drawing | Generic 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.
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.
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 run-time system 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 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 run-time system 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, the screen attributes are set to the default or user attribute.
The default run-time system attribute is white foreground on black background, unless defined otherwise in the terminfo database. See the chapter Terminfo Database and Terminal Devices in your Server Express User's Guide for further details.
There are four types of encoding for the attribute byte. Two of these are for Windows and OS/2 systems. The other two are:
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 UNIX attribute encoding. See your Net Express or Object COBOL for DOS, Windows or OS/2 for both monochrome and color PC attribute encoding.
The default UNIX attribute byte has no color encoding and encodes purely monochrome attributes:
Bit
|
Attribute
|
---|---|
7 through 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.
When a COBOL program displays text subject to a HIGHLIGHT or LOWLIGHT clause, the run-time system 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 behavior 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 run-time system used the default mode for highlighted text and the dim mode for normal text. If the dim mode was not specified, then the run-time system 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 behavior by setting the COBATTR environment variable.
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 and 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_CLEAR_SCR routine.
Reads and sets user attribute.
call x"A7" using function-code user-attribute returning status-code
function-code |
pic x comp-x. |
user-attribute |
pic x comp-x. |
status-code |
See Key in the Preface |
function-code |
Defines the action:
|
||||
user-attribute |
For function 7, the value to set the user attribute. |
user-attribute |
For function 6, the value of the current user attribute. |
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.
X"A7" function 16 - Turn User Attribute
On/Off
X"A7" functions 20/21 - System Attributes
Turns the user attribute on or off.
call x"A7" using function-code parameter
function-code |
pic x comp-x. |
parameter |
pic x comp-x. |
function-code |
Value 16 | ||||
parameter |
Indicates the action wanted:
|
None
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.
X"A7" functions 6/7 - User Attribute
Reads and sets system attributes.
call X"A7" using function-code sys-attr-array returning status-code
function-code |
pic x comp-x. | ||
sys-attr-array |
Group item defined as:
|
||
status-code |
See Key in the Preface |
function-code |
Defines the action:
|
||||||||||||||||||||||||||||||||
sys-attr-array |
Contains the system attributes to set. The attributes
are used for:
|
sys-attr-array |
Contains the system attributes read. |
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 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.
X"A7" functions 6/7 - User Attribute
Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Generic Line Drawing | Generic Display Attributes |