Jan Verhoeven - Januari 2001, website email
TSynEdit comes with many highlighters, including a general highlighter where you can define your own keywords. TSynAnySyn is a descendant of TSynCustomHighlighter that allows the end user of a program to define his or her own highlighter properties in a .ini file and load it into TSynAnySyn.
Besides a list of keywords you can also define a list of constants and objects that can have their own highlighting attributes.
The component comes with some ready to use highlighter files for most commonly used programming languages.
Copy SynHighlighterAny.pas to your SynEdit source directory. Add TSynAnySyn to the SynEdit package and include registration in the SynEditReg.pas file. Also add the TSYNANYSYN bitmap to SynEditReg.dcr
Only additional methods and properties are shown.
TSynAnySyn is based on TSynCustomHighlighter.
procedure LoadHighlighter(AFile:string);
Loads the highlighter from a .ini file. See syntax for details on creating a highlighter file.
When ActiveDot is true properties and methods of objects after the dot are highlighted, e.g. myobject.method
Holds the attributes for constant words defined in the Constants property.
Holds the words defined as constants.
When DollarVariables is true symbols preceeded by the sign will be highlighted using the VariableAttri settings. You can use this for variable highlighting in languages like php and perl
Holds the attributes for objects properties and methods after a dot character, in case Activedot is true.
When Entity is true entity symbols like & will be highlighted. You can use this for e.g. HTML and XML highlighting.
Holds the attributes for Entities when the Entity property is true.
Holds the attributes for identifiers, symbols that begin with a letter and are followed by more letters or figures.
Holds the attributes for keyword words defined in the Keywords property.
Holds the words defined as keywords.
When markup is true, words between < and > will be highlighted. You can use this for markup languages liken HTML, XML and XSLT
Holds the attributes for numbers
Holds the attributes for object words defined in the Objects property.
Holds the words defined as objects.
Holds the attributes for spaces
Holds the attributes for strings, double or single quoted depending on the StringDelim property.
Defines whether strings are single or double quoted.
Holds the attributes for symbols like + and *.
Holds the attributes for vatiables, words preceeded by a $, in case DollarVariables is true.
Highlighter files are .ini style files that the end user of your program can create in any text editor. In your program you can provide the option of loading such a file into TSynAnySyn using the LoadHighlighter method.
For colors you can use the Delphi color constants or a $BBGGRR (blue, green, red) color triplet.
For font style you can use normal or a (comma seperated) combination of bold, italic or underline. For example:
Style=bold,italic
For booleans you use true or false
Use the code below as the template for new highlighter files. It contains all available options.
[CommentStyle] ansi=false asm=false bas=false c=false pas=false vb=false [String Delimiter] Double Quotes=true [Switches] markup=false entity=false dollarvariables=false ActiveDot=false [Comment] Foreground=clblue Background=clwhite Style=italic [Constant] Foreground=clblack Background=clwhite Style=bold [Entity] Foreground=clblack Background=clwhite Style=normal [Identifier] Foreground=clblack Background=clwhite Style=normal [Dot] Foreground=clblack Background=clwhite Style=normal [Keywords] Foreground=$FF0080 Background=clwhite Style=bold [Number] Foreground=clblack Background=clwhite Style=normal [Space] Foreground=clblack Background=clwhite Style=normal [String] Foreground=$FF8000 Background=clwhite Style=normal [Symbol] Foreground=clblack Background=clwhite Style=normal [Object] Foreground=clblack Background=clwhite Style=normal [Variables] Foreground=clpurple Background=clwhite Style=bold [Objects] object1 object2 [Constants] constant1 constant2 [Keys] key1 key2