5250 colors and display attributes
The IBM 5250 data stream was devised in the 1970's. Color was not thought of, even though color displays were well known for a long time from TV. After the later introduction of color displays for computer terminal screens, already established display attributes were reused for indicating which color something on the screen should have.
Display attributes include properties like e. g. "bright" (high intensity), underlined, blinking, and column separators[1] for elements and text on screen.
Display attributes are encoded in a single, otherwise invisible screen position directly preceding the screen element(s) the attribute is applied to.[2] This attribute byte can be modified with the DDS keywords COLOR and DSPATR and indicators. Since indicators are limited in count, conditionally applying many attributes to many screen objects can quickly exhaust the number of available indicators for a given screen (record format).[3]
Attributes
The basic display attributes are specified as follows. Bits counted from right to left (LSB to MSB)!
Bit | Attribute (DSPATR-Name) |
---|---|
0 | Reverse Image (RI) |
1 | High Intensity (HI) |
2 | Underline (UL) |
3 | Blink (BL) |
4 | Column separator (CS) |
5 | Always 1 |
6 | Always 0 |
7 | Protect (PR) |
Attribute to color mapping
As stated, color was introduced later. Hence, display attribute bits have been reused for setting color:
- Blink = Red
- Column separator = Turquoise (cyan)
- High intensity = White
Further colors can be displayed by combining bits 1, 3, and 4:
- Blink, column separator = Pink (magenta)
- Blink, column separator, high intensity = Blue
- Column separator, high intensity = Yellow
Normally, you don't need to memorize all of that, but just use the DDS COLOR(xxx) keyword to enable the available colors:
Desired color | DDS COLOR statement | equivalent DDS DSPATR statement |
---|---|---|
Black | DSPATR(ND) | |
White | COLOR(WHT) | DSPATR(HI) |
Red | COLOR(RED) | DSPATR(BL) |
Green | COLOR(GRN) | |
Blue | COLOR(BLU) | DSPATR(BL CS HI) |
Yellow | COLOR(YLW) | DSPATR(CS HI) |
Pink (magenta) | COLOR(PNK) | DSPATR(BL CS) |
Turquoise (cyan) | COLOR(TRQ) | DSPATR(CS) |
All but black can be combined with the Reverse Video (RI) attribute to have black letters on colored background.[4]
Depending on the settings of the used color display terminal or emulator, attributes and color might be shown concurrently. This is most apparent when setting the color of an input capable field to cyan, and the result not only is cyan, but also looks weird, due to column separators being displayed. Most display terminals or emulators have a configuration setting to only show colors and not apply attributes being reused for specifying color.[5]
Table of valid attribute byte values
Hex | Binary | Color | Attribute(s) | Screen appearance |
---|---|---|---|---|
0x20 | 0b00100000 | GRN | Green | |
0x21 | 0b00100001 | GRN | RI | Green, reverse image |
0x22 | 0b00100010 | WHT | White | |
0x23 | 0b00100011 | WHT | RI | White, reverse image |
0x24 | 0b00100100 | GRN | UL | Green, underline |
0x25 | 0b00100101 | GRN | UL RI | Green, underline, reverse image |
0x26 | 0b00100110 | WHT | UL | White, underline |
0x27 | 0b00100111 | ND | Nondisplay | |
0x28 | 0b00101000 | RED | Red | |
0x29 | 0b00101001 | RED | RI | Red, reverse image |
0x2a | 0b00101010 | RED | HI | Red, high intensity |
0x2b | 0b00101011 | RED | HI RI | Red, reverse image, high intensity |
0x2c | 0b00101100 | RED | UL | Red, underline |
0x2d | 0b00101101 | RED | UL RI | Red, unline, reverse image |
0x2e | 0b00101110 | RED | UL BL | Red, underline, blink |
0x2f | 0b00101111 | RED | ND | Nondisplay |
0x30 | 0b00110000 | TRQ | CS | Turquoise, column separator |
0x31 | 0b00110001 | TRQ | CS RI | Turquoise, column separator, reverse image |
0x32 | 0b00110010 | YLW | CS | Yellow, column separator |
0x33 | 0b00110011 | WHT | RI CS | White, reverse image, column separator |
0x34 | 0b00110100 | TRQ | UL CS | Turquoise, underline, column separator |
0x35 | 0b00110101 | TRQ | UL RI CS | Turquoise, underline, reverse image, column separator |
0x36 | 0b00110110 | YLW | UL CS | Yellow, underline, column separator |
0x37 | 0b00110111 | ND | Nondisplay | |
0x38 | 0b00111000 | PNK | Pink | |
0x39 | 0b00111001 | PNK | RI | Pink, reverse image |
0x3a | 0b00111010 | BLU | Blue | |
0x3b | 0b00111011 | BLU | RI | Blue, reverse image |
0x3c | 0b00111100 | PNK | UL | Pink, underline |
0x3d | 0b00111101 | PNK | UL RI | Pink, underline, reverse image |
0x3e | 0b00111110 | BLU | UL | Blue, underline |
0x3f | 0b00111111 | ND | Nondisplay | |
0xa0 | 0b10100000 | GRN | PR | Green, protected |
0xa1 | 0b10100001 | GRN | PR RI | Green, protected, reverse image |
0xa2 | 0b10100010 | WHT | PR | White, protected |
0xa3 | 0b10100011 | WHT | PR RI | White, protected, reverse image |
0xa4 | 0b10100100 | GRN | PR UL | Green, protected, underline |
0xa5 | 0b10100101 | GRN | PR UL RI | Green, protected, underline, reverse image |
0xa6 | 0b10100110 | WHT | PR UL | White, protected, underline |
0xa7 | 0b10100111 | ND PR | Nondisplay, protected | |
0xa8 | 0b10101000 | RED | PR | Red, protected |
0xa9 | 0b10101001 | RED | PR RI | Red, protected, reverse image |
0xaa | 0b10101010 | RED | PR HI | Red, protected, high intensity |
0xab | 0b10101011 | RED | PR HI RI | Red, protected, reverse image, high intensity |
0xac | 0b10101100 | RED | PR UL | Red, protected, underline |
0xad | 0b10101101 | RED | PR UL RI | Red, protected, unline, reverse image |
0xae | 0b10101110 | RED | PR UL BL | Red, protected, underline, blink |
0xaf | 0b10101111 | ND PR | Nondisplay, protected | |
0xb0 | 0b10110000 | TRQ | PR CS | Turquoise, protected, column separator |
0xb1 | 0b10110001 | TRQ | PR CS RI | Turquoise, protected, column separator, reverse image |
0xb2 | 0b10110010 | YLW | PR CS | Yellow, protected, column separator |
0xb3 | 0b10110011 | WHT | PR RI CS | White, protected, reverse image, column separator |
0xb4 | 0b10110100 | TRQ | PR UL CS | Turquoise, protected, underline, column separator |
0xb5 | 0b10110101 | TRQ | PR UL RI CS | Turquoise, protected, underline, reverse image, column separator |
0xb6 | 0b10110110 | YLW | PR UL CS | Yellow, protected, underline, column separator |
0xb7 | 0b10110111 | ND PR | Nondisplay, protected | |
0xb8 | 0b10111000 | PNK | PR | Pink, protected |
0xb9 | 0b10111001 | PNK | PR RI | Pink, protected, reverse image |
0xba | 0b10111010 | BLU | PR | Blue, protected |
0xbb | 0b10111011 | BLU | PR RI | Blue, protected, reverse image |
0xbc | 0b10111100 | PNK | PR UL | Pink, protected, underline |
0xbd | 0b10111101 | PNK | PR UL RI | Pink, protected, underline, reverse image |
0xbe | 0b10111110 | BLU | PR UL | Blue, protected, underline |
0xbf | 0b10111111 | ND PR | Nondisplay, protected |
Arithmetics of attributes
Because the meaning of attributes or color is well defined, many lines of IF or SELECT statements in RPG can possibly be substituted by simple arithmetics, like additions and bit operations.
Examples:
Base value is always 0x20.
- To have a field displayed in reverse image, add 1,
- to have a field displayed in red, add 8,
- etc.
Weblinks
- COLOR (Color) keyword for display files, IBM DDS reference
- DSPATR (Display Attribute) keyword for display files, IBM DDS reference
- IBM 5250, Wikipedia
- Condition display fields without indicators, rpmpgm.com
Footnotes
- ↑ That was was thought as an aid to precisely know where characters were placed in an on-screen editable field. Appearing somewhat confusing to the common eye, real word usage was probably not very widespread.
- ↑ The DDS logic takes care to switch off set attributes after a screen element's end.
- ↑ It should be noted that in a subfile, each record has an independent set of indicators.
- ↑ This should be used sparsely, because it's very eye straining.
- ↑ Due to reusing of attribute bits, changing this setting disables the display of color-mapped attributes globally. You can't then display one field with e. g. column separators. Instead, the field is then colored cyan.