The ESL language supports a special type of text file for display in textual regions with the 'colored' attribute. The 'colored' attribute is stored in colored textual regions with each character so that each can have a unique foreground and background color. This feature combined with the built-in functions xcoord, ycoord, foreground of, and background of can be combined creatively to support selectable text fields within a textual region.
The action statement
will write a colored textual region to a file with the colored attributes. This can then be read back in, and the colors will be as they were when written.
The CTEXT module provides an indirect method of storing color information in the header of the text file for interpretation at runtime. However a more direct (and undocumented) method is to write the file directly (e.g. with a C program). Here is how ESL colored textual region files are stored:
The first byte in the file is the character, the next 4 bits (or high order nibble of the second byte) is the background color, and the last 4 bits are the foreground color.
The color attributes stored in the file are not the same as the ESL color values.
ESL Color Name |
ESL Color Number |
Text file color Attribute |
red |
1 |
4 |
green |
2 |
2 |
yellow |
3 |
6 |
blue |
4 |
1 |
purple/magenta |
5 |
5 |
cyan/aqua |
6 |
3 |
white |
7 |
7 |
black |
8 |
0 |
To create a colored text file containing a blue character "X" with a white background, the first byte in the file would be the character "X". The second byte in the file would be 0x71. Seven (7), the high order nibble, corresponds to the white background and one (1) corresponds to the blue foreground.