Dynamica Editor contains predefined highlight styles for following languages : C#, Java, XML and HTML. Those definitions are containes the Styles enumeration (there is also Styles.None member if no highlighting is required). You can set one of predefined styles using method Editor.SetHighlightStyle(Styles style). Do it like this :
// Create editor instance Dynamica.Editor.Editor editor = new Dynamica.Editor.Editor(); // set one of the Styles enumeration editor.SetHighlightStyle(Styles.CSHARP);
You can customize Dynamica Editor to highlight user-defined syntax rules. User defined syntax rules are defined in XML files (structure is given in next paragraph) and the key command for imposing those rules to editor is Editor.SetHighlightStyle(string filename). Do it like this :
// Create editor instance Dynamica.Editor.Editor editor = new Dynamica.Editor.Editor(); // set .xml file to impose syntax editor.SetHighlightStyle(@"C:\mysyntax.xml");
Like previously mentioned, syntax files are given in XML format. Those files contain definitions for text separators and highligh descriptors for user-defined special tokens. Separators are characters used to separate tokens while parsing ; blank separator (" ") is already predefined, and there is no need to do it explicitly in your syntax file.
The XML structure of user-defined syntax files follows the next pattern :
<highlightDefinition caseSensitive="true">
<!-- List of separator characters (blank is predefined) -->
<separators>
<separator value="\t" />
<separator value="+" />
<separator value="(" />
<separator value=")" />
...
<separators>
<!-- List of highlight descriptors definitions -->
<descriptors>
<!-- Descriptor attributes :
token - word or word segment that is to be recognized and highlighted
closeToken - end token for recognition phrase ; meaniningfull only if type is set to ToCloseToken
escapeToken - token that is used to escape closeToken ; meaniningfull only if type is set to ToCloseToken;
for example : token "\" escapes closing double quotes (used for strings) in C# syntax
type - one of the following values :
Word - token word will be highlighted
ToCloseToken - text will be highlighted between token and closeToken
ToEOL - whole line content after token will be highlighted
recognition - the recognition mechanism ; one of the following values :
WholeWord - token is recognized only as whole word
StartsWith - token is recognized if the word starts with the token string
Contains - token is recognized if anywhere in the word
color - highlight color for descriptor
-->
<descriptor token="abstract" color="Blue" type="Word" recognition="WholeWord">
<font family="Courier New" size="10"></font>
</descriptor>
<descriptor token="[" closeToken="]" escapeToken="" color="DarkRed" type="ToCloseToken" recognition="StartsWith">
<font family="Courier New" size="10"></font>
</descriptor>
...
</descriptors>
</highlightDefinition>
For deeper insight, you may want to checkout some already generated syntax files. You may find them self-explanatory and they might help you in better understanding of syntax files composition. You can download syntax files on download page.