Author Topic: Code Folding  (Read 11722 times)

Offline Knx

  • Multiple posting newcomer
  • *
  • Posts: 41
Code Folding
« on: November 20, 2007, 10:53:54 am »
Code: [Select]
        //(*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: [Select]
// <editor-fold defaultstate="collapsed" desc=" Variables declaration "> 
code here
// </editor-fold>
And when collapsed you see a white box with " Variables declaration "
Using:
Code::Blocks SVN        wxWidGets 2.8.6
Windows XP SP2          MinGW Latest  Wish List Code folding (For wxSmith and more options like NetBeans)

Offline mariocup

  • Developer
  • Lives here!
  • *****
  • Posts: 587
Re: Code Folding
« Reply #1 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: [Select]
//{

//}

Bye,

mario

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: Code Folding
« Reply #2 on: November 20, 2007, 01:31:51 pm »
Code: [Select]
// <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: [Select]
//{

//}

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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Code Folding
« Reply #3 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

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9496
Re: Code Folding
« Reply #4 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...?! ;-)
« Last Edit: November 21, 2007, 08:53:04 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Code Folding
« Reply #5 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


Offline MortenMacFly

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

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Code Folding
« Reply #7 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

Offline MortenMacFly

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

Offline Knx

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Code Folding
« Reply #9 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


NetBeans
Using:
Code::Blocks SVN        wxWidGets 2.8.6
Windows XP SP2          MinGW Latest  Wish List Code folding (For wxSmith and more options like NetBeans)

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: Code Folding
« Reply #10 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!

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Code Folding
« Reply #11 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]

Offline Knx

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Code Folding
« Reply #12 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?
Using:
Code::Blocks SVN        wxWidGets 2.8.6
Windows XP SP2          MinGW Latest  Wish List Code folding (For wxSmith and more options like NetBeans)

Offline MortenMacFly

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

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Code Folding
« Reply #14 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