You can define a textual region as colored. In a colored textual region, you can specify background and foreground colors for individual characters. For example, you can display a textual region with mostly white text on a blue background, but also with some red text on a black background, some yellow text on a red background, and so on.
The color specifications in the definition are for the background and foreground of the entire region, exactly like an uncolored textual region. The color specifications for individual characters in the region override the color specifications in the definition. You can specify the position and color for characters in two ways:
•For text that already exists in a colored textual region in your program, you use the make segment or make block action statement to specify a character's position or color. (See Coloring Text that Already Exists in the Program)
•For text in an ASCII text file that will be read into the colored textual region, you add a "color header" to the file, and then use the CText module. The CText module reads the information in the color header and applies the specified colors to the individual characters through ESL commands in the module. Both the color header and the text in the ASCII text file can be edited at any time and read into the colored textual region without any changes to the program. (See The CText Module.)
When you assign a color to a character in a colored textual region, the color stays assigned to that character even if the character changes position later on - in other words, the specified color attributes are assigned to the characters, not to the character positions. For example, if text is inserted or deleted during runtime, the displaced characters will retain their colors as originally specified.
All of the drawing and action statements for uncolored textual regions also apply to colored textual regions. For example, you can read and write colored textual regions to and from files. When you write a colored textual region to a file, you can create a regular ASCII text file or a color-attributed file. A color-attributed file is a binary file that assigns color to the text on a character-by- character basis, similar to the way that a word processing program assigns attributes to its text files. Color-attributed files cannot be edited.
Special considerations for colored textual regions are noted in the descriptions for each of the textual region statements in this chapter. (Working with Colored Textual Regions details the use of colored textual regions.) Wherever the words "textual region" are used without being distinguished from colored textual regions, the information applies to both types of textual regions.