Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Finding region
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Andre
Junior Member

Canada
20 Posts

Posted - Aug 23 2005 :  4:23:23 PM  Show Profile
What about allowing find for regions. It would be nice if we could find the beginning or the end of a region. You could even list the regions so we could select the one to be found.

feline
Whole Tomato Software

United Kingdom
15980 Posts

Posted - Aug 24 2005 :  2:45:12 PM  Show Profile
personally my first reaction is to ask why? speaking as a C++ programmer regions are something that happen to other people.

i presume you are talking about regions in C#, but even then i would not expect there to be many in a code file.

have you tried alt_up_arrow and alt_down_arrow for moving up and down the file? you may find that you quickly find the boundaries of a region using this method.

zen is the art of being at one with the two'ness
Go to Top of Page

jmihalicza
Ketchup Master

Hungary
66 Posts

Posted - Sep 12 2005 :  11:34:10 AM  Show Profile
They do exist in C/C++, but aren't called regions. Just google for "pragma mark".

All IDE-s on Macintosh support them nicely (in the methods popup for example) and that's really a very useful feature.
IMHO it would fit well into VA, after all, this is directly about code navigation and ease of read.

Other related posts:
http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=3704
http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=3719

Don't treat #region/pragma mark as 'just a hint for the IDE to enable folding'.
It is rather a tool for the coder to express code structure.
It is supposed to be taken into account by VA.

I frequently have to maintain old C code parts where there are bunches of functions grouped this way instead of a long dumb list.
Just have a quick look how it works in Xcode:
http://www.atxproject.net/xcode-tuning/ Tip #5
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15980 Posts

Posted - Sep 12 2005 :  2:56:12 PM  Show Profile
*ah* a picture speaks a thousand words. now i understand what you are getting at, plus why they are a good idea.

adding the line:

#pragma mark fred

to a VS 2003 C++ project produces the compiler warning "warning C4068: unknown pragma"

in VS 2005 beta 2, if you generate a standard managed C++ windows application you get the lines:

#pragma region Windows Form Designer generated code
#pragma endregion

used to denote a named folding block in the IDE.

the real question becomes how best should this be done by VA. placing them into the alt_m list when it is ordered by occurrence makes a lot of sense, and allowing alt_up_arrow and alt_down_arrow to jump to them also makes sense.

but what is VA to look for? and in what languages? in your old C code what exactly is used? "#pragma mark <comment>" presumably denotes the beginning of a logical block, but what, if anything, marks the end of it?

i know a lot of people set the error checking in the IDE to treat warnings as errors, so introducing unknown #pragma's is not going to be a popular option.

zen is the art of being at one with the two'ness
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15980 Posts

Posted - Sep 12 2005 :  4:27:05 PM  Show Profile
a further question, how do you see regions inside functions being treated? it makes no sense to list them in VA's alt_m list.

zen is the art of being at one with the two'ness
Go to Top of Page

jmihalicza
Ketchup Master

Hungary
66 Posts

Posted - Sep 12 2005 :  8:07:22 PM  Show Profile
quote:
i know a lot of people set the error checking in the IDE to treat warnings as errors, so introducing unknown #pragma's is not going to be a popular option
So do I. I think everyone who sets that option also disables some 'only information' or other insane warnings with
#pragma warning (disable:####)
In our case the price of VA pragma mark support would be to disable that pragma check.
Go to Top of Page

jmihalicza
Ketchup Master

Hungary
66 Posts

Posted - Sep 12 2005 :  9:18:41 PM  Show Profile
Typical usage:
#pragma mark -
#pragma mark Group1
// contents of Group1 mark scope
#pragma mark -
// some stuff in global mark scope
#pragma mark -
#pragma mark Group2
// other stuff
#pragma mark -
// ungrouped stuff
#pragma mark -
// other ungrouped stuff
There are no strict rules, the marking style differs from person to person.
As #region really groups #pragma mark just annotates/separates code.
It is not trivial to treat them the same way.
Sometimes recursive grouping using pragmas is achieved this way:
#pragma mark -
#pragma mark Group1
// ...
#pragma mark Group1 - SubGroup1
// ...
#pragma mark Group1 - SubGroup2
// ...
#pragma mark Group2
// ...
#pragma mark -
I can't try the effect of the pragmas inside a function now, but I guess the IDE doesn't care about the scope, it probably just mixes the function heads and pragma lines according to the order in the source code.

