Great undocumented feature: foldable code with $REGION directive
From: Marcelo Carvalho (mc_nospam_at_arquivo.com.br)
Date: 12/04/04
- Next message: Nick Hodges [TeamB]: "Re: Delphi 2005 is here, apparently no benefit of the cheap dollar.."
- Previous message: Nick Hodges [TeamB]: "Re: Delphi 2005 is here, apparently no benefit of the cheap dollar.."
- Next in thread: John Kaster (Borland): "Re: Great undocumented feature: foldable code with $REGION directive"
- Reply: John Kaster (Borland): "Re: Great undocumented feature: foldable code with $REGION directive"
- Reply: Mauro Venturini: "Re: Great undocumented feature: foldable code with $REGION directive"
- Reply: John Kaster (Borland): "Re: Great undocumented feature: foldable code with $REGION directive"
- Reply: Dennis Landi: "Re: Great undocumented feature: foldable code with $REGION directive"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 4 Dec 2004 07:54:20 -0800
Hi,
Having my first contact with C# IDE on D2005, I noticed a different
rectangle, that was “hiding” a piece of auto-generated code. It was the
#REGION directive. Than I saw the same kind of region in the Delphi.Net
IDE, as the {$REGION} directive. Immediately I tried it in the Win32
IDE and… it worked!
The syntax is:
…
{$REGION ‘Any title you want’}
…
// Any piece of code
…
{$ENDREGION}
…
After typing it, when you place the cursor back on the {$REGION}
line, a small [+] appears near the line numbers - and you have a
foldable piece of code! Closing it provides a nice rectangle hiding all
code between the directives, showing the title you typed.
This resource allow you to organize code easily, and is a great
complement for the similar foldable methods and procedures. You can
fold logical pieces of code, group code to turn complex structured
blocks easy to read, group procedures and functions by categories,
group variable declarations, and so on. You can even see all your unit
folded code in one single screen!
The regions CAN be nested, and they keep the indentation of the
{$REGION} directive when folded. You can also customize it’s colors
when folded and unfolded.
Of course there’s space for enhancements: The main one, as pointed
by Nick Hodges, would have some “Make selected code a region” as a
right click… Also I'd like to be have a parameter so set color for
individual regions (to categorize them), and have a shortcut do fold
all regions and methods...
I was wondering why such great resource is undocumented, not even
being showed in the Borcons demos – it would be a success there, I’m
sure. My first thought is that maybe because it is derived from some C#
or VB resource… Observing many people being surprised when I mentioned
it I decided to share it here.
[][][][]
Marcelo.
- Next message: Nick Hodges [TeamB]: "Re: Delphi 2005 is here, apparently no benefit of the cheap dollar.."
- Previous message: Nick Hodges [TeamB]: "Re: Delphi 2005 is here, apparently no benefit of the cheap dollar.."
- Next in thread: John Kaster (Borland): "Re: Great undocumented feature: foldable code with $REGION directive"
- Reply: John Kaster (Borland): "Re: Great undocumented feature: foldable code with $REGION directive"
- Reply: Mauro Venturini: "Re: Great undocumented feature: foldable code with $REGION directive"
- Reply: John Kaster (Borland): "Re: Great undocumented feature: foldable code with $REGION directive"
- Reply: Dennis Landi: "Re: Great undocumented feature: foldable code with $REGION directive"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|