Lugaru's Epsilon
Editor 14.04

Epsilon User's Manual and Reference
   Primitives and EEL Subroutines
      Buffer Primitives
         Changing Buffer Contents
         Moving Text Between Buffers
         Getting Text from a Buffer
         . . .
         Listing Buffers
      Display Primitives
         . . .
         Character Coloring
         Code Coloring Internals
      File Primitives
         File Reading Primitives
         File Writing Primitives
         Line Translation Primitives
         . . .
         Tagging Internals
      . . .

Previous   Up    Next
Code Coloring Internals  Primitives and EEL Subroutines   File Reading Primitives

Epsilon User's Manual and Reference > Primitives and EEL Subroutines > Display Primitives >


user int selected_color_scheme;
short _our_mono_scheme;
short _our_color_scheme;
short _our_gui_scheme;
short _our_unixconsole_scheme;
short *get_color_scheme_variable()
window short window_color_scheme;
buffer short buffer_color_scheme;

Epsilon stores color choices in color scheme variables. A color scheme specifies the color combination to use for each defined color class.

Epsilon's standard color schemes are defined in the file stdcolor.e. See Color Classes for the syntax of color definitions. You can also create additional color schemes without loading an EEL file by using the new_variable( ) primitive, providing NT_COLSCHEME as the second parameter. Epsilon stores color schemes in its name table, just like variables and commands, so a color scheme may not have the same name as a variable or other name table entry. (Color classes, on the other hand, have their own unique "name space".)

The selected_color_scheme primitive variable contains the name table index of the color scheme to use. Setting it changes the current color scheme. Each time Epsilon starts up, it sets this variable from one of four other variables: _our_gui_scheme under Epsilon for Windows or in Epsilon for Unix under X11, _our_unixconsole_scheme if Epsilon for Unix is running in console mode and the USE_DEFAULT_COLORS environment variable is set (so that Epsilon inherits the colors of its xterm), _our_mono_scheme if Epsilon is running on a monochrome display, or _our_color_scheme otherwise. When you use set-color to select a different color scheme, Epsilon sets one of these variables, as well as selected_color_scheme. The get_color_scheme_variable( ) subroutine returns a pointer to one of these variables, the one containing a color scheme index that's appropriate for the current environment. By default, these four variables refer to the color schemes standard-gui, xterm-color, standard-mono and standard-color, respectively.

If the window-specific variable window_color_scheme is nonzero in a window, Epsilon uses its value in place of the selected_color_scheme variable when displaying that window. Epsilon uses this when displaying borderless windows, so that each window has an entirely different set of color class settings. Also see the variable text_color.

Similarly, if the buffer-specific variable buffer_color_scheme is nonzero in a buffer, Epsilon uses its value instead of either window_color_scheme or selected_color_scheme.

user char monochrome;

The monochrome variable is nonzero if Epsilon believes it is running on a monochrome display. Epsilon tries to determine this automatically, but the -vmono and -vcolor flags override this. See Epsilon Command Line Flags.

set_color_pair(int colorclass, int fg, int bg, ?int scheme)
int get_foreground_color(int colorclass, ?int raw)
int get_background_color(int colorclass, ?int raw)

The set_color_pair( ) primitive lets you set the colors to use for a particular color class within the current color scheme (or, if the optional scheme argument is nonzero, in that scheme). The first parameter is a color_class expression (see Constants and Identifiers); the next two parameters are 32-bit numbers that specify the precise color to use. Use the MAKE_RGB( ) macro to construct suitable numbers. See Color Classes.

The get_foreground_color( ) and get_background_color( ) primitives let you retrieve the colors specified for a given color class. Normally they return a specific foreground or background color, after Epsilon has applied its rules for defaulting color specifications. (See Color Classes.) Specify a nonzero raw parameter, and Epsilon will return the color class's actual setting. It may include one of the bits ETRANSPARENT, ECOLOR_COPY, or ECOLOR_UNKNOWN.

The ETRANSPARENT macro is a special code that may be used in place of a background color. It tells Epsilon to substitute the background color of the "text" color class in the current color scheme. You can also use it for a foreground color, and Epsilon will substitute the foreground color of the "text" color class.

The ECOLOR_UNKNOWN macro in a foreground color indicates there's no color information in the current scheme for the specified color class.

