SynEdit Development Website

Issues with SynEdit should be directed to the appropriate mailing lists, after the FAQ has been read.


Hosted by
SourceForge.net Logo

FAQ - Frequently Asked Questions

If the development team receive a question, related to SynEdit, the answer to which benefits others then you will find the answer here.


Table of Contents

  1. How do I convert a mwEdit highlighter to a SynEdit highlighter?
  2. How do I subscribe to the Mailing Lists?
  3. How do I set up SynEdit for exporting?
  4. How can I make a php/html multi highlighter? I cannot use <? and ?>
  5. How do I print the contents of a TSynEdit?
  6. How can I automatically determine the highlighter to use from a filename?
  7. Can SynEdit be used in console programs?
  8. I attempt to compile the demo programs but get errors like: SynEdit.dcu cannot be found, what am I doing wrong?
  9. I wrote a highlighter for the XYZ language. How can I contribute it to the project?

How do I convert a mwEdit highlighter to a SynEdit highlighter?

There are several changes before mwEdit highlighters can be used with SynEdit, this page tells you how to convert the source.

Steps to convert a highlighter:

  • unit name: SynHighlighterXXX.pas with XXX being the language name
  • GPL and MPL file header
  • used units in interface part: SynEditTypes, SynEditHighlighter
  • used unit in implementation part: SynEditStrConst
  • remove reference to exporter unit
  • remove Register procedure
  • edit SynEditReg.pas to register the new highlighter
  • rename the class to TSynXXXSyn with XXX being the language name
  • rename the base class to TSynCustomHighlighter
  • rename the highlighter attribute class type to TSynHighlighterAttributes
  • rename the TIdentChars type to TSynIdentChars
  • remove the SetLineForExport and ExportNext methods
  • remove the GetCapabilities method when it only adds the hcExportable capability, otherwise change the type to TSynHighlighterCapabilities
  • remove the TRangeState type and the GetRange, ResetRange, SetRange methods if the highlighter does not implement ranges
  • rename the MWS_ prefix to SYNS_
  • change the GetDefaultAttribute to use the SYN_ATTR_XXX constants and return the correct attribute object when applicable (NOTE: there are two more constants now!)

Michael Hieke 2000-04-14

Back to Top

How do I subscribe to the Mailing Lists?

Please see this document by David Muir.

Back to Top

How do I set up SynEdit for exporting?

There is a simple example of exporting in the downloadable source tree, in the Demos\ExportDemo directory.  This illustrates how to export to RTF and HTML.

Back to Top

How can I make a php/html multi highlighter? I can't use <? and ?>

"?", like ".", "*", and many others symbols, are reserved into regular expression syntax cause they have a special meaning.
Just replace "?" "." and all the reserved symbol with "\?" "\." and so on. So for the php example it is <\? and \?>.
You can find more info about posix regular expressions here

Back to Top

How do I print the contents of a TSynEdit?

Have a look at the PrintDemo located under the Demos directory.  This is a good example of how to print using the TPrintOut class, which can be used with or without a TSynEdit.

As of 19/06/2000, new print and print preview components have been added to the distribution.  A enhanced print demo, PrintDemoNew directory, is included in the SynEdit Source Download 1.0.

Back to Top

How can I automatically determine the highlighter to use from a filename?

If you have a look in the source tree, in the Demos directory you will see a Pascal unit called "uHighlighterProcs.pas" which contains some useful functions and procedures relating to this kind of problem.

Back to Top

Can SynEdit be used in console programs?

Yes, it can.  An instance of the control can be created using:

program test;

uses

  SynEdit;

var 

  SynEdit: TSynEdit;

begin

  SynEdit := TSynEdit.Create(Application);   { this creates the TSynEdit instance }

  SynEdit.Lines.LoadFromFile(SomeFile.txt);  

  { then process the file }

end.

See the pas2html demo, in the Demos\pas2html directory of the source tree, for an example of exporting a file to HTML without using a TSynEdit control.

Back to Top

I attempt to compile the demo programs but get errors like: SynEdit.dcu cannot be found, what am I doing wrong?

A common cause of this is that the directory that Delphi is looking for the source files is not the one in which the source files are actually located.  To solve this simply add the directory of the SynEdit source files to the Search Path of the project.

  1. Select Project menu, Options item
  2. Goto Directories/Conditionals tab
  3. In the edit box entitled Search path append the directory of SynEdit source files (e.g. C:\Program Files\Borland\Components\SynEdit\source)
Back to Top

I wrote a highlighter for the XYZ language. How can I contribute it to the project?

If you have a new highlighter to contribute, please put it into a ZIP file, together with a matching DCR file, and either send it to the developer list, or go to the SynEdit Project page, where you can find the mail addresses of the project maintainers to send the files to them.

Back to Top

David Muir.
Copyright © 2000  SynEdit Development Team. All rights reserved.
Revised: June 29, 2000 .