April 29, 2024, 07:36:09 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


#region...#endregion

Started by Parker, January 06, 2006, 10:04:00 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Parker

I think this has been mentioned before, but I really wanted it to appear in the language. The #region and #endregion keywords work just like line comments, but they signal to the IDE that you are beginning a fold region, much like the { ... }.
In C# you can use them like this:
#region Controls in my window
Button1.Create(...);
...
#endregion


I just feel that it makes code a lot easier to see when you can define your own regions of code that you can collapse and expand. And since we already have the scintilla editor, I didn't think it would be very hard to implement.

Thanks

Ionic Wind Support Team

Scintilla impliments it's own code folding. 

In order to do that I would need to create fake keywords for the parser to ignore, since it would try and process your #region as a command.
Ionic Wind Support Team

Parker

Is it something that may be implemented though? Or is it too weird to add? Maybe if using that syntax doesn't work, it can appear as a comment.
//#region Some region
statements;
//#endregion


It's just for convienence and I'd like to see it added eventually, but if it can't be, I guess it just can't.

Ionic Wind Support Team

I will look into the Scintilla implementation to see if it can be adapted.
Ionic Wind Support Team

Parker

Thanks so much! I hope it all goes well.

Zen

If im right in understanding what these #regions are then you could use this as your ToDo feature Parker. In that case i also think it would be a good idea for when you have a lot of documentation in your programs, you can simply just fold it away until needed.

Lewis

Parker

The #region is just for folding away sections of code. For example, if you use C#, you'll have a
#region Windows Forms Designer generated code
Form1.AddButton(...);
...
#endregion

so then you don't have to worry about its code.

The TODO: thing is another issue, since you have to be able to search through all the files in your project for a //TODO: comment. Which I can do currently with the find in files, I just like the todo list and easyness of that, it's not any big deal at all though.

SMartin

I know this topic is a year old and this has probably been discussed elsewhere but....

//{ <any region name you want>

(bunch-0-code)

//} <end of any region name>

works is the editor and allows you to fold a region of code.

Parker

It was discussed elsewhere, but you won't be able to see it - it's in the developer's center. I figured out after looking at Scintilla's source code (May 13, 2006) that //{ and //} were already implemented in the C++ lexer, so they were used. No parser modifications required and it's already built in :)

But thanks for bringing this up, I didn't realize it wasn't in the public area.