Lugaru's Epsilon
Programmer's
Editor

Context:
Epsilon User's Manual and Reference
   Epsilon Extension Language
      . . .
      Constant Expressions
      Global Definitions
         Key Tables
         Color Classes
         Function Definitions
      Differences Between EEL And C
      . . .

Previous   Up    Next
Key Tables  Epsilon Extension Language   Function Definitions


Epsilon User's Manual and Reference > Epsilon Extension Language > Global Definitions >

Color Classes

color-class-definition:
        color_class  color-class-list  ;
        color_scheme  color-scheme-list  ;

color-class-list:
        color-class-item
        color-class-item  ,  color-class-list

color-class-item:
        identifier
        identifier color_scheme string-constant color-pair
        identifier { color-scheme-spec-list }
        identifier color-pair

color-scheme-spec-list:
        color-scheme-spec
        color-scheme-spec  color-scheme-spec-list

color-scheme-spec:
        color_scheme string-constant color-pair ;

color-scheme-list:
        color-scheme-item
        color-scheme-item  ,  color-scheme-list

color-scheme-item:
        string-constant
        string-constant color_class identifier color-pair
        string-constant { color-class-spec-list }

color-class-spec-list:
        color-class-spec
        color-class-spec  color-class-spec-list

color-class-spec:
        color_class identifier color-pair ;

color-pair:
        = color_class identifier
        constant-expression
        constant-expression on constant-expression

A color class specifies a particular pair of foreground and background colors Epsilon should use on a certain part of the screen, or when displaying a certain type of text. For example, Epsilon uses the color class c_keyword to display keywords in C-like languages. More precisely, the color class specifies which foreground/background pair of colors to display under each defined color scheme. If the user selects a different color scheme, Epsilon will immediately begin displaying C keywords using the c_keyword color pair defined for the new scheme.

Before you use a color class in an expression like set_character_color(pos1, pos2, color_class c_keyword);, you must declare the color class (outside of any function definition) using the color_class keyword:

color_class c_keyword;

When you declare a new color class, you may wish to specify the colors to use for a particular color scheme using the color_scheme keyword:

color_class c_keyword
     color_scheme "standard-gui" black on white;
color_class c_keyword
     color_scheme "standard-color" green on black;

If you have many color definitions all for the same color class, you can use this syntax:

color_class c_keyword {
    color_scheme "standard-gui" black on white;
    color_scheme "standard-color" green on black;
};

Similarly, if you have many color definitions for the same color scheme, you can avoid repeating it by writing:

color_scheme "standard-gui" {
    color_class c_keyword black on white;
    color_class c_function blue on white;
    color_class c_identifier black on white;
};

To specify the particular foreground and background colors for a color class (using the syntax foreground on background), you can use these macros defined in eel.h:

#define black           MAKE_RGB(0, 0, 0)
#define dark_red        MAKE_RGB(128, 0, 0)
#define dark_green      MAKE_RGB(0, 128, 0)
#define brown           MAKE_RGB(128, 128, 0)
// etc.

See that file for the current list of named colors. These functions use the MAKE_RGB() macro, providing particular values for red, green, and blue. You can use this macro yourself, in a color class definition, to specify precise colors:

color_scheme "my-color-scheme" {
    color_class c_keyword MAKE_RGB(223, 47, 192) on yellow;
};

There are several other macros useful in color definitions:

#define MAKE_RGB(rd,grn,bl)  ((rd) + ((grn) << 8) + ((bl) << 16))
#define GETRED(rgb)          ((rgb) & 0xff)
#define GETGREEN(rgb)        (((rgb) >> 8) & 0xff)
#define GETBLUE(rgb)         (((rgb) >> 16) & 0xff)

The GETRED(), GETGREEN(), and GETBLUE() macros take a color expression created with MAKE_RGB( ) and extract one of its three components, which are always numbers from 0 to 255.

The foreground color for a color class may also include font style bits, by or'ing any of the macros EFONT_BOLD, EFONT_UNDERLINED, and EFONT_ITALIC into the color code.

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. The following three examples are all equivalent:

color_class text color_scheme "standard-gui" yellow on red;
color_class c_keyword color_scheme "standard-gui" blue on red;

color_class text color_scheme "standard-gui" yellow on red;
color_class c_keyword color_scheme "standard-gui" blue
    on ETRANSPARENT;

color_class text color_scheme "standard-gui" yellow on red;
color_class c_keyword color_scheme "standard-gui" blue;

The last example works because you may omit the on background part from the syntax foreground on background, and just specify a foreground color. Epsilon interprets this as if you typed on transparent, and substitutes the background color specified for "text".

You can also specify that a particular color class is the same as a previously-defined color class, like this:

color_scheme "standard-gui" {
    color_class text black on white;
    color_class tex_text = color_class text;
};

When, for the current scheme, there's no specific color information for a color class, Epsilon looks for a default color class specification, one that's not associated with any scheme:

color_class diff_added black on yellow;
color_class c_string cyan;
color_class c_charconst = color_class c_string;

The first definition above says that, in the absence of any color-scheme-specific setting for the diff_added color class, it should be displayed as black text on a yellow background. The second says that text in the c_string color class should be displayed using cyan text, on the default background for the scheme (that defined for the text color class). And the third says that text in the c_charconst color class should be displayed the same as text in the c_string color class for that scheme.

Internally, Epsilon stores all color class settings that occur outside any color scheme in a special color scheme, which is named "color-defaults". See Colors for more on colors.



Previous   Up    Next
Key Tables  Epsilon Extension Language   Function Definitions


Lugaru Copyright (C) 1984, 2012 Lugaru Software Ltd. All Rights Reserved.