Colors, Color Coding, and Symbol Colors

SlickEdit Core provides a great deal of control over the colors in the editor, using two complimentary coloring systems. With Color Coding you can color your code based on syntactic information about the elements: keywords, strings, operators, etc. Using Symbol Coloring, you can definie rules to color symbols based on scope, visibility, and other detailed properties. Symbol Coloring provides more detailed information for identifiers that would otherwise be colored the same using Color Coding.

Note

Colors for the SlickEdit Core application window are controlled by the operating system. This includes the font and background color for views and dialogs. The colors in editor windows are controlled by SlickEdit Core.

This section is divided into the following subsections:

Colors

Use the Colors option screen ( Window → SlickEdit Preferences → Appearance → Colors or the color command) to set the color for different screen elements in SlickEdit Core. This includes syntactic elements in the editor window, like keywords, comments, strings, etc. as well as other user interface elements like the message area or the status line. Window colors and backgrounds are set using the facilities provided by the operating system.

Setting Colors for Screen Elements

Colors can be set either individually or by editing a scheme. To change the default colors, complete the following steps:

  1. From the main menu, click Window → SlickEdit Preferences → Appearance → Colors (or use the color command). The Colors option screen is displayed.

  2. Select the element you want to change from the list of customizable items. The items are categorized by their purpose. For descriptions of the individual color elements, see Color Options).

    Tip

    The element selected in the list matches the symbol at the cursor position when this screen was opened. You can use this to determine what kind of symbol SlickEdit Core thinks it is. If you're not sure which screen element to pick, close the options screen and put the cursor in the symbol you want to color, and then reopen the options screen.

    Note

    If you have chosen the Selection or Current line screen element, note that SlickEdit Core will attempt to render the text using your normal color settings for the Foreground color. The selected foreground color will only be used if there is not enough contrast between the foreground color for the underlying text element and selected background color to be readable. It is best to specify a Background color for selections that is as close as possible to your normal background color, ensuring that the color-coded text is still easy to read.

  3. Set the Foreground and Background colors by clicking on the color squares. The Color Picker dialog is displayed, allowing you to pick a color from the palette, or set your own custom color using RGB values.

    Note

    Several colors for syntactic screen elements such as comments, keywords, and numbers inherit their background color information from the Window Text color. This allows you to change the background color for an entire color scheme merely by changing the background color for Window Text.

  4. If you want, choose a Font Style for the text.

For a complete list of all of the options available, see Color Options.

Using Color Schemes

Color schemes store the settings for all screen elements, allowing you to quickly change the look of your editing environment. Several predefined color schemes are provided, and you can create your own.

To use a color scheme, from the Scheme drop-down, select a color scheme and click Apply or OK.

To define a new color scheme, set your colors for the various screen elements and click Save Scheme. User-defined color schemes are stored in the uscheme.ini file located in your configuration directory. You can change the name of a scheme by clicking Rename Scheme.

Setting an Embedded Language Color

Colors for editor screen elements also have an embedded background color. This color is used as the background when in embedded code. It is best to select an embedded background color that is only a slight tint from your standard background color. This makes it easier to select common foreground colors that will display with enough contrast in both embedded and normal code.

Embedded Language color is used when a file of one type embeds a language of another type within it, like HTML files containing JavaScript. For HTML, the syntax color coding recognizes the <script language="???"> tag and uses embedded language colors for the new language. In addition, for Perl and UNIX shell scripts, you can prefix your here-document terminator with one of the color coding lexer names to get embedded language color coding. The following is an example for Perl:

Symbol Coloring