The ECOLOR_COPY macro in a foreground color tells Epsilon that one color class is to borrow the settings of another. The index of the other color class replaces the color in the lower bits of the value; use the COLOR_STRIP_ATTR() macro to extract it.

Regardless of whether the raw parameter is used, a retrieved foreground color may include any of the font style bits EFONT_BOLD, EFONT_UNDERLINED, or EFONT_ITALIC.

When Epsilon looks up the foreground and background settings of a color class, it uses this algorithm.

First it checks if the foreground color contains the ECOLOR_UNKNOWN code. If so, it tries to retrieve first a class-specific default, and then a scheme-specific default. First it looks for that color class in the "color-defaults" color scheme. This scheme is where Epsilon records all color class specifications that are declared outside any particular color scheme. If a particular color pair is specified as a default for that class, Epsilon uses that. If the color class has no default, Epsilon switches to the color class named "default" in the original color scheme and repeats the process.

Either the default setting for the color class or the original setting for the color class may use the ECOLOR_COPY macro. If so, then Epsilon switches to the indicated color class and repeats the above process. In the event that it detects a loop of color class cross-references or otherwise can't resolve the colors, it picks default colors.

Finally, if the resulting foreground or background colors use the ETRANSPARENT bit, Epsilon substitutes the foreground or background color from the "text" color class.

int define_color_class(char *name, b32 fg, b32 bg)

The define_color_class( ) primitive creates a new color class. If name is the name of an existing color class, it simply sets its colors to the specified foreground and background pair, like set_color_pair( ). Otherwise, it creates a new color class by that name, initialized to the specified colors. If name is NULL or "", it creates an anonymous color class. The resulting color class always uses the specified foreground and background colors, and the set-color command can't be used to customize it.

int alter_color(int colorclass, int color)
int rgb_to_attr(int rgb)
int attr_to_rgb(int attr)

The alter_color( ) primitive is an older way to set colors. When the argument color is -1, Epsilon simply returns the color value for the specified color class. Any other value makes the color class use that color. Epsilon then returns the previous color for that color class. (In Epsilon for Windows or under the X11 windowing system, this function will return color codes, but ignores attempts to set colors. Use set_color_pair( ) to do this.)

The colors themselves (the second parameter to alter_color( )) are specified numerically. Each number contains a foreground color, a background color, and an indication of whether blinking or extra-bright characters are desired.

The alter_color( ) function uses 4-bit color attributes to represent colors. The foreground color is stored in the low-order 4 bits of the 8-bit color attribute, and the background color is in the high-order 4 bits. Epsilon uses a pair of 32-bit numbers to represent colors internally, so alter_color( ) converts between the two representations as needed.

The functions rgb_to_attr( ) and attr_to_rgb( ) can be used to perform the same conversion. The rgb_to_attr( ) function takes a 32-bit RGB value and finds the nearest 4-bit attribute, using Epsilon's simple internal rules, while attr_to_rgb( ) converts in the other direction.

int orig_screen_color()

In some environments, Epsilon records the original color attribute of the screen before writing text to it. The orig_screen_color( ) primitive returns this color code. If the restore-color-on-exit variable is nonzero, Epsilon sets the color class it uses after you exit (color_class after_exiting) to this color. See Setting Colors.

int number_of_color_classes()
char *name_color_class(int colclass)

The number_of_color_classes( ) primitive returns the number of defined color classes. The name_color_class( ) primitive takes the numeric code of a color class (numbered from 0 to number_of_color_classes() - 1) and gives the name. For example, if the expression color_class mode_line has the value 3, then the expression name_color_class(3) gives the string "mode-line". It returns NULL for anonymous color classes created by define_color_class( ).

Each window on the screen can use different color classes for its text, its borders, and its titles (if any). When a normal, tiled window is created, Epsilon sets its color selections from the color classes named text, horiz_border, vert_border, and mode_line. When Epsilon creates a pop-up window, it sets the window's color selections from the color classes text, popup_border, and popup_title. See Setting Colors for a description of the other predefined color classes.

user window int text_color;

The text_color primitive contains the color class of normal text in the current window. You can get and set the other color classes for a window using the functions get_wattrib( ) and set_wattrib( ).

Previous   Up    Next
Code Coloring Internals  Primitives and EEL Subroutines   File Reading Primitives

Lugaru Epsilon Programmer's Editor 14.04 manual. Copyright (C) 1984, 2021 by Lugaru Software Ltd. All rights reserved.