Programming => General => Topic started by: Sora-Kun on November 12, 2010, 08:49:28 pm

Title: CodeFolding
Post by: Sora-Kun on November 12, 2010, 08:49:28 pm
Is there a way to configure the code folding feature of a TSynEdit ?
Title: Re: CodeFolding
Post by: Martin_fr on November 12, 2010, 10:33:25 pm
Codefolding is provided through the highlighter.

Currently the following highlighters provide folding:
pascal, lfm, diff, xml, html

If you need folding for a different language, then you would have to write a new highlighter.

To use a highligher, select it from the components, drop on the form, and then change
property SynEdit.Highlighter
to the highlighter you want.

As for folding configuration:

There are some options for configuration.
Look at the settings in the IDE "Environment" menu / "options".
It shows you what can be configured.
Mainly switching folding on/off for individual block types (like begin/end or class/end or try/except,....).

In order to configure folding in your project, you need to write some code.
It can not be done through the designer.

Please have a look at the testcase that comes with synedit:
particularly the file: testhighlightpas.pas

the method TTestBaseHighlighterPas.EnableFolds shows how to change fold-config.

You can also look at the gutter, it has a part for code folding.
It allows configuration of how the mouse works (ask for more details if you need this,it's complex).

This may not answer all your questions. But a lot of the answer depends on more detail of what you want to do exactly.

You can try out some bits, by using a Pascal highlighter. It has some folding enabled by default.

Then you can play with the code from the testcase, and try to enable/disable it.

Otherwise please write exact details of what you need.

As for writing your own highlighter (if you need a language that is not yet supported):
this is the starting point
  (see links at bottom too)
also see the very few entries in fpdoc (in synedit folder)

TinyPortal © 2005-2018