[Feature request] Adding regions

Post here any ideas/problems/suggestions you have regarding CodeLite's CodeFormatter (AStyle) plugin

[Feature request] Adding regions

Postby kortyburns » Mon Jan 26, 2009 8:35 pm

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)
kortyburns
CodeLite Enthusiast
 
Posts: 13
Joined: Mon Dec 15, 2008 1:26 am
Location: France

Re: [Feature request] Adding regions

Postby sdolim » Mon Jan 26, 2009 10:29 pm

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
sdolim
CodeLite Veteran
 
Posts: 69
Joined: Fri Oct 24, 2008 10:29 pm

Re: [Feature request] Adding regions

Postby eranif » Mon Jan 26, 2009 10:35 pm

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
User avatar
eranif
CodeLite Plugin
 
Posts: 5744
Joined: Wed Feb 06, 2008 9:29 pm

Re: [Feature request] Adding regions

Postby sdolim » Tue Jan 27, 2009 3:06 am

So my list of "some editors" includes CodeLite already...
Well, that makes it easy to satisfy this FR! :D
sdolim
CodeLite Veteran
 
Posts: 69
Joined: Fri Oct 24, 2008 10:29 pm

Re: [Feature request] Adding regions

Postby kortyburns » Tue Jan 27, 2009 12:38 pm

Haha excellent, thank you !
Ubuntu64 Intrepid(8.10)
kortyburns
CodeLite Enthusiast
 
Posts: 13
Joined: Mon Dec 15, 2008 1:26 am
Location: France


Return to CodeFormatter

Who is online

Users browsing this forum: No registered users and 2 guests