Color Setting

Color can be thought of as simply another character attribute. On terminals supporting color there are typically two color attributes per character - foreground and background. The foreground color is the color of the character itself while the background color is the color of the screen "behind" the character. Sometimes the number of colors available in foreground and background are not the same, and therefore PRO/5 treats them as separate entities.

Color terminals support three primary colors (red, green, blue) in various combinations. PRO/5 is prepared to handle four shades of red, green, and blue giving a total of 64 color combinations. The actual value used to represent a color depends on the number of colors supported by the terminal. The :Cd#: field defines the number of foreground colors available on the terminal. This should be 4, 8, 16, or 64. The following describes how color values are computed:

Number of Colors

Values

4

0 = black

1 = blue

2 = green

3 = red

8

Primary colors have the values 1=blue, 2=green, 4=red. Combinations are created by addition. For example, magenta = red+blue = 5.

16

This is the same as with 8-color except the value 8 may be added for high intensity. For example: blue=1, light blue = 1+8 = 9.

64

Primary colors have the values 1=blue, 4=green, 16=red. Each primary color may be present in up to 4 (0..3) shades by multiplication and addition. For example, a color that consists of the highest shade of blue (3) plus a low shade of red would be computed as 3*blue + 0*green + 1*red = 19.

The :Cf#: field specifies the number of background colors available. The codes for background colors are computed in the same manner as the codes for foreground colors.

If it is possible to place the desired color codes directly into an escape sequence then the :Ca=: string may be given. The :Ca=: string is treated just like the :cm=: cursor movement string except the desired foreground and background colors are the values used (instead of line and column). The "%" codes described for the :cm=: string apply here.

If the desired color codes used in the :Ca=: string need to be offset by some value, that may be achieved by the usual "%+x" code in the :Ca=: string. However, the offsets may also be specified by using the :Ce#: field for the foreground color and the :Cg#: field for the background color.

If the proper escape sequence cannot be defined using the :Ca=: string then sequences for each possible color combination can be given in the :Cb=: string for foreground colors and :Cc=: string for background colors. These strings are accessed by the color codes in the same manner as the :Cp=: string is used for character attributes (see above).

If it is desired that the reverse video attribute merely reverse the foreground and background colors of a character, then include the :Ch: Boolean field.

Finally, some terminal manufacturers treat red and blue backwards. If the red and blue colors seem to be reversed then include the :Ci: Boolean field.