Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Code formatting

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
glynn.morgan Posted - Jun 05 2007 : 04:49:13 AM
Would be nice to improve on the Alt-F8 code re-indent functionality, to actually reformat braces as per user preferences. Does anyone remember the UNIX Indent utility?

Good when getting code from 3rd parties to conform to project standard.

As you already have language parsers built-in, I think this would be very easy for you to implement.
20   L A T E S T    R E P L I E S    (Newest First)
hotzenplotz Posted - Jun 27 2008 : 7:15:08 PM
Well, maybe I'm paranoid, but in the presence of macros I consider every non-whitespace modification to be "dangerous" :)
Ok, when you consider what you can do with macros even whitespace modifications can change the behaviour of the program, e.g. when you use macros to turn non-strings into strings, and then pass that string to some code that parses it (*shudder*). But, well, one has to draw the line somewhere.

BTW: ProFactor Stylemanager seems to not touch whitespace when it's part of the argument list for a macro. Annoying when you want to eliminate "space after (" and "space before )" and things like that, but I sure can understand why they made it like that.
mwb1100 Posted - Jun 27 2008 : 4:10:11 PM
quote:
Originally posted by feline

I am not sure why inserting the "void" keyword is dangerous.



For C++ code it should not make a difference as far as I know (but I wouldn't be astounded of someone pointed out some situation where it was significant).

However, for C code, an empty parameter list is different from a parameter list that has the void keyword. In the first case you essentially saying there's no information about the parameter list, while with the void keyword you're explicitly stating there are no parameters.
feline Posted - Jun 27 2008 : 10:49:50 AM
I am not sure why inserting the "void" keyword is dangerous.

However I am wary of any form of automated code editing, and I would not expect VA to do any of this behind your back, even if we did do code formatting. If it breaks something then the problem could be quite hard to find, since you did not know about the edit.
hotzenplotz Posted - Jun 26 2008 : 6:26:55 PM
Some of the "dangerous" things that GC can do:

===============================================================================
-code_decl_add_void-
-no-code_decl_add_void- (DEFAULT)
===============================================================================

Force the "void" keyword in a function declaration if nothing is
specified.
Example :

before
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int function()
{
}

after
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int function(void)
{
}

===============================================================================
-code_decl_move_top-
-no-code_decl_move_top- (DEFAULT)
===============================================================================

Move all local variables declaration to the top of the corresponding
statement.
Example :

-code_decl_move_top-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void main(void)
{
int a, b;

a = b = 0;
while(a)
{
}

int c; <= declaration
c = 10;
}

after
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void main(void)
{
int a, b;
int c; <= declaration has been moved

a = b = 0;
while(a)
{
}

c = 10;
}
===============================================================================
-code_decl_move_affect-
-no-code_decl_move_affect- (DEFAULT)
===============================================================================

Move initialization in local variables declaration just after the
declaration.
Example :

-code_decl_move_affect-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void main(void)
{
int a = 0;
int c = a + 1;
}

after
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void main(void)
{
int a;
int c;

a = 0; <= initializations has been moved
c = a + 1;
}

Note(s) :
- Be careful because this option sometimes does not work well. That's
why it's set to FALSE by default.




And to give you an idea what GC does to just bug you:
(That's just ONE out of many such options, many of which are on by default, like this one)

===============================================================================
-cmt_decl_before- (DEFAULT)
-no-cmt_decl_before-
===============================================================================

Add a separator before local declarations.
-cmt_decl- must be enabled.
Example :

-cmt_decl_before-

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int a(void)
{
/*~~~~~~~~~~~~~~~~~~*/
unsigned int var;
long b;
/*~~~~~~~~~~~~~~~~~~*/

var = 0;
}

-no-cmt_decl_before-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int a(void)
{
unsigned int var;
long b;
/*~~~~~~~~~~~~~~~~~~*/

var = 0;
}
feline Posted - Jun 20 2008 : 10:19:16 AM
Those options dialogs do not look to bad, but already you are saying you need a load more options.

What do you mean about the crazy stuff GC does? When I used GC, quite a while ago, it just formatted my source code, which is what you are asking for. It had a *lot* of options, but this is what tends to be required to keep most people happy.
hotzenplotz Posted - Jun 13 2008 : 7:58:03 PM
Sure can do.
Would be easier if you guys had allowed attachments, but since there is imageshack...

Indentation:


Braces:


Line wrapping:


----

Really not that scary. Very clear and well arranged, and not *that* many options. Adding a 4th tab for whitespace between keywords and brackets, and maybe 5th for ... well something else, would still not make this options dialog something to be afraid of :)

I really would like this in 2 situations:
1) When I write new code, having VAX to re-style my C++ code, just like VS does in the C# editor
2) When I work with someone else's code, and don't want to fire up a tool/plugin that takes like a minute to re-style a selection (read: profactor stylemanager, which my company just bought a lincense for for me)

