Author Topic: CodeFolding  (Read 5609 times)


  • Full Member
  • ***
  • Posts: 162
  • I can smell your presence ...
    • Sora-Kun
« on: November 12, 2010, 08:49:28 pm »
Is there a way to configure the code folding feature of a TSynEdit ?
if nothing suites you, make it your self!
The Revolution, Genesis. The next generation IDE.
If you want to help, PM me.

Made in Lazarus.
Soon, in The WWW.


  • Administrator
  • Hero Member
  • *
  • Posts: 7885
  • Debugger - SynEdit - and more
    • wiki
Re: CodeFolding
« Reply #1 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)

« Last Edit: November 12, 2010, 10:36:22 pm by Martin_fr »


TinyPortal © 2005-2018