Adding Language Support. 1: Syntax Highlighting

Home Forums General Test Me Adding Language Support. 1: Syntax Highlighting

This topic contains 0 replies, has 6,462 voices, and was last updated by  deleyd 10 years, 11 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #2007

    deleyd
    Participant

    Adding Language Support. 1: Syntax Highlighting

    COLOR SETUP DIALOG
    First become familiar with the COLOR SETUP dialog.

    TOOLS -> CUSTOMIZE -> General(left side) -> COLOR SETUP (right side)

    Click on HELP in that dialog and read all about the COLOR SETUP dialog.

    Also look up COLORS in the index of the Multi-Edit User’s Guide and read what it has to say there about the Color Setup Dialog. Be sure to try out all the different Color Templates (upper left of the Color Setup dialog).

    In the COLOR SETUP dialog scroll down the listbox on the left side until you come to the Syntax Highlighting section. There is a direct correspondence between items here and items in the Language Setup dialog.

    Note the entries are:
    Reserved Words 1
    Reserved Words 2
    Reserved Words 3
    Reserved Words 4
    Symbol Text
    Brackets
    EOL Comment 1
    EOL Comment 2
    EOL Comment 3
    EOL Comment 4
    Open/Close Comment 1
    Open/Close Comment 2
    Numeric Text
    String Text


    Brief Overview of Setting Colors
    Select an item in the list, such as Reserved Words 1.[list:s2tjdtso][*:s2tjdtso]The text color is the foreground color (FG). To set the foreground color select one of the Basic Colors or Custom Colors with the mouse and left-click.
    [/*:m:s2tjdtso]
    [*:s2tjdtso]To highlight text set the background color (BG). To set the background color select one of the Basic Colors or Custom Colors with the mouse and right-click. (For no highlighting set the background color to be the same as the background color for ‘Normal Text’, which is at the very top of the list.)
    [/*:m:s2tjdtso]
    [*:s2tjdtso]To change the text to italic check the Italic box for Font Style on the right hand side of the dialog.
    [/*:m:s2tjdtso]
    [*:s2tjdtso]To bold the text check the Bold box for Font Style on the right hand side of the dialog.
    [/*:m:s2tjdtso]
    [*:s2tjdtso]To create a custom color: Click Define, select a color, and click ‘Add to custom colors’.
    [/*:m:s2tjdtso]
    [*:s2tjdtso]To delete a custom color: Select the color (FG appears) and click ‘Delete’. (Then reset your FG color back to what it was.)[/*:m:s2tjdtso][/list:u:s2tjdtso]Make sure the On checkbox for Syntax Highlighting is checked (top of dialog), otherwise none of the language’s reserved words will be shown in the special color you specify.

    Also, for each entry in the listbox under the Syntax Highlighting heading, make sure the Use Color and Use Font checkboxes in the Control section (right side) are checked. Otherwise you won’t get the color and/or you won’t get the font style you selected for that entry.

    In the following discussion of the Language Setup Dialog, when I say "the color specified in the Color Setup dialog" you can specify more than just color, you can specify:[list:s2tjdtso][*:s2tjdtso]text color (foreground color FG)[/*:m:s2tjdtso]
    [*:s2tjdtso]background of the text color (Background Color BG, for Highlighting text)[/*:m:s2tjdtso]
    [*:s2tjdtso]italicFont Style (right hand side of color dialog), check box for Italic[/*:m:s2tjdtso]
    [*:s2tjdtso]boldFont Style (right hand side of color dialog), check box for Bold[/*:m:s2tjdtso][/list:u:s2tjdtso]

    LANGUAGE SETUP DIALOG
    Now have a look at the Language Setup Dialog.

    TOOLS -> CUSTOMIZE -> General (left side) -> Languages (right side).

    You may view any existing language setup by selecting the language and clicking EDIT. To add support for a new language, click INSERT to get an empty Language Setup dialog which you can fill in. (Click the HELP button in the lower right corner and read what it has to say about the Language Setup dialog.)

    Let’s go through the fields from top to bottom:

    Language: The name of your language. (Later we will go to the File Extension Setup dialog and assign a file extension to your language using this name.)

    Case Sensitive: Check this if your language is case sensitive. Otherwise the language is treated as case insensitive and reserved words will be recognized regardless of their case.

    Reserved Words
    1: All words entered here will be displayed using the color specified in the Color Setup dialog for ‘Reserved Words 1’.

    2: All words entered here will be displayed using the color specified in the Color Setup dialog for ‘Reserved Words 2’.

    3: All words entered here will be displayed using the color specified in the Color Setup dialog for ‘Reserved Words 3’.

    4: All words entered here will be displayed using the color specified in the Color Setup dialog for ‘Reserved Words 4’.

    Note: The four Reserved Words fields each have a maximum length of 3000.

    Symbols
    Symbols entered here will be displayed using the color specified in the Color Setup Dialog for ‘Symbol Text’. Some typical symbols are +-*/=<>!#$%&,.:;?@\^_`|~

    Brackets
    Brackets entered here will be displayed using the color specified in the Color Setup Dialog for ‘Brackets’. Common brackets are ()[]{}

    Strings
    Enter a double quotation mark (") if strings in your language are enclosed in double quotation marks. Enter a single quotation mark (‘) if strings in your language are enclosed in single quotation marks. You may enter both a single and a double quotation mark if strings in your language may be enclosed in either. (Other delimiters may work, but I’ve never encountered a language that uses something other than single or double quotation marks.) Strings will then be displayed using the color specified in the Color Setup dialog for ‘String Text’.

    Literal
    If there is a special escape character which when found in a string means take the next character literally, enter that character in the ‘Literal’ field. For example, in CMAC in a double-quoted string the backslash character is a special character, so we enter a backslash here. This way a double quote will not be interpreted as the end of the string if it is preceded by a backslash. Thus the following string will be properly interpreted as a single string rather than two strings:

    [code:s2tjdtso]"He said, \"Goodbye!\" and then left."[/code:s2tjdtso]
    Tech Note: Some predefined languages in Multi-Edit have two backslashes in the ‘Literal’ field. This is not necessary. One will suffice.

    Numeric
    When Multi-Edit comes across a word which starts with a character entered in this field it will display that word using the color specified in the Color Setup dialog for ‘Numeric Text’. Digits 0-9 are implied, so you don’t have to enter them. For example, if you enter # in this field, then any word starting with # will be displayed using the color specified in the Color Setup dialog for ‘Numeric Text’.

    Block Comments
    If your language supports starting and ending block comment characters enter them here. For example, in C and CMAC the sequence /* specifies the start of a block comment and the sequence */ specified the end of said block comment. You would enter /* in the ‘Open 1’ field and */ in the ‘Close 1’ field. Then these comments will be displayed using the color specified in the Color Setup dialog for ‘Open/Close Comment 1’.

    Similarly, a block comment specified by the starting and ending characters in the ‘Open 2’ and ‘Close 2’ fields will be displayed using the color specified in the Color Setup dialog for ‘Open/Close Comment 2’.

    End of line comments
    Specify the character or character sequence that identifies the beginning of a comment which extends to the end of the line.

    A comment identified by End of line comments 1: will be displayed using the color specified in the Color Setup dialog for ‘EOL Comment 1’.

    A comment identified by End of line comments 2: will be displayed using the color specified in the Color Setup dialog for ‘EOL Comment 2’.

    A comment identified by End of line comments 3: will be displayed using the color specified in the Color Setup dialog for ‘EOL Comment 3’.

    A comment identified by End of line comments 4: will be displayed using the color specified in the Color Setup dialog for ‘EOL Comment 4’.

    If your language dictates that any text beyond a certain column number is to be treated as a comment, enter that column number in the Column: field for one of the entires. For example, FORTRAN-77 specifies that any text beyond column 72 is a comment, so you would enter 73 in this field to specify that comments begin with column 73.

    You can also combine Comment Character(s) with Comment Column to specify that if a certain character is in a certain column, then starting there to the end of the line is a comment. For example, in FORTRAN-77 a "C" in column 1 specifies that line is a comment, so you enter a C for the character and 1 for the column.

    You can also specify that a comment character or character sequence must be the first non-whitespace character on the line in order for it to be a comment character by specifying -1 as the comment column number.

    Some people have been creative in their use of the four different end of line comments you can define. They have used them for other things that they want to stand out. (See the thread forum.)

    I have set up four different EOL comments, each with their own color scheme. I can then insert the appropriate comments in my code to make lines show up as different colors. I have colors (with varying intensities) for "TODO/CRITICAL", "Headings", "Normal Comments", and a very muted gray for code I comment out that is slated for the chopping block. I use a muted color to help keep it from distracting me whereas for TODO/Critical I use a very loud red. The headings are intense yellow, and my normal comments are a pale yellow. It breaks up the code very nicely.[/quote:s2tjdtso]

    SepChars
    (See Multi-Edit help. The only example I have found of this being used is with PERL.)

    Note: If you make a change to the display colors in the Color Setup dialog for a color used by a particular language, and you have a file already loaded which uses those colors, you will need to close and reopen that file for the new colors to take effect.

    Note: The color template name you have displayed in the Color Templates field of the Color Setup dialog will become the default color template when you click the OK button. The default color template is used when no special color template is specified for a particular language.

    Related Articles:
    [url:s2tjdtso]http://www.multieditsoftware.com/addlanguage.php[/url:s2tjdtso]

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.