Use the Symbol Coloring options screen (Window → SlickEdit Preferences → Appearance → Symbol Coloring to set the color for symbols identified by Context Tagging®. This includes function declarations, function definitions, variables, class names, package names, type names, defines, enumerated types, constants, as well as undefined symbol names.

Note

Symbol Coloring is turned off by default. Symbol Coloring can be enabled on a per-language basis by going to Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → View and checking Symbol Coloring. You can also enable Symbol Coloring for a specific file by selecting Display → Symbol Coloring → Enable Symbol Coloring. This will override the language specific setting, but only for the current file.

Symbol Coloring is different from Color and Color Coding. The base color scheme, along with the Color Coding lexer, are used to identify and color lexical elements found in source code, such as comments, strings, numbers and keywords. Symbol coloring augments the base coloring by overlaying additional color information for identifiers based on the corresponding symbol's name, type, and attributes. This allows you to define symbol coloring rule sets for focusing in on certain symbols or groups of symbols. It also makes it easier to distinguish between different symbol types, such as local variables and constants. See Color Coding and Colors for more information about lexical color coding and color configuration.

When you point at a symbol with the mouse cursor, SlickEdit Core displays a pop-up that includes information from Symbol Coloring about what rule was applied. If that symbol is not colored by Symbol Coloring, no information about the symbol color will be displayed in the pop-up.

Symbol Coloring under some circumstances can cause SlickEdit Core to pause momentarily while you type. If you experience these pauses, please turn off Symbol Coloring by unchecking Display → Symbol Coloring → Enable Symbol Coloring which will turn off symbol coloring for the current file. If these pauses happen in all files for that language, you can turn Symbol Coloring off for that language by going to Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → View and unchecking Symbol Coloring.

Note

The standard symbol coloring schemes shipped with SlickEdit® Core are very thorough and attempt to assign a color to nearly every symbol type. While this is useful, it may be more information that is necessary. The schemes are this way because it is easier to edit or remove rules than it is to add new rules or create a new scheme from scratch. You can use the standard symbol coloring schemes as templates that you prune down to create your own, more focused, symbol coloring schemes suiting your specific needs.

Symbol Coloring can be used to highlight unidentified symbols. These are symbols for which the SlickEdit Core Context Tagging engine can not find a definition. If you are working without a workspace or your libraries are not fully tagged, you would see a lot of unidentified symbols. Because of this, the capability to highlight unidentified symbols is turned off by default, even if you enable Symbol Coloring. To enable highlighting of unidentified symbols, select Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → View and put a check in Highlight unidentified symbols. The Symbol coloring checkbox must be checked for this control to become active.

Symbol Coloring Schemes

A symbol coloring scheme is a set of rules defining what color to assign to a symbol with a specific name, type, and attributes. You can think of a scheme as a colored lens for looking at your code that highlights the specific symbols you are interested in. Since you can quickly switch symbol coloring schemes, it is very easy to use a special lens for specific tasks, like refactoring out global variables or identifying where your code uses preprocessing.

A symbol coloring rule consists of the following elements:

  • A Rule name.

  • Symbol types -- A matching symbol's type must be one of the specified types. The special *SYMBOL NOT FOUND* type is used to identify symbols which Context Tagging® can not locate. See Symbol types for detailed descriptions of each symbol type.

  • Symbol attributes -- The attributes can be either required, ignored, or disallowed. A matching symbol must have all the required attributes, and none of the disallowed attributes. See Symbol attributes for detailed descriptions of each symbol attribute.

  • Class name -- A matching symbol must belong to a class matching the regular expression.

  • Symbol name -- A matching symbol's name must match the regular expression.

  • Color and font attributes -- The color definition includes foreground color, background color, and font attributes. This is the color the symbol will be highlighted using. A color definition can base it's color on another rule, for example, in order to inherit background color and font attributes for consistency.

Symbol coloring rules are matched in order from the top to bottom of the list of rules in the symbol coloring scheme. For a symbol to match a rule, it must be the first rule in the symbol coloring scheme that matches all of the requirements above.

Unidentified Symbols

An unidentified symbol is one for which the context tagging engine cannot locate the type information. This could be because the code is incomplete, the source file for that definition has not been tagged or is out of date, or the definition wasn't located before a specified timeout or limit was hit. We use the term "unidentified" instead of "undefined" because the symbol may be defined even though the tagging engine doesn't know it. Unidentified symbols are found using the *SYMBOL NOT FOUND* symbol type.

Symbol Coloring contains a scheme, Unidentified Symbols Only, that can be used to spot these symbols. You can select that scheme via the Symbol Coloring options page, Window → SlickEdit Preferences → Appearance → Symbol Coloring. You can also select that scheme from the View menu, Display → Symbol Coloring → Unidentified Symbols Only. Lastly, you can toggle the view of unidentified symbols from the view menu using Display → Symbol Coloring → Highlight Unidentified Symbols This will work with any scheme, even if it doesn't contain a rule for unidentified symbols.

Color Scheme Compatibility

Symbol coloring augments the standard lexical color coding for keywords, comments, strings, numbers, and other items. Since the symbol colors will be overlayed and typically inherit background color information from the base color scheme, it is important for the selected foreground color to be chosen such that the symbol name is still visible and readable against the editor window background.

The standard symbol coloring schemes shipped with SlickEdit Core are marked with the standard base color schemes they are compatible with. Some schemes, such as Protected and Private are compatible with all color schemes. Others are fine-tuned to work best against a dark background, a light background, or a specific color scheme. User-defined color schemes can specify which base color schemes they work best with.

In addition, each base color scheme has a designated, default symbol coloring scheme preferred for that scheme. This allows you to switch color schemes and automatically get a corresponding symbol coloring scheme which is compatible. See Colors for more information.

Selecting a Symbol Coloring Scheme

Symbol coloring rules can be set either individually or by editing a scheme. To change the default symbol coloring scheme, complete the following steps:

  1. From the main menu, click Window → SlickEdit Preferences → Appearance → Symbol Coloring. The Symbol Coloring options screen is displayed.

  2. Using the Scheme combo box, select a scheme name. If your current scheme is modified, those modifications will be automatically saved to that scheme. If you select a scheme which is incompatible with your current base color scheme, you will be prompted to confirm that you really want to use the selected color scheme. See Color Scheme Compatibility for more information.

  3. The list of rules will be shown for the selected symbol coloring scheme. You can get a quick overview of the scheme from the list and see detailed information about each rule by selecting the rule.

  4. Press OK or Apply to commit the changes. The change will be applied to all open files using the default symbol coloring scheme.

Editing a Symbol Coloring Scheme

To edit the current symbol coloring scheme, from the main menu, click Window → SlickEdit Preferences → Appearance → Symbol Coloring. The Symbol Coloring options screen is displayed.

Select a rule from the list of rules. Note that the rule list not only displays the name of the rule, but also a brief summary of the rule settings. You can add a new rule after the currently selected rule by clicking on the plus icon. Likewise, you can remove the current rule by clicking on the delete icon. Rules can be moved up or down in the rule order by clicking on the up or down arrows.

See Color Rules for detailed descriptions of each of the standard symbol coloring rules shipped with SlickEdit® Core.

The current rule can be renamed by clicking in the text box under Rule name, modifying the name, then hitting Enter .

The display color and font choices for a rule allow you to inherit color and font information from another rule or from certain items from the base color scheme. By default a rule will inherit from the Window Text color defined in your base color scheme.

Set the Foreground and Background colors by clicking on the color squares. The Color Picker dialog is displayed, allowing you to pick a color from the palette, or set your own custom color using RGB values. You can also select Inherit in order to specify that the rule use the same color as it's parent rule. Set the font attributes by clicking on Normal, Bold, Italic, or Underline. Select Inherit Font to specify that the rule should use the same font attributes as it's parent rule.

Select a set of symbol types from the list of symbol types supported by the Context Tagging® engine. A symbol must be one of the selected symbol types in order to match the rule. You can select as many symbol types as you want. Select the special *SYMBOL NOT FOUND* symbol type to define a rule for what to do with symbols that could not be found using Context Tagging®.

Caution

Not all symbol types apply to every language.

Symbol attributes can have three states. The default state is a grayed state which says we don't care if this attribute is set or not for this rule. If an attribute is checked, it must be set in the matching symbol.

Note

If an attribute is unchecked, it must not be set. Some attributes, such as Public, Protected, and Private, are mutually exclusive by nature. If you configure a rule that checks both Public and Private, that rule will never be matched. You should instead either define two rules, or one rule with Protected and Package unchecked.

In addition to the symbol type and attribute specifications, you can further refine a symbol coloring rule by adding a Class name or Symbol name regular expression, using the regular expression syntax of your choice. The class name regular expression is matched against the name of the scope (class, package, struct) which a symbol is defined in. Do not confuse this with the name of the scope in which the symbol is used. The symbol name regular expression is matched against the name of the symbol. For example, a Wildcards expression of "vs*" would match all symbols starting with the characters "vs". Case sensitivity for the regular expression matching is regulated by the language's case-sensitivity. See Color Coding for more information.

Creating a New Symbol Coloring Scheme

New symbol coloring schemes can be created by selecting an existing scheme and adding or subtracting rules, then saving the scheme under a new name. To create a new symbol coloring scheme from scratch, start with the None scheme and then add your own custom rules.

Selecting a Symbol Coloring Scheme for the Current File

From the main menu, click Display → Symbol Coloring This will bring up the Symbol Coloring view menu.

The menu will list only symbol coloring schemes known to be compatible with the current base color scheme. Select a scheme to switch to that scheme for the current file. Select the (None) scheme to disable symbol coloring for the current file.

Selecting a specific scheme for the current file will not change the symbol coloring scheme for any other files, nor will it change the default symbol coloring scheme. The selected symbol coloring scheme will be saved in your file history so that the next time you open that file, it will return to using the same symbol coloring scheme you selected, as long as your base color scheme does not change.

Language-Specific Symbol Coloring Settings

Certain Symbol Coloring features can be disabled on a per-language basis. To edit language-specific symbol coloring options, from the main menu, click Window → SlickEdit Preferences → Languages → [Language Category] → [Language] → View. The Language View options are displayed.

From this dialog, you can configure the following on a per-language basis.

  • Turn off Symbol Coloring entirely for the language. This would be a good idea if symbol analysis was particularly slow or ineffective for a language, such that symbol coloring was only slowing you down.

    Note

    Symbol coloring is automatically disabled for HTML and other XML variants. It is also automatically disabled in all modes which do not have any Context Tagging® implemented. Finally, Symbol Coloring is disabled in all embedded language contexts. This means that Symbol Coloring is disabled for all PHP code, since PHP is always embedded in an HTML or XML processing instruction ( <?php ).

  • By default, Symbol Coloring will bold the name part of symbol declarations and definitions. This is particularly useful for languages which allow implicit local variable declarations. It is also helpful when the declaration syntax is not always visually distinct from the rest of the code. This bolding behavior can be turned off by unchecking Use bold for symbol names in definitions and declarations.

  • Symbol Coloring is able to select the Symbol not found rule for symbols with are not found by Context Tagging®. This can serve effective as a live error checker with respect to spelling and capitalization of symbols.

    However, in certain languages, especially scripting languages that allow variables to be declared implicitly, Context Tagging® can be rather ineffective, simply because the code can not be analyzed statically. In this case, you might see an unusually large number of symbols highlighted as unidentified symbols. This can also happen if you do not have Context Tagging® configured correctly for the code and libraries you are working with.

    For this reason, this feature is disabled by default. You can enable highlighting of unidentified symbols by checking Highlight unidentified symbols.

  • By default, Symbol Coloring uses fairly strict language specific symbol lookups in order to identify symbols. In some languages, it is necessary to relax the rules in order to find symbol definitions. This can, for example, be useful in heavily templated or preprocessed C++ code which is too complex for Context Tagging®. Unchecking Use strict symbol lookups will tell Symbol Coloring to revert to a simple, symbol name lookup, ignoring scope and visibility rules, if the strict symbol lookup does not yield results.

Symbol Coloring Performance Settings

Symbol Coloring requires the editor to do symbol lookup and analysis for every symbol visible on the current page of the current file. This can be expensive, especially for extremely large files or large, complex code bases. Because of this, it attempts to only color the symbols which are currently visible, not the entire file. Furthermore, instead of immediately painting like basic syntax driven color coding does, symbol coloring works on a delay timer. This way you should never have to wait for symbol coloring to finish working except under extreme circumstances. Besides coloring the current page, symbol coloring will also look ahead slightly to surrounding lines. This makes it possible, in the typical case, to page up one page and not have to wait for symbol coloring to draw because the information was already prefetched.

Caution

For typical users, the default performance settings will be good enough. Tinkering with these settings without regard to the implications could result in very poor performance and/or annoying drawing behavior.

Symbol Coloring performance can be fine-tuned through the user interface. To edit symbol coloring performance options, from the main menu, click Window → SlickEdit Preferences → Editing → Context Tagging. The Context Tagging® options are displayed.

From this dialog, you can configure the following settings.

  • Update after (ms) idle -- This is the amount of idle delay symbol coloring should wait before updating the Symbol Coloring for the current page. Increasing this value can prevent interruptions to your normal typing due to symbol coloring updating, however, it will cause symbol coloring updates to lag further behind your editing. Decreasing this value too much can have the effect of making symbol coloring updates behave nearly synchronously and can create very bad editor response times. A good setting is four times your average keypress gap, which you can estimate by looking at how many words per minute you type when coding.

  • Timeout after (ms) -- This the maximum amount of time that symbol coloring should spend trying to do symbol analysis before giving up and trying to finish in the next pass. Increasing this time can cause increased intrusiveness. Decreasing this time too much can cause symbol coloring to not have enough time to paint the entire page. As a result, you would see lines get colored as symbol coloring makes subsequent passes to finish coloring the page.

  • Number of lines to color above and below the current page -- This is the amount of prefetch symbol coloring should do for pages surrounding the current visible page of code. Setting this very high can have the effect of forcing symbol coloring to color the entire file in one shot. Setting it to 0 will force symbol coloring to only color the visible page and not do any prefetch at all.

  • Number of off-page lines to color per pass (chunk size) -- When prefetching symbol coloring for off-page lines, this is the number of lines to prefetch per pass. Setting this to a large number can make symbol coloring performance more intrusive. Setting this to a small number, such as 1, will force symbol coloring to make many passes before it can color all the off-page lines it is supposed to. As a result, a Page Up might reveal a page which is only partially colored.

Color Coding

For information on how to set up colors for various entities in the editor, see Colors This section describes how to configure the Color Coding engine, which identifies entities to color.

Adding Color Coding Keywords to Supported Languages

To add color-coded keywords to a supported language, complete the following steps:

  1. From the main menu, click Window → SlickEdit Preferences → Languages, expand your language category and language, then select Color Coding.

  2. Click New.

  3. Enter the new keywords separated with a space character.

  4. Click OK.

  5. Click OK on the Color Coding options screen.

For more information, see Color Coding Configuration.

Creating Color Coding for a New Language

To create color coding support for your language, complete the following steps:

  1. From the main menu, click Window → SlickEdit Preferences → Languages, expand your language category and language, then select Color Coding.

  2. Select the Color Coding Tokens Tab , then click New. The Enter New Keywords dialog box is displayed.

  3. Enter the new lexer name. Usually this is a language name such as C or Java. Click OK.

  4. On the Tokens tab, make sure the new keyword is selected, then correct the ID start characters. These are valid characters which can be the start of an identifier.

  5. Correct the ID follow characters. These are additional characters which are valid after the start ID character. For example, digits are usually allowed in identifiers, but not as the first character of an identifier.

  6. Select the Color Coding Comments Tab . This lists the comments currently defined and allows you to define new multi-line and line comments. For each comment, click New to add a line or multi-line comment.

  7. Select the Color Coding Numbers Tab to display various numeric style options.

  8. Select the Color Coding Strings Tab to display various string literal options.

  9. If you have not found all the options you need, click the Color Coding Language Tab. This displays even more advanced language-specific options.

  10. Click OK on the Color Coding options screen.

Color Coding Configuration

To configure color coding, from the main menu, click Window → SlickEdit Preferences → Languages, expand your language category and language, then select Color Coding. This screen lets you change the list of tokens and other information that is color coded in the editor. The options on each tab are described in the section, Language-Specific Color Coding Options.

Click Colors at the bottom of the dialog to display the Color Settings dialog, which allows you to specify the color for color coding elements and other editor elements (see Setting Colors for Screen Elements).

Advanced Color Coding Configuration

The vslick.vlx file defines language-specific coloring support. For information about modifying this file, and how to create a new lexer name, see VLX File and Color Coding.