Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: Knx on November 20, 2007, 10:53:54 am

Title: Code Folding
Post by: Knx on November 20, 2007, 10:53:54 am
Code
        //(*Identifiers(tFrame)
        static const long ID_BUTTON1;
        static const long ID_PANEL1;
        static const long ID_TEXTCTRL1;
        static const long ID_PANEL2;
        static const long ID_NOTEBOOK1;
        static const long idMenuQuit;
        static const long idMenuAbout;
        static const long ID_STATUSBAR1;
        //*)

        //(*Declarations(tFrame)
        wxNotebook* Notebook1;
        wxButton* Button1;
        wxPanel* Panel1;
        wxStatusBar* StatusBar1;
        wxTextCtrl* TextCtrl1;
        wxPanel* Panel2;
        //*)

Since C::B generates the code like this for wxWidgets, why not to create a fold option for "//(*" "//*)", code between this could be folded.
In NetBeans(Java) you can fold code putting
Code
// <editor-fold defaultstate="collapsed" desc=" Variables declaration ">  
code here
// </editor-fold>
And when collapsed you see a white box with " Variables declaration "
Title: Re: Code Folding
Post by: mariocup on November 20, 2007, 01:08:42 pm
Hi Knx,

you can add folding point in CB using (http://codeblocks.org/docs/main_codeblocks_ench1.html#x2-10001)
Code
//{

//}

Bye,

mario
Title: Re: Code Folding
Post by: MortenMacFly on November 20, 2007, 01:31:51 pm
Code
// <editor-fold defaultstate="collapsed" desc=" Variables declaration ">  
code here
// </editor-fold>
And when collapsed you see a white box with " Variables declaration "

you can add folding point in CB using (http://codeblocks.org/docs/main_codeblocks_ench1.html#x2-10001)
Code
//{

//}

The combination of both - having wxSmith to add these automatically (but maybe optionally) would be a very good feature request for Byo! You might want to file such at BerliOS.

With regards, Morten.
Title: Re: Code Folding
Post by: byo on November 20, 2007, 11:25:42 pm
Switching to //{ scheme may be little bit problematic now since it may introduce problems on how to deal with two types of comments. Besides it looks like the //{ folding does not work now (at least on my Ubuntu box).

So probably the easiest way to allow folding wxSmith code is to modify current algorithm generating folding blocks but I don't know much about it and how it could be changed.

The wxSmith-generated code could also be threated especially in lexer so it would be coloured differently to separate that code from other parts. I've done this before but it required patching wxScintilla so maybe better solution should be introduced first ;)

Regards
   BYO
Title: Re: Code Folding
Post by: MortenMacFly on November 21, 2007, 08:35:27 am
Switching to //{ scheme may be little bit problematic now since it may introduce problems on how to deal with two types of comments.
I'm afraid I don't get it completely. I didn't mean to switch, but having this in addition around wxSmith code and current comments. So you can keep the wxSmith comment style untouched. But you are also talking about "two types of comments"...?! Mind explaining again for a stupe like me...?! ;-)
Title: Re: Code Folding
Post by: byo on November 21, 2007, 09:46:12 am
Switching to //{ scheme may be little bit problematic now since it may introduce problems on how to deal with two types of comments.
I'm afraid I don't get it completely. I didn't mean to switch, but having this in addition around wxSmith code and current comments. So you can keep the wxSmith comment style untouched. But you are also talking about "two types of comments"...?! Mind explaining again for a stupe like me...?! ;-)

Oh, now I get it, so it could be something like

//{ //(*BlockName(ClassName)
...
//*) //}


Ok, but I'm affraid it won't work since there's still problem with //{ //} detection in wxScintilla (it just don't mark such block for me).

BYO

Title: Re: Code Folding
Post by: MortenMacFly on November 21, 2007, 02:59:31 pm
Ok, but I'm affraid it won't work since there's still problem with //{ //} detection in wxScintilla (it just don't mark such block for me).
It works perfectly for me on Windows (anyway) and Ubuntu 7/10 with wxWidgets 2.8.6  (C::B svn build).
What OS/version do you haave where it does *not* work?!

[attachment deleted by admin]
Title: Re: Code Folding
Post by: byo on November 21, 2007, 10:39:10 pm
Hmm, now it's working for me  :oops:. So this is probably related to the bug when after regenerating source code in wxSmith, wxScintilla is unable to recover properly.

I'll try to add the extra-comment feature soon.

Regards
   BYO
Title: Re: Code Folding
Post by: MortenMacFly on November 22, 2007, 08:12:39 am
Hmm, now it's working for me  :oops:.
Halloween is over, isn't it... ;-)

I'll try to add the extra-comment feature soon.
That'd be a great feature, really. Take your time - I'm looking forward to it. :-)
Title: Re: Code Folding
Post by: Knx on November 22, 2007, 02:18:36 pm
Maybe I'm asking too much, but maybe someone can improve code folding...

When you click [-] C::B collapse and put a (ugly) line, instead of that I wish C::B could add a small block...

Zend
(http://img511.imageshack.us/img511/7060/zendpr5.jpg)

NetBeans
(http://img170.imageshack.us/img170/8151/netbeansus0.jpg)
Title: Re: Code Folding
Post by: JGM on November 23, 2007, 04:53:02 am
Maybe I'm asking too much, but maybe someone can improve code folding...

There was already a thread about that here:

http://forums.codeblocks.org/index.php/topic,5426.0

Also a forum member made a patch and posted it on that thread. Good luck!
Title: Re: Code Folding
Post by: byo on November 23, 2007, 10:08:42 am
I've made small investigation on extra code-folding comments and it looks like it may introduce some problems.
I've also looked into wxScintilla sources and prepared two patches.

First one forces wxScintilla to additionally fold wxSmith code, second one enables extra folding and additional colouring of such generated code (currently it would be standard black since it's not configurable in editor's preferences).

The biggest disadvantage of these patches is that they directly patch wxscintilla. There may be possibility to add our own lexer outside wxScintilla but that would require much more investigations.

Regards
   BYO

[attachment deleted by admin]
Title: Re: Code Folding
Post by: Knx on November 23, 2007, 12:32:42 pm
I've made small investigation on extra code-folding comments and it looks like it may introduce some problems.
I've also looked into wxScintilla sources and prepared two patches.

First one forces wxScintilla to additionally fold wxSmith code, second one enables extra folding and additional colouring of such generated code (currently it would be standard black since it's not configurable in editor's preferences).

The biggest disadvantage of these patches is that they directly patch wxscintilla. There may be possibility to add our own lexer outside wxScintilla but that would require much more investigations.

Regards
   BYO

Sorry, but how do I apply those patchs?
Title: Re: Code Folding
Post by: MortenMacFly on November 23, 2007, 02:39:15 pm
The biggest disadvantage of these patches is that they directly patch wxscintilla. There may be possibility to add our own lexer outside wxScintilla but that would require much more investigations.
Woohoo... you are going beyond the limits... but nice one - will try! :-)
Title: Re: Code Folding
Post by: byo on November 23, 2007, 09:44:03 pm
Sorry, but how do I apply those patchs?

If you're using TortoiseSVN simply right click on code::blocks directory and from TortoiseSVN submenu choose Apply Patch and select patch file. The rest should be easy.

One more thing I didn't mention - patches are excluding themselves, after applying one patch changes must be reverted to apply another one.

Regards
   BYO