Syntax Highlighting

<< Click to Display Table of Contents >>

Navigation:  Reference > Workspace, Toolbars and Dialogs > The Write Tab > Font >

Syntax Highlighting

This menu option applies highlights program code text to make it easier to read. A number of programming languages are supported, and you can customize the highlighting styles for each program language.

For more details see Formatting program source code.

Options for predefined languages

This dialog is displayed when you select Format > Syntax Highlighting > Customize. The following options are available when you select one of the predefined languages:

DLG_HighlighterCustomize  

Format with style:

The basic appearance of all text formatted with the Syntax Highlighting function is controlled by the standard Code Example style. This is the currently only style you can use for syntax highlighting.

BTN_EditStyle

Opens the Edit Styles dialog to edit the Code Example style.

Elements:

Settings for defining the color and font styles of the various elements highlighted by the function.

Format with soft breaks:

Use soft line breaks instead of paragraphs for code examples. This can be necessary to get the desired results in some cases.

Reset defaults:

Resets all settings for the current language to the default values. This also replaces any reserved words you have loaded.

Additional options for custom highlighters

If you select one of the three custom highlighters at the bottom of the list you have the following additional options for defining your own language highlighting rules:

Quotes:

Specify whether single or double quotes are to be identified as quotes.

Identifiers:

The relevant characters that are allowed in identifiers for the language you are using. This should normally be set to A-Za-z0-9, and/or an explicit list. Identifiers are all special words used in the language.

Sequential character classes are identified with the beginning and end characters linked with a dash (0-9), otherwise you just enter explicit characters. For example, if you want to include the $ and _ characters as well as alphanumeric characters, you would enter:

0-9a-zA-Z$_

Don't use commas or spaces!

That would include the comma and space characters as identifiers. Then "ERROR,LIST" and "ERROR LIST" would both be identified as a single keyword.

Include all the characters you use in your list!

You should include all the characters that can appear in variables and keywords in your identifiers character list. For example, if you include the underscore character in your variable names, you must also include it in your identifiers list. If you don't, the characters between underscores will be identified as a separate word.

How the identifier characters are used

Only words that contain only the characters listed in the Identifiers list will be checked. If the word is in the list of reserved words it will get the reserved words formatting. If it is not, it will get the identifiers formatting.

A different category will be applied if a word does not consist of the identifier characters, or if it is covered by another rule (Number, Comment, String etc).

Comments:

The commenting style used. You can currently only choose between a list of preset commenting styles, but this should cover most needs.

Edit reserved words:

Create and edit a list of reserved words for your custom language. You can paste lists of words into the editing dialog. Only the characters you define in the Identifiers setting can be included in your reserved words. If the words include other characters they will be ignored by the highlighter.

See also:

Formatting program source code