With the syntax editor you can create or edit syntax definition files to be used in RJ TextEd. It is
possible to create these manually in the editor using an old format. But they have to be converted
to the new format using the syntax editor.
Multi highlighter Options The first line in the syntax file can hold a directive. This is used, in some syntax files, when you
want the editor to open a different syntax file instead of this one. This can be very useful if the
syntax file is capable of using several syntax files for highlighting. Also called a multiple
highlighter.
E.g.
We put a directive in the PHP syntax file like this:
Syntax
|
Html
|
File
|
Html.syx
|
If we open a PHP file, the editor will first check the first line in the PHP syntax file. When it
finds a directive, it will open the Html syntax file instead. The html syntax is a multiple
highlighter and will use several syntax files to highlight the code. Including the PHP syntax
file. All PHP code will be highlighted using the PHP syntax file. Html code will be highlighted
using the Html syntax file and CSS code using the CSS syntax file and so on. The Html
highlighter ignores the directive when it open other syntax files for highlighting.
Syntax options
There are several options you can add to a syntax definition file. You only have to include the
options you actually need.
LineCommentA
Syntax
Description
The string is used to identify a line comment.
Example
LineCommentB
Syntax
Description
The string is used to identify a line comment. Use this if you need a second line
comment.
CommentStartA
Syntax
Description
The string is used to identify a comment start block.
Example
CommentEndA
Syntax
Description
The string is used to identify a comment end block.
Example
A comment block can, for instance in Java, be:
/*
This is a block comment, or a
multi line comment.
*/
So the options in a Java syntax file should be:
CommentStartA
|
/*
|
CommentEndA
|
*/
|
CommentStartB
Syntax
Description
The string is used to identify a comment start block.
CommentEndB
Syntax
Description
The string is used to identify a comment end block.
CommentEsc
Syntax
Description
In e.g. LaTeX a comment is written after a ( % ) sign. To write the actual ( % ) sign (not
comment) you type ( \% ). For the editor to handle comments and the sign ( % ) set the
comment escape to ( \ ). Now the ( \% ) sequence isn't highlighted as a comment.
AllowNestedComments
Syntax
AllowNestedComments
|
<Yes|No>
|
Description
Set this to "Yes" if you want to allow the use of nested comments.
Example
/* Comment block
/* Nested comment block */
we are still in comment block
*/
OnlyLineCommentIfFirstChar
Syntax
OnlyLineCommentIfFirstChar
|
<Yes|No>
|
Description
Line comment characters should only be used as line comment when they are the first
non-white space character on the line.
Example
' This is a line comment
... some text here ' this is not a line comment
Char
Syntax
Description
The string is used to identify a character bracket.
String
Syntax
Description
The string is used to identify a string bracket
Example
Everything between char or string symbols will be colored as a string. E.g. with the string
option:
String
|
"
|
StringOnLine
|
Yes
|
strings will be highlighted in the editor:
"This is a string!"
StringOnLine
Syntax
Description
Tell the editor if a string should span several lines or just one. This can differ for different
programming languages.
VerbatimStringStart
Syntax
VerbatimStringStart
|
<character>
|
Description
In C# you can enter a @ character before the string to have the string containing any
characters, including characters usually treated as escape characters. The verbatim
string does not have escape sequences.
So the statement:
test=@"c:\Test\test.doc";
is same as:
test="c:\\Test\\test.doc"; .
HexIdentifier
Syntax
Description
Most programming languages have a hexadecimal identifier. It can be a (0x) or a (#) sign.
Or it can be something else.
(Note! The tool "Colors" uses this identifier when inserting a color into your text. It is
always inserted as a hexadecimal number.).
Escape
Syntax
Description
Most programming languages that uses a string also have an escape char. E.g. the (\)
char.
AllowEscapeOutsideString
Syntax
AllowEscapeOutsideString
|
<Yes|No>
|
Description
In most programming languages a string escape is only used inside a string. But in some
languages it is valid to escape a beginning of a string (outside a string). This option is
used with the Perl syntax.
Numbers
Syntax
Description
Enter the chars that should be identified as numbers. E.g. Numbers = "0123456789"
Symbols
Syntax
Description
The editor uses the symbols entered here to separate words (a space char is always
used to separate words). Add your values here very carefully.
Example
If you add the folloing in a CSS syntax file:
could generate the following result:
{FONT-FAMILY: ARIAL,HELVETICA}
but with:
you get:
{FONT-FAMILY: ARIAL,HELVETICA}
The symbols ":," are very important in CSS and are used to separate properties and
values.
CaseSensitive
Syntax
Description
Tells the editor if the keywords should be identified with or without case sensitivity.
TagCaseSensitive
Syntax
TagCaseSensitive
|
<Yes|No>
|
Description
Tells the editor if the tags should be identified with or without case sensitivity.
HighlightUrl
Syntax
Description
Tells the editor that hyperlinks in the text should be highlighted and can have its own
color.
AutoCompleteTags
Syntax
AutoCompleteTags
|
<Yes|No>
|
Description
All tags or block with a start string of "<" and an end string of ">" can be auto
completed.
This option is set to "Yes" in the XML syntax file.
Example
In XML when you enter <LastName> the stop tag is inserted and the cursor is placed in
between
<LastName>|</LastName>
Tags that ends with "/>" are ignored. This option could work in the Html syntax as well,
but only if you always use xHtml. It wont work in html with tags like <br> since it doesn't
have a closing tag.
AddProjectClassesToCompletion
Syntax
AddProjectClassesToCompletion
|
<Yes|No>
|
Description
If you have created a project and if it contain classes, this option tell the editor to add
those classes to the list when auto completion and the user menu is invoked.
AutoCloseBraceStart, AutoCloseBraceEnd,
AutoCloseBlockStart, AutoCloseBlockEnd
Syntax
AutoCloseBraceStart
|
<string>
|
AutoCloseBraceEnd
|
<string>
|
AutoCloseBlockStart
|
<string>
|
AutoCloseBlockEnd
|
<string>
|
Description
Tell the editor what to use with the option to automatically close blocks and braces.
Example
E.g. The programming language can use the braces:
(), [], ""
and a block is enclosed by {...}
So we enter:
AutoCloseBraceStart
|
(["
|
AutoCloseBraceEnd
|
)]"
|
AutoCloseBlockStart
|
{
|
AutoCloseBlockEnd
|
}
|
OnlyHighlightInBlock
Syntax
OnlyHighlightInBlock
|
<Yes|No>
|
Description
Tells the editor to only highlight code within a block. This is used in e.g. CSS where we
only want the editor to highlight text inside the { ... } brackets.
EndOpenBlockAt
Syntax
Description
Tells the editor to end an open block at one of these characters. This is e.g. used in the
JScript syntax for regex modifiers.
AutoCompleteCharA
Syntax
Description
This character is used to trigger auto completion. In most programming languages this
should be a dot (.).
AutoCompleteCharB
Syntax
Description
A second character to be used to trigger auto completion. In some syntax files a space is
used to trigger auto completion e.g. after the "new" keyword.
HintCharStart
Syntax
Description
Hints can be used to with function to display parameters. Usually a left bracket "(" is
used, but can be anything you want. If nothing is entered "(" is assumed.
HintCharEnd
Syntax
Description
Hints can be used to with function to display parameters. Usually a right bracket ")" is
used, but can be anything you want. If nothing is entered ")" is assumed.
BlockName
Syntax
Description
A block is everything between a block start and a block end symbol. The block name
option creates the block and has to be entered before any other block options. You can
create as many blocks as you want. Just enter a new block name option with a different
value (name) and the other block options will then affect the new block.
Open block
If you only enter a block start, and not a block end, you get an open block. A space or
symbol will then end the block. This is used in the syntax definition file for the Perl
language to highlight variables. E.g. @var were @ act as a block start and with no given
block end the space act as the block end.
Example
E.g. The blocks we want to create are:
[ ... ]
{ ... }
So we enter:
BlockName
|
Example block 1
|
BlockOnLine
|
Yes
|
BlockAsString
|
Yes
|
BlockStart
|
[
|
BlockEnd
|
]
|
BlockName
|
Example block 2
|
BlockOnLine
|
Yes
|
BlockAsString
|
Yes
|
BlockStart
|
{
|
BlockEnd
|
}
|
A block can be used as an advanced string. It can act exactly like a string coloring
everything in the block with the same color. Or it can just color everything it does not
recognize using a block color. This can be extremely helpful when writing syntax files.
Keywords, strings, numbers and so on keeps there specific color but the rest gets the
block color. Here are some very simple example of how it can be used.
E.g.
An ini file looking like this:
[Colors]
Text=255
Bk=0
will with these options:
BlockName
|
Key block
|
BlockOnLine
|
Yes
|
BlockAsString
|
Yes
|
BlockStart
|
[
|
BlockEnd
|
]
|
look like this, if the "Key block" color is set to "Teal":
[Colors]
Text=255
Bk=0
E.g.
A line in a CSS file might look like this:
P {FONT-FAMILY: Arial, Helvetica, sans-serif}
Now, the editor does not have to recognize every font type to color the names. If P is
colored as normal text (e.g.purple) and FONT-FAMILY as a keyword (e.g.blue). And we
enter these options:
BlockName
|
CSS block
|
BlockOnLine
|
No
|
BlockAsString
|
No
|
BlockStart
|
{
|
BlockEnd
|
}
|
With the "CSS block" color red, we get:
P
{FONT-FAMILY: Arial, Helvetica, sans-serif}
(Note! For this to work you must enter the colon (:) as a symbol but not (-). If you enter (-) as a symbol FONT-FAMILY will not be recognized as a keyword because FONT and
FAMILY will be handled separately.)
BlockOnLine
Syntax
Description
Tell the editor if the block can span over several lines, or just one line.
BlockAsString
Syntax
Description
Set this option to change the behavior of the block.
1. "Yes" the block will act like a string. Everything inside the block, including
the
block characters, will have the same color.
2. "No" keywords, strings, symbols ... will have there specific color and the
text not
recognized (all the rest) will be colored with the block color.
BlockStart
Syntax
Description
A string to start a block.
BlockEnd
Syntax
Description
A string to end a block. If this option is empty, an open block is created. The block is then
ended by a space or a symbol.
BlockEsc
Syntax
Description
In e.g. LaTeX the sign ( $ ) is treated as a block. To write the actual ( $ ) sign you can
type ( \$ ). For the editor to handle blocks and the sign ( $ ) correctly, set the block
escape to ( \ ). Now the ( \$ ) sequence isn't highlighted as a block.
Fold_Id
Syntax
Description
This can be used to identify the beginning of a fold region. E.g. to identify a function in
Pascal/Delhi you could write:
Example
A string with a maximum of two words can be used.
Fold_Id
|
function
|
Fold_Begin
|
begin
|
Fold_End
|
end
|
Fold_Begin / Fold_End
Syntax
Fold_Begin
|
<string>
|
Fold_End
|
<string>
|
Description
In several programming languages a block is marked by a begin id and an end id. These
can be { ... } or begin ... end. The editor needs to know the begin id to correctly identify
the end statement.
Example
Let us look at a few examples:
Ex1.
function
Test( form )
{
// A simple if statement
if (form.name.value == "")
{
alert("Please enter a name.");
form.name.focus();
return false;
} //
end if
} //
end function
Now as fold id we can use "function". We should also use "{" as begin and "}"
as end,
as below.
Fold_Id
|
function
|
Fold_Begin
|
{
|
Fold_End
|
}
|
If we don't use a begin id the editor will think the fold region ends at the " } // end if "
statement.
Ex.2.
Now, what if we want all " { ... } " blocks to be foldable. That's actually very simple. We
just enter an empty fold id. The editor will then try to id the right row automatically. If we
don't want to fold if { ... } we can add this to the option Fold_Opt_AutoIdExcludes = "if".
This is how it would look like:
Fold_Id
|
|
Fold_Begin
|
{
|
Fold_End
|
}
|
AutoIdExcludes
|
if
|
Ex3.
<body>
<table
...>
</table>
</body>
Lets say we wish to fold both the body and the table block. We then enter:
Fold_Id
|
<body
|
Fold_Begin
|
|
Fold_End
|
</body
|
Fold_Id
|
<table
|
Fold_Begin
|
|
Fold_End
|
</table
|
That was simple, wasn't it?
As with the id, a string with a maximum of two words can be used. E.g. Fold_End = "End
Function" used in VB .NET. The editor will also ignore foldable blocks that only span one
line.
Fold_EndBefore
Syntax
Description
Some programming languages and scripts can not be folded using a start/end keyword.
This option may then be used to end the fold before a specified phrase or by using a
command. There are some commands you can use to end the fold:
· \lf - line feed. The line can contain spaces or tabs but is otherwise blank. Can also be
the last line (end of file).
· \ef - end of file. The last line in the document. This is used in the INI syntax file.
· \in - indent. Compare the indention to the fold start line. Can also be the last line.
· ~ - the string has to be the first string on the line. E.g. ~[ means the [ character has to
be the first character on the line.
It is possible to use a combination of command and keywords, but always place the
command first. \lf, \ef and \in can not be used together though.
Example
Ex. 1
In the programming language Boo we need to create folds by reading the indent of each
line.
1 def Hello():
2 return "Hello, World!"
3
4 def Hello(name as string):
5
return "Hello, ${name}!"
We use the following options:
Fold_Id
|
def
|
Fold_EndBefore
|
\in
|
this tells the editor to compare the indention with the fold start line. If code with the same
(or less) indention is encountered, we have a fold that ends just above that line. The end
of the fold can also be the last line in the document.
Above we get two folds between lines:
1-3 because the "def..." at line 4 has the same indention as "def..." on line 1.
4-5 because it is the last line and no similar or smaller indention was found.
Ex. 2
In a .reg or .ini file we have sections with no "end" keyword. We need to find the end of
each section in order to create a fold.
1
[section]
2 key=value
3 key=value
4
5 [section]
6 key=value
7 [section]
8 key=value
Looking at the code above we see that the end of a section can the beginning of a new
section or the last line. We use the options:
Fold_Id
|
[
|
Fold_EndBefore
|
\ef ~[
|
The [ - sign identifies a new section and \ef the last line (end of file). The ~ sign is used to
tell the editor that the [ sign has to be the first character on the line. We get folds between
lines:
1-4 : line 5 is a new section.
5-6 : line 7 is a new section.
7-8 : line 8 is the last line in the document.
Ex. 3
In several programming languages like C++, PHP... you may enter code like
1 if (...) {
2
3 } else {
4
5 }
The "if { ... }" block should create a fold, but it would then include the "} else {" statement.
We need to tell the editor that we want the fold to end above the "} else" statement. We
use the following options:
Fold_Id
|
if
|
Fold_Begin
|
{
|
Fold_End
|
}
|
Fold_EndBefore
|
} else
|
|
|
Fold_Id
|
else
|
Fold_Begin
|
{
|
Fold_End
|
}
|
This will create folds at lines:
1-2 : Fold ends before line 3 because of the "} else" statement.
3-5 : "else { ... }" fold, as expected.
Fold_Section
Syntax
Description
Use this option if you only want a fold block to appear in a certain section of the source.
Example
In Ex3. above you could add:
Fold_Id
|
<table
|
Fold_End
|
</table
|
Fold_Section
|
<body
|
Fold_opt_Sections
|
<head|<body
|
In this case it is a bit unnecessary, but can sometimes be useful. E.g. in Pascal/Delphi
you declare procedures and function in the "interface" section. You don't want these to be
foldable, only the procedures and function in the implementation section
Fold_NoParentOfId
Syntax
Fold_NoParentOfId
|
<Yes|No>
|
Description
This option is probably only useful in Pascal/Delphi syntax. In Delphi you can declare a
class without the actual declaration of its class members.
Example
TMyClass = class; // First class declaration
TMyOtherClass = class // Second class declaration
class methods ...
end;
Now, you want the second class declaration to foldable and the first to be ignored.
So, we write:
Fold_Id
|
class
|
Fold_End
|
end
|
Fold_NoParentOfId
|
Yes
|
Fold_NoParentOfId = Yes <--
This makes the editor skip the first
class declaration and use the second instead.
Fold_List_Item
Syntax
Description
Use this option to tell the editor that this node should be added to the code explorer. The
type can be:
ceStruct - structures, records...
ceEnum - enumerations
ceClass - class
ceNS -
namespace (.NET)
ceMethod - procedure, function...
ceConstructor - constructor
ceDestructor - destructor
ceProperty - property
ceTag -
html tag
ceTagStyle - html style tag
ceTagScript- html script tag
ceTagHead - html head tag
ceTagBody - html body tag
ceUnknown - misc...
Example
Fold_Id
|
class
|
Fold_End
|
end
|
Fold_List_Item
|
ceClass
|
Fold_Id
|
Function
|
Fold_End
|
End Function
|
Fold_List_Item
|
ceMethod
|
.
List_As...
Syntax
List_AsStruct
|
<string>
|
List_AsEnum
|
<string>
|
List_AsClass
|
<string>
|
List_AsNS
|
<string>
|
List_AsProperty
|
<string>
|
List_AsMethod
|
<string>
|
Description
In some languages you want all " { ... } " blocks foldable. You can use this option to teach
the editor which elements should be added in the code explorer.
Example
E.g.
You have the following options in a syntax file:
Fold_Id
|
|
Fold_Begin
|
{
|
Fold_End
|
}
|
To let the editor recognize some important elements you can use the options above.
E.g.
List_AsClass
|
class
|
List_AsStruct
|
record
|
All other elements will be added as methods to the code explorer. You should use the
exclude feature below as well.
List_Exclude
Syntax
List_Exclude
|
<string>|<string>|...
|
Description
Exclude some elements from the code explorer.
Example
List_AsClass
|
class
|
List_AsStruct
|
record
|
List_Excludes
|
case|else|if|for|while
|
If we don't add the exclude option above, all elements like for, while, if ... would be added
to the code explorer and displayed as methods.
List_ClassSeparator
Syntax
List_ClassSeparator
|
<string>
|
Description
In some languages a class function consist of a class name and a function name divided
by a separator. In C++ the separator is "::".
Example
So in a C++ syntax file we should enter:
This will add the functions to the right class in the code explorer.
AsBegin
Syntax
AsBegin
|
<string>|<string>|...
|
Description
Some languages use a begin and an end statement to all blocks. And some don't. For
instance Delphi don't use begin with "case" or "try" statements. If we don't add these as
fold blocks we need to tell the editor that case and try should be counted as a begin
statement.
Example
Lets look at an example:
procedure Test(const s: string);
begin
if (
s = '' ) then
begin
exit;
end; <--
first end
case ... of
some
code ...
end; <--
second end
end; <--
third end
As you can see in the code above, there are 3 ends but only 2 begins. For the editor
to find the third end statement we need to tell the editor to count "case" as a begin
statement, as shown below:
Fold_Id
|
procedure
|
Fold_Begin
|
begin
|
Fold_End
|
end
|
Fold_Section
|
implementation
|
AsBegin
|
case|try
|
Sections
|
interface|implementation
|
Sections
Syntax
Sections
|
<string>|<string>|...
|
Description
If you are using the section option in the fold blocks, the editor needs to know which
sections to look for, as shown in the example above.
Separators
Syntax
Description
A space will always separate statements, but there can sometimes be other symbols
before or after a fold id.
Example
E.g. in the example above you can see:
if( <-- notice the (
end; <-- notice the ;
For the editor to be able to identify "if" and "end" we enter:
With this option the "if" and the "end" statements are recognized properly.
Case
Syntax
Description
Set this option to yes if the folding identifiers are case sensitive.
FoldAllTags
Syntax
Description
With this option set to yes, all tags will create a collapsible region. Start and end tags on
the same line are ignored and so are closed tags. This options should probably only be
used with XML files or XML based languages like XHTML.
AlwaysAllowNesting
Syntax
AlwaysAllowNesting
|
<Yes|No>
|
Description
With this option set to yes, all folded items in your code can be nested. This is usually
prevented. Most programming languages don't support nested function etc. In some
situations nesting of functions, properties etc. may cause problems. This option is
therefore usually set to "No".
Start / End
Syntax
Start
|
<string>
|
End
|
<string>
|
Description
Start and end of a region. Regions are used in .NET languages like C#.
Example
In a VB .NET syntax file we can write:
Start
|
#Region
|
End
|
#End Region
|
A string with a maximum of two words can be used as region identifiers.
CommentStart
Syntax
Description
In for instance Delphi .NET a comment is used to "hide" region identifiers. The editor
needs to know which comment symbols is being used.
Example
{ $REGION ... }
Some code ...
{ $ENDREGION }
We just need to tell the editor which comment symbol is used.
Start
|
$REGION
|
End
|
$ENDREGION
|
CommentStart
|
{
|
"{" is the comment used to "hide" the region identifiers.
Keywords
You can have as many keyword groups as you want. E.g. one group can be standard keywords
and another group data types. Enter a name to the keyword group and then add keywords to that
group.
Tags
Tags are used in for instance html files. You can add as many tag groups as you want. Enter a
name to the tag group and then add tags and stop tags to that group.
User Menu
In the user menu you can add items you want to be available in the editor when you hit Ctrl +
Space. The user menu can contain any text you want. Enter a menu name and add items to the
menu. The menu items have icons and data. The data is text that should be inserted in the editor
when selected. Selecting a menu item and pushing the insert button (or double click the item) will
insert a text at the cursor position. If nothing is entered as "Inserted Text" the menu item name
itself is inserted at the cursor position.
Class Auto Completion
When typing a class name and a dot in the editor you can present the user with a list of variables
and methods.
1. Enter a class name. The name can be a single word or several separated with a
dot. E.g. System.out. or just System.
2. Enter the members for your class.
3. For each item you can select an icon.
4. For each item you can specify the text that is inserted into the editor. If nothing
is specified
the item name itself is inserted.
Tag Auto Completion
When typing a tag (<) or a space inside a tag you can present the user with a list of tags or
attributes. Also when typing a stop tag (</) the user can be presented with a list of stop tags.
1. Enter all the tags and stop tags.
2. For each tag enter the attributes that is available for this tag.
3. Select icon for the attribute.
4. Select the text that should be inserted for the attribute. If nothing is entered
the attribute
name will be inserted.
When typing ( < ) in the editor all the tags are listed in a listbox. If the user then enters a ( / ) the
listbox changes and all stop tags are listed. When hitting the space bar inside a valid tag a list
with attribute for that tag is shown in a listbox.
· When
a tag is selected in a listbox only the tag name is inserted.
· When
a stop tag is selected the stop tag name and a ( > ) character is inserted. E.g. when
typing </ and the user selects applet applet> is inserted resulting in </applet>.
· When
an attribute is selected you can decide what should be inserted.
Hints
When typing a function or method in the editor the user can be presented with a hint.
Enter the full name for the function or method. E.g. System.load(String filename) . What you enter
between the brackets is up to you. You could have entered: System.load(filename).
Syntax Sample
In the options dialog the user should be presented with a sample of the source code to aid the
user when selecting colors and text attributes for keywords, string ...
Try to add all elements in this sample. The code does not have to be functional. It should have
keywords, a string, numbers, comments, symbols, maybe tags (and a script) or blocks that you
have created in the options page.
Add-ons information
The author and date string information will be displayed in the add-ons dialog. The version
number is used to compare the remote and local version when updating the syntax files.
Author Information
This is optional. You can add or delete items as you please.
Enter some information about the syntax type, date and author. You can also enter some
information about the colors you think should be used with certain keywords or maybe some
version information. You can enter as much text here as you want.
These four lines
Syntax:
Author:
Version:
Date:
are created by pressing "Add Default".
Install the syntax file
When the file is finished and you want to install it in RJ TextEd, follow these steps below.
Alt. 1
1. Save the file to disk. In RJ TextEd select <Environment->Install New->Language files> in the
menus. Select your file and the options dialog is opened.
Alt. 2
1. Save the syntax file in the
C:\Documents and Settings\(user)\Application Data\RJ TextEd\Syntax folder, or in
Vista
C:\Users\(user)\AppData\Roaming\RJ TextEd\Syntax folder.
Or in the non-install version
<Prog dir>\Syntax folder.
2. Now it can be added in the "Manage Highlighters" sections in the options dialog. Press "New"
to open a wizard. Enter a name for the syntax style, e.g. Cpp, and add some file extensions,
e.g. *.cpp|*.h.
After successful testing please send it to me and I will put it on the homepage.