Lugaru's Epsilon Programmer's Editor 14.04
Context:
|
Epsilon User's Manual and Reference > Primitives and EEL Subroutines > Display Primitives > Character ColoringYou can set the color of individual characters using the set_character_color( ) primitive. At first glance, this feature may seem similar to Epsilon's mechanism for defining highlighted regions. Both let you specify a range of characters and a color to display them with. But each has its own advantages.Region highlighting can highlight the text in different ways: as a rectangle, expanded to entire lines, and so forth, while character coloring has no similar options. You can define a highlighted region that moves around with the point, the mark, or any other spot. Character coloring always remains with the characters. But when there are many colored regions, using character coloring is much faster than creating a corresponding set of highlighted regions. If you define more than a few dozen highlighted regions, Epsilon's screen refreshes will begin to slow down. Character coloring, on the other hand, is designed to be very fast, even when there are thousands of colored areas. Character coloring is also easier to use for many tasks, since it doesn't require the programmer to allocate spots to delimit the ends of the colored region, or delete them when the region is no longer needed.
One more difference is the way you remove the coloring. For
highlighted regions, you can turn off the coloring temporarily by
calling modify_region( ), or eliminate the region entirely by
calling remove_region( ). To do either of these, you must supply
the region's handle, a value returned when the region was first
created. On the other hand, to remove character coloring, you can
simply set the desired range of characters to the special color
Epsilon's code coloring functions are built on top of the character coloring primitives described in this section. See the next section for information on the higher-level functions that make code coloring work.
A color class of When you insert text in a buffer, it takes on the color of the character immediately after it, or in the case of the last character in the buffer, the character immediately before it. Characters inserted in an empty buffer are initially uncolored. Copying text from one buffer to another does not automatically transfer the color; Epsilon treats the new characters the same as any other inserted text. You can use the buf_xfer_colors( ) subroutine to copy text from one buffer to another and retain its coloring. See Moving Text Between Buffers. Epsilon maintains the character colors set by this primitive independently of the highlighted regions created by add_region( ). The modify_region( ) primitive will never change what get_character_color( ) returns, and similarly the set_character_color( ) primitive never changes the attributes of a region you create with add_region( ). When Epsilon displays text, it combines information from both sources to determine the final color of each character. When displaying a buffer, Epsilon uses the following procedure when determining which color class to use for a character:
Next, Epsilon chooses a color class from the list:
Notice that when a region using the
You can also use the primitive to determine the extent of a range of
characters all in the same color. If the optional pointer parameters
Also see the similar get_character_syntax_color( ) subroutine, which returns a character's color after applying the buffer's syntax highlighting rules.
Each set of attributes consists of a tag (a unique
string like
The set_tagged_region( ) primitive sets the attribute of the
characters in the range
The get_tagged_region( ) primitive gets the attribute of the
character at position
Epsilon's character color primitives set_character_color( ) and
get_character_color( ) use a built-in tagged region with a tag name of
|