Author Topic: Collapsible Code Blocks  (Read 19729 times)

basurapr

  • Guest
Collapsible Code Blocks
« 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Collapsible Code Blocks
« Reply #1 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline eranif

  • Regular
  • ***
  • Posts: 256
Re: Collapsible Code Blocks
« Reply #2 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



Offline jmccay

  • Almost regular
  • **
  • Posts: 202
Re: Collapsible Code Blocks
« Reply #3 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
OS: WinXP, Win98 SE, & sometimes Linux

a little light reading from the wxWidgets 2.6.2 readme: A detailed 2000-page reference manual is supplied in HTML, PDF and Windows Help form: see the docs hierarchy.

basurapr

  • Guest
Re: Collapsible Code Blocks
« Reply #4 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  :)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Collapsible Code Blocks
« Reply #5 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