Quick ideas for VA - not really though them over:
  • Yes, the list in ALT-M seems to be obvious
  • I don't agree with ALT-up/down jumping to them, it would be confusing. The marks are on a higher level, there is a need for new commands jumping forward/backward on these marks only, for ex. CTRL-ALT-up/down
  • Having these marks/regions recognized there is a corresponding group name for each source line (can be empty, or composed from more names in the case of region hierarchy). This group name could be displayed in FSIW, tooltips, HCB.
Go to Top of Page

jmihalicza
Ketchup Master

Hungary
66 Posts

Posted - Sep 12 2005 :  10:13:31 PM  Show Profile
Some additional thoughts.

ALT-m directly followed by a left arrow could collapse the list/tree only to the marks/regions (in case of region hierarchies further left/right arrows could close/open the different levels).


This pragma mark stuff is a kind of annotation. Another example for such annotation is the TODO comment that has different highlight in KDevelop.
Currently VA tries to rev.eng. the code to find out what happens. There are aspects that don't appear directly in the code (unfinished code parts, time critical sections, not optimal quick solutions etc.) but the coder could annotate it.
In big projects there can be different reasonable groupings of the source files depending on the point of view. It would be easy to put the important keywords to a comment line in the beginning of the file.
I feel I am getting too general, let's see some examples what I mean.
x.cpp first line:
/*VA file keywords: core database module, speed critical, coder:jmihalicza */
In OFIW/FSIW there would be another field with a corresponding filter text box where I could search for files having the given keyword(s).

Let's suppose I am working on a given part of the program (usually a subdirectory, but it can happen that I have to maintan something that appears spread over different source paths). Using keywords I could lock some of them to automatically present in the filter and only the interested area pops up each time. This is a bit similar to the file name filter discussed somewhere else.

Sometimes symbols need to be annotated, optionally signed with user ID.
Example:
class IDatabaseObserverClass /*VA symbol keywords: interface, observer, coder:jmihalicza */


I miss these annotation possibilities in current IDEs.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15980 Posts

Posted - Sep 14 2005 :  7:33:10 PM  Show Profile
is it me or is the scope of this idea growing as we go along?

in VS 2003 you can specify specific words in comments as "tokens" that then show up in the task list, if you ask it nicely.

tools menu -> options -> environment -> task list

you may also need to right click on the tasks window and change the "show tasks" setting. i use this to track TODO notes, but i only get items for the current file listed. so having something produce a list of all tokens in the current solution makes sense. i am not certain this belongs in VA, but the idea is certainly interesting.

there are already keyboard shortcuts to fold and unfold code in the IDE, and i have a feeling relying on pressing left or right arrows quickly after using alt_m would confuse people.

alt_m followed by CTRL_M + CTRL_M does the same job. not quite so intuitive, but it is safer.

i need to fiddle around a bit with some C# code and see how this looks from that perspective. ideally the same idea should apply to C++, managed C++ and C#.

zen is the art of being at one with the two'ness
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15980 Posts

Posted - Oct 05 2005 :  3:34:16 PM  Show Profile
sorry about the delay, i got side tracked with other things. after a bit of experimentation i have pinned down:

C++ and managed C++ in VS 2005, use:

#pragma region <region name>
#pragma endregion


C# in both VS 2003 and VS 2005, use:

#region <region name>
InitializeComponent();
#endregion

notice that the IDE wants these tags at the same indent level as the surrounding code

C++ and managed C++, no native support in VS 2003


i was going to include the screen shot of the mac IDE in action in the case, but the site is currently down, and i have not had any luck finding an equivalent screen shot *mutters*

the original idea of placing the pragma / region names into the alt_m list makes sense. allowing for the "#pragma mark" in C++ with VC6 and VS2003 we seem well covered.

case=808

zen is the art of being at one with the two'ness
Go to Top of Page

jmihalicza
Ketchup Master

Hungary
66 Posts

Posted - Oct 05 2005 :  9:45:17 PM  Show Profile
Not that good ones, but better than nothing...
http://www.google.com/images?q=xcode-orgmethods.jpg thumbnail of image from the page that disappeared
http://aaron.bignerdranch.com/cocoastyle/ middle of the page (search for pragma)
http://scrap.dasgenie.com/articles/2005/07/08/less-known-facts-about-subethaedit-modes
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
15980 Posts

Posted - Oct 06 2005 :  3:18:43 PM  Show Profile
it never occurred to me that the page was going to disappear so completely *rolls eyes*

the picture at the second link is a good example of the effect, thank you

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
© 2019 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000