Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

ID: 21388, Extending Syntax Highlighters using the ToolsAPI

by Ryan VanIderstine Email: Anonymous

Complete source code demonstrating adding new syntax highlighting to the Delphi IDE. Supports Delphi 7 and Delphi8.Net.
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 7.0  to 8.0 497 downloads
Copyright: No significant restrictions

Size: 11,824 bytes
Updated on Tue, 03 Feb 2004 10:28:38 GMT
Originally uploaded on Tue, 03 Feb 2004 10:23:19 GMT
SHA1 Hash: 413A251A1DCBD59191F8BF37D1B2224022C318C4
MD5 Hash: 603DBF4F1265F94E240EE6C9644F6A13

    Explore the files in this upload

This is an example/exploration of extending the highlighters that are
available through the ToolsAPI in Delphi 7 and above.

The highlighter that is implemented is an extended ini highlighter that makes use of the built-in highlighter and then alters some of the highlighting to show how it can done.

o the tokenizing methods can be called up to 4 times on each line so
you need to process the file in a rather quick fashion
o you can wrap other highlighters by via delegation and add new syntax
options (this can be done to the built in highlighters as well)
Your mileage may vary, my attempts only got me a few inches :(
o replacing the highlighter while in a package creates an issue when
either the package is rebuilt or the person elects to not use the
o The aggregating highlighter appears to work in a much more robust
manner as compared to the replacing delegators... shame
o When compiled for D8.Net it appears that the services are not
available right away so you have to defer loading the highlighter
until later (how long to wait isn't clear since they have implemented
a delegate callback for when a service is created but we do not
have access to that... as best as I can tell anyway). For my purposes
a wait of a few seconds was enough and then I simply synchronized the
call to register the highlighter at that point.

Build/Testing (D7)
o Compile and install the Package (RtsHighlighterPackage_D70.dpk)
o Tools | Editor Options
o Create new source file type
o Put "abc" (without the quotes) in the extensions list
o Check on the Use Syntax Highlight
o Select "INI Files (RTS)" in the Syntax Highlighter drop down
o Click OK
o Open the that is included, note the highlighting
o Edit the unitHighlighterImpl.pas routine TINIHighlighter.Tokenize()
method by changing some of the atXXXX constants used
o Rebuild the package and you should see the new highlighting

Building (D8.Net)
o Get the D7.1 Delphi compiler from BDN,1410,31918,00.html
o Extract the files to \Delphi7.1\bin
o Create the file \Delphi7.1\bin\dcc32.cfg (not supplied in zip)
I copied the dcc32.cfg file from my D7 installation and then touched it
up to indicate where the dcu and dcp files are located.
o Open a cmd box
o type "set path=c:\delphi7.1\bin;%path%" without the quotes
We do this to ensure we don't compile with prior version of the compiler
o change to the directory with this source
o compile the project
dcc32 -B RtsHighlighterPackage_D71.dpk
o go "grrr" because the -E option isn't used and the package got
created in your real delphi 7 directory!!!
o The output bpl should be in \Projects\Bpl\
o If you have the bpl file you can proceed to testing

Testing (D8.Net)
o Install the package into the known ide package via regedit
goto HKEY_CURRENT_USER\Software\Borland\BDS\2.0\Known IDE Packages
add a string value with the full path and filename to the package
i.e. c:\delphi7\projects\bpl\RtsHighlighterPackage_D71.bpl
o Start D8.Net
o Open the included sample file (
note that it is not highlighted yet
o Goto Tools | Options
o Goto Editor Options / Source Options
o Create a new Source file type (RTS)
o enter "abc" in the extension list
o Check on the 'Use sytnax highlight'
o Select "INI Files (RTS)" from the list of highlighters
o Click OK
o The file should be highighted now

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03