[Lazarus] user defined code folding regions using $REGION comments
Martin Friebe
lazarus at mfriebe.de
Wed Nov 26 15:53:17 CET 2008
Gerard N/A wrote:
> I have a rough implementation that seems to work Ok (I'm cautious
> because the synedit highlighter is a scary piece of code).
> If there is interest, I can post a patch to the bug tracker or here.
>
>
Hi Gerard,
I saw the patch you uploaded to the bug system.
As indicated the user-token must not interfere with real compiler
directives. This should still be easy to solve. Instead of looking for a
directive named $REGION, you would look for a comment with special content.
The 2nd issue requires more work.
consider this:
{@REGION 'for relesae builds' fold }
If IsRelease then begin
{@ENDREGION}
a:= foo(b);
writeln(a);
{@REGION 'for relesae builds' fold }
end;
{@ENDREGION}
This should work. The "begin" should still match the "end"
FoldedView has *some* (but completely untested) preparation for this.
The big task is, that this kind of fold info can not be stared in a
single combined list of the current type (FoldMinLevel / FoldEndLevel )
- The Highlighter needs to keep/calculate the info independent of the
current FoldLevel
- Current folds, have some info at *every* line in SynEditTextBuffer.
User folds are likely to be less in count. So I would suggest *not* to
add info to every line.
SynEditTextBuffer could have a TAVLTree storing info about each known
userfold.
- SynEdit.ScanFrom => would need to update the additional fold info
- TFoldedView would have to obey the additional FoldInfo
If you have a different idea, how the problem could be solved, please
feel free to explain, and we can discuss it.
Best Regards
Martin
More information about the Lazarus
mailing list