Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: basurapr on March 04, 2007, 06:54:45 pm

Title: Collapsible Code Blocks
Post by: basurapr on March 04, 2007, 06:54:45 pm
It will be a nice feature in the codeblocks editor to have collapsible blocks of code, like in visual studio or sharpdevelop.
For example:

#region Constructors and Destructors
//Code Here..
#endregion

#region Events
//Bunch of events..
#endregion

#region Layout
//Really long code..
#endregion

We will have a better organized code in terms of viewing, searching and editing. I don't know if the feature is already available, but I will like to help in it. if some one can point me to the right direction I will be glad of it.
Title: Re: Collapsible Code Blocks
Post by: MortenMacFly on March 04, 2007, 09:59:10 pm
#region Constructors and Destructors
//Code Here..
#endregion
You can do this pretty easy using #ifndefs like:
Code
#ifndef REGION_LIVE_CYCLE
// Constructurs, Destructors...
#endif // REGION_LIVE_CYCLE
As long as you don't define "REGION_LIVE_CYCLE" (why would you?!) the code compiles fine but yu can collapse those regions easily.
For this purpose make sure you have enabled Settings->Editor->"Folding"->"Fold pre-processor commands".
With regards, Morten.
Title: Re: Collapsible Code Blocks
Post by: eranif on March 04, 2007, 11:43:30 pm
#region Constructors and Destructors
//Code Here..
#endregion
You can do this pretty easy using #ifndefs like:
Code
#ifndef REGION_LIVE_CYCLE
// Constructurs, Destructors...
#endif // REGION_LIVE_CYCLE
As long as you don't define "REGION_LIVE_CYCLE" (why would you?!) the code compiles fine but yu can collapse those regions easily.
For this purpose make sure you have enabled Settings->Editor->"Folding"->"Fold pre-processor commands".
With regards, Morten.
Well, you could do it like Morten suggested, but there is a better way of doing it:

Scintilla (CodeBlocks editing component) offers users an easy way for inserting fold points in the code using the following symbols:
//{ -- as a block starter
//} -- as a block ender

HTH
Eran


Title: Re: Collapsible Code Blocks
Post by: jmccay on March 05, 2007, 01:21:43 am
Well, you could do it like Morten suggested, but there is a better way of doing it:

Scintilla (CodeBlocks editing component) offers users an easy way for inserting fold points in the code using the following symbols:
//{ -- as a block starter
//} -- as a block ender

HTH
Eran

   I took the liberty of adding this to the wiki documentation: Wiki->Documentation->User Documentation->Miscellaneous.  I thought it would be handy to know.

jmccay
Title: Re: Collapsible Code Blocks
Post by: basurapr on March 05, 2007, 01:26:49 am
Hurray!,

Thanks guys, now i have a more searchable source code. Is nice to know that scintilla facilitate this task. :D

thanks a lot  :)
Title: Re: Collapsible Code Blocks
Post by: MortenMacFly on March 05, 2007, 07:22:41 am
//{ -- as a block starter
//} -- as a block ender
Wow! That's fantastic (I honestly didn't know about that :oops:). Thanks Eranif!!! :D
With regards, Morten.