p.S.: I'm talking about formatting *whitespace* here, not the crazy stuff that GC does. Just whitespace, outside of comments, outside of macros - after all that's still hard enough to do.
feline Posted - Jun 12 2008 : 07:58:35 AM
quote:
Originally posted by hotzenplotz

Have a look at Eclipse' built-in formatter for C++. Most of what I think makes sence is already in there. Really easy to understand, nicely layed out dialog, nothing to be afraid of (neither as a user nor as a developer). Toss in some missing things like "insert space between flow-control-keyword and opening brace", "insert space before opening brace of function call" (and some 10-20 more like there) and you have a pretty decent formatter.


Can you post a screen shot of what you are talking about? I have downloaded Eclipse but it will not run without Java being installed. I am not interested in installing various things just to have a look at a screen in the options dialog

Adding 10-20 more options on top of the set of options it comes with sounds like we are going to need a *lot* of options to control formatting, which is one of the things we are trying to avoid.

Code formatting has been discussed internally, but I don't know if it will ever happen or not.
mwb1100 Posted - Jun 12 2008 : 01:52:41 AM
quote:
Originally posted by accord
Have you tried the latest version of this plug-in? http://www.profactor.co.uk/stylemanager_screenshots.php


I notice from the screenshot that they are VAX users.

Also, does anyone here have any opinions on PolyStyle (http://www.polystyle.com/)? I'm too lazy, err, busy to trial these at the moment.
hotzenplotz Posted - Jun 11 2008 : 8:00:48 PM
No, not the latest version. But an older one (about 6 to 12 month old now). Had some hiccups IIRC, but don't ask me what exactly.
Will try again however, that is if the current demo runs on my Windows - after all I had an older demo installed ages ago.

I just remember one of the tools broke my code (changed something that altered the meaning - some brackets or stuff), anotherone was terribly slow (and I mean REALLY slow), and still anotherone was a badly limited demo (no whole-file format, only N formats for the demo -- N begin 5 or 10 or something). Oh yes, one of them just told me that it can't format my file because blah (macro usage or whatever. duh, stupid tool, just try and do your best - if some indentations are off I can fix them manually, no big deal). And all the others just were not flexible enough, or just failed far too often to correctly parse the code.
accord Posted - Jun 11 2008 : 4:44:39 PM
>(i.e. I couldn't find any tool that
> really just worked - at least not for VS)

Have you tried the latest version of this plug-in? http://www.profactor.co.uk/stylemanager_screenshots.php
I will try it, because it seems to good.
hotzenplotz Posted - Jun 10 2008 : 11:37:50 AM
I know this discussion has been going on for quite some time, but I just have to ask again: are you considering to implement C++ code formatting in VAX (or another distinct formatting-tool)?
I would easily be willing to pay 50-100$ for a license for a tool that meets my requirements. And I don't believe the options are the most difficult part. I believe the most difficult part ist the parser, and you should have most of what you need (maybe all of it) in VAX already.
Once you've figured out what each character/token represents that question "how shall I format this" shouldn't be that hard.

Have a look at Eclipse' built-in formatter for C++. Most of what I think makes sence is already in there. Really easy to understand, nicely layed out dialog, nothing to be afraid of (neither as a user nor as a developer). Toss in some missing things like "insert space between flow-control-keyword and opening brace", "insert space before opening brace of function call" (and some 10-20 more like there) and you have a pretty decent formatter.
The Netbeans formatter also isn't that bad. (Maybe even better than the Eclipse one)

With Visual Studio integration this would really be a nice tool. Would save me a lot of trouble.

I don't know how big the market for a C++ code formatter (with Visual Studio integration) really is, but at least I know it's not currently flodded (i.e. I couldn't find any tool that really just worked - at least not for VS). Especially since people frequently ask for such a tool, and since you should IMO already have a usable parser to build on, I think it would at least be worth thinking about.
feline Posted - Feb 26 2008 : 07:53:02 AM
Rain Dog that site, and the screen shots, are the very thing we are trying to avoid doing in VA. We do not want to have hundreds, if not thousands, of code formatting options.

mwb1100 it is quite possible that GC allows you to do that, but I never found the right combination of options. From memory, and it was a while ago I tried, there were a LOT of options. Finding the specific option I wanted was often quite an undertaking.
mwb1100 Posted - Feb 25 2008 : 8:03:33 PM
quote:
Originally posted by feline
So the curly bracket to start a function is on a new line, but all internal curly brackets are on the same line as the item they are linked to. I tried, and failed, to make GC do that.



I haven't tried GC but I'm surprised that it wouldn't support that format since that's the K&R format, which is one of the 3 or 4 that usually are involved in the Brace Placement Religious Wars.
Rain Dog Posted - Feb 25 2008 : 3:33:31 PM
If you look at how resharper and other tools do it, they provide mechanisms for sepcifying how braces, spaces, etc should be placed on each group of things that can be associated with braces, etc.

For example: You have the option to set brace style on for loops, while loops, if/else loops, functions and class/struct definitions.

Here is a product for VS:
http://www.profactor.co.uk/stylemanager_screenshots.php
feline Posted - Jan 14 2008 : 2:10:45 PM
Maybe, but my personal experience suggest otherwise.

At my last job I was once told that the official code standard required curly brackets like this:

void testFunction(int a, int b)
{
    if(a > b) {
        // do something
    }
}


So the curly bracket to start a function is on a new line, but all internal curly brackets are on the same line as the item they are linked to. I tried, and failed, to make GC do that.

Turning to the forum, people regularly ask for "code formatting" and want variable declarations or parameters vertically aligned, but then they start tossing in special cases when asked to consider a 60 character type.

I am not saying it cannot be done, but there are so *many* "little" details people get passionate about...

This is a very popular idea, but also quite a complex one.
Rain Dog Posted - Jan 11 2008 : 8:59:27 PM
I don't buy the "thousands of configurations". If you look at ReSharper or any Java IDE, they offer a great deal of source code formatting options. In my mind there are only 4 or 5 basic styles of formatting that you would generally meet the requirements of 90% of its users.
Kvasi Posted - Jun 20 2007 : 07:54:43 AM
I agree, probably the feature I lack most.
Any aditional indentation option would be a plus (now we can't even configure case label indentation for c/c++).
feline Posted - Jun 05 2007 : 07:56:13 AM
The main reason I suggest GC is simply that it is free. I tried it myself, and after quite a bit of fiddling, I was unable to make it do quite what I needed.

A good illustration of just how many options a program needs *sigh*

There are other code formatting programs out there, but I don't have a lot of experience with them myself, so I hesitate to offer any suggestions.
schoenherr Posted - Jun 05 2007 : 07:44:56 AM
hello feline,
you often suggested gcgreatcode but the author stoped the development and put it to the community. But nothing happens there. And my last try didn't meet my requirements. Sure this tool has hundreds of options but as you said above it would need some more.
feline Posted - Jun 05 2007 : 07:17:46 AM
We are discussing this idea internally. The basic problem is not the code formatting, it is the hundreds, if not thousands of options people will require in order to control the code formatting.

For now you may want to have a look at GC:

http://sourceforge.net/projects/gcgreatcode/

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000