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
 Syntax Coloring For Delegates and Capture
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

invino4
Senior Member

35 Posts

Posted - Apr 04 2009 :  04:39:58 AM  Show Profile  Reply with Quote
My group and I have been writing a lot of asynchronous and event-based code lately and our coding patterns call for a lot of anonymous delegates. A very common problem people are having is quickly distinguishing in the code which pieces are going to execute immediately as part of the function and which are part of a delegate body that will be executed later. Plus, in an anonymous delegate body there can be tricky issues with doing variable capture so weG??d love to make the editor call out when this is occurring so the developer is sure to notice. I was wondering if Visual Assist could enhance its existing syntax coloring to include this as a feature? Perhaps an idea would be to darken the color of delegate body text background (by say 20%) while also coloring captured variables some configurable color (say defaults to yellow). For example:



It would be even better if this occurred recursively inside delegates so that delegates defined within delegates were color differently still so they were always distinguishable:



I know this would increase the readability of our code significantly!

- Jason.

Edited by - invino4 on Apr 04 2009 04:41:18 AM

feline
Whole Tomato Software

United Kingdom
18755 Posts

Posted - Apr 07 2009 :  6:05:36 PM  Show Profile  Reply with Quote
I am assuming this is C# code, is this correct?

If we try and do this then people are going to want functions picked out, inline functions, etc. It could quickly become quite "interesting".

Have you considered using a VA Snippet entry for a delegate that adds marker comments, so you end up with something like:

Action b = () =>
{ /*** DELEGATE START ***/
    foo.SomeMetohd();
    i++;
} /**** DELEGATE END ****/


I know it is not the same, but it might help.

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

invino4
Senior Member

35 Posts

Posted - Apr 07 2009 :  8:00:30 PM  Show Profile  Reply with Quote
(Yeah C#! => but the idea probably applies to any language.)

HaHa! Functions, did you say? Now that you mention it, coloring functions would be great too!

In fact this could quite easily be a general feature that is the inverse of the current syntax color coding. In today's syntax color coding you primarily set the foreground color for items based on the syntactic context. This would be setting their background color based on syntactic scope/locality.

E.g.
Base Coloring:
Namespace scope bg=light green
Class body (decl, fields, etc.) bg=pale blue
Function definition bg=white

Modifiers: (apply on top of the scope/locality color)
inlined delegate bg=(10% darker)
inline class bg=(10%darker)

With the base colors being very light pastel to start allows several step downs from modifiers that would easily distinguish cross of context and the modifiers can be applied repeatedly for nested scopes. If you want to make it configurable you can allow users to set the base colors and the steepness of the modifier gradient for each category.

Surely the editor already has this scope information since it is displayed in the VA toolbar?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18755 Posts

Posted - Apr 08 2009 :  11:28:28 AM  Show Profile  Reply with Quote
Have you ever tried setting:

VA Options -> Advanced -> Display -> Highlight current line = * Foreground and background

You will notice that when VA does this you loose the foreground syntax highlighting. Basically this is happening since we are sneaking around behind the IDE's back, doing things it does not know about.

Also consider anyone who is not using White as the background colour in the editor. Black is a fairly common background colour, while others prefer off white as their background colour, I know I do.

This idea has a certain appeal, but I am not sure what to try and do.

After all, people are not going to want to stop just at the function, what about switch statements, if statements, etc.

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

invino4
Senior Member

35 Posts

Posted - Apr 08 2009 :  3:41:00 PM  Show Profile  Reply with Quote
Hmm...tough questions. Some suggetsions:

1.) I realize the difficulty of the background issue in the current product. Perhaps this issue is resolved in Dev10 with the new display engine?
2.) Perhaps modifiers could specify a negative gradient (-10%) for those that use a dark background (e.g. Black)?
3.) I would think other sub-functional scopes (if, switch, etc) would all be modifiers rather than bases. I think it would be up to you guys how many you wanted to provide configuration for. I didn't think of if/switch since they happen so frequently I would find it distracting, but I agree, you never really know what people will want. I guess you'd have to pick a set to start with and see what people say?

Actually it just occurred to me that you could unify bases and modifiers by simply having a flat list of scopes and for each you can either pick a fixed color OR a gradient percentage. If you pick a color its that color, if you pick a gradient then it applies the gradient to the parent scope's background. That might make the configuration control dialogs easier to produce and give people a lot of display choice.

- Jason.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18755 Posts

Posted - Apr 09 2009 :  1:08:22 PM  Show Profile  Reply with Quote
I see why you want this, but I am really not sure about trying to change the background colour like this. I have asked internally to see what people think of this idea.

The screen shots show the problem, but what would be a good solution?

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