[Feature request] Adding regions

Post here any ideas/problems/suggestions you have regarding CodeLite's CodeFormatter (AStyle) plugin
kortyburns
CodeLite Enthusiast
Posts: 13
Joined: Mon Dec 15, 2008 1:26 am
Location: France
Contact:

[Feature request] Adding regions

Post by kortyburns »

Hi,

I would like CL to support regions, like VStudio, but in another way. I mean, with VS, writing

Code: Select all

#pragma region "this is a region"
...
#pragma endregion
Creates a region that can be folded. This is usefull when the same source code file is written in logical parts. Also, #pragma is a preprocessor directive and other compiler than M$, like gcc, don't like it until we disable warning for this directive ; that's why i would prefer a c comment tag to use to create a Region.

Would it be possible to create a region using a specific c comment tag, like

Code: Select all

/* Region Parse CAPMT */
... This block can be automaticaly folded in or out in the editor.
   /* Region Parse Elementary Stream */
   ... This is a subregion.
   /* EndRegion
/* EndRegion */
?

This would be displayed in the editor

Code: Select all

+Parse CAPMT
If '+' is clicked, then

Code: Select all

- /* Region Parse CAPMT */
   ... the code has been unfolded
   + Parse Elementary Stream 
   ...
/* EndRegion */
Creating a region is almost the same as creating a { } block, with a name.

Using these regions in source code is a good way to make a zoom in/ zoom out in the code. For example, you can choose to display or not all the error cases of a source file(parameters checks, errors values returned by functions, by choosing to unfold all "ERROR xxx" regions names).
Ubuntu64 Intrepid(8.10)
sdolim
CodeLite Veteran
Posts: 69
Joined: Fri Oct 24, 2008 10:29 pm
Contact:

Re: [Feature request] Adding regions

Post by sdolim »

I think some other editors (vim?) allow something like this to mark regions:

Code: Select all

//{ 
...
//}
You can add descriptive words like "Parsing" after the '{' or '}'. This pattern is nice because it is easy to scan for and can't really be misspelled.

Of course, that doesn't stand out visually very nicely when you are scrolling through the editor. Maybe we could do something like this:

Code: Select all

//---------------------------------{ Parsing }--------------------------------

...

//---------------------------------{ Lexical }--------------------------------
Here, the regex for a region start would be

Code: Select all

^ *//-*{.*}-* *$
The region would go to the beginning of the next region, as in the example above. (I use spaces in this regex for example only: a real regex would match tabs too.)

There could also be a marker to end a region if you want to not start a new region. I suggest this:

Code: Select all

//---------------------------------{ Lexical }--------------------------------

...

//-----------------------------------------------------------------------------
Note the lack of a "{ Name }" in the middle of the end-region marker.

BTW, this kind of feature is not really part of the CodeFormatter's job: It's a Scintilla Lexer issue because of the folding (CodeFormatter just reindents and respaces code.)

Scott
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: [Feature request] Adding regions

Post by eranif »

sdolim wrote:I think some other editors (vim?) allow something like this to mark regions:
CODE: SELECT ALL
//{
...
//}
and so does codelite.
Adding

Code: Select all

//{
adds a fold point and

Code: Select all

//}

will close it.

this is a built in feature of scintilla

Eran
Make sure you have read the HOW TO POST thread
sdolim
CodeLite Veteran
Posts: 69
Joined: Fri Oct 24, 2008 10:29 pm
Contact:

Re: [Feature request] Adding regions

Post by sdolim »

So my list of "some editors" includes CodeLite already...
Well, that makes it easy to satisfy this FR! :D
kortyburns
CodeLite Enthusiast
Posts: 13
Joined: Mon Dec 15, 2008 1:26 am
Location: France
Contact:

Re: [Feature request] Adding regions

Post by kortyburns »

Haha excellent, thank you !
Ubuntu64 Intrepid(8.10)
Post Reply