AStyle version: 1.23
and the arguments is:
--style=allman --indent=spaces --indent-cases --indent-preprocessor --pad-oper --unpad-paren --keep-one-line-statements --keep-one-line-blocks --convert-tabs --suffix=none
If use this arguments, it's can be format this code FROM:
int main()
{
for(int i=0;i<10;++i)
{
cout << i << endl;
}
return 0;
}
TO:
int main()
{
for (int i = 0; i < 10; ++i)
{
cout << i << endl;
}
return 0;
}
NOTICE:
for{HERE is a space}(int i = 0; i < 10; ++i)
But, if i setting AStyle Plugin like below picture show, it's only format the code TO:
int main()
{
for(int i = 0; i < 10; ++i)
{
cout << i << endl;
}
return 0;
}
IN for and (, NOT space in there.
[attachment deleted by admin]
I'am sorry! It's seems works now. SVN6080
if i selected the option on cursor position.
[attachment deleted by admin]
Still have problems, if this option is enabled, the following code to have a problem.
#include <windows.h>
int main()
{
for (int i = 0; i < 10; ++i)
{
cout << i << endl;
}
::MessageBox (0, 0, 0, 0);
return 0;
}
::MessageBox(0, 0, 0, 0); formated to ::MessageBox (0, 0, 0, 0);
Quote from: Loaden on January 24, 2010, 04:41:59 PM
::MessageBox(0, 0, 0, 0); formated to ::MessageBox (0, 0, 0, 0);
Well if you have enabled the option "Insert space padding around parenthesis on the outside" as shown in the screenshot of the previous post that's exactly what has to happen...?!
Quote from: MortenMacFly on January 24, 2010, 04:45:59 PM
Quote from: Loaden on January 24, 2010, 04:41:59 PM
::MessageBox(0, 0, 0, 0); formated to ::MessageBox (0, 0, 0, 0);
Well if you have enabled the option "Insert space padding around parenthesis on the outside" as shown in the screenshot of the previous post that's exactly what has to happen...?!
It's seems lost this option.http://astyle.sourceforge.net/astyle.html#_unpad-paren (http://astyle.sourceforge.net/astyle.html#_unpad-paren)
--unpad-paren / -U / --unpad=paren (depreciated)
Remove extra space padding around parenthesis on the inside and outside. Any end of line comments will remain in the original column, if possible. This option can be used in combination with the paren padding options pad‑paren‑out and pad‑paren‑in above. Only padding that has not been requested by other options will be removed.
For example, if a source has parens padded on both the inside and outside, and you want inside only. You need to use unpad-paren to remove the outside padding, and pad‑paren‑in to retain the inside padding. Using only pad‑paren‑in would not remove the outside padding.
if ( isFoo( a, b ) )
bar ( a, b );
becomes (with no padding option requested):
if (isFoo(a, b))
bar(a, b);
example, this code:
#include <windows.h>
int Foo (bool isBar)
{
if ( isBar () )
{
bar ();
return 1;
}
else
return 0;
}
int main()
{
for (int i = 0; i < 10; ++i)
{
cout << i << endl;
}
::MessageBox (0, 0, 0, 0);
return 0;
}
How to format it to:
#include <windows.h>
int Foo(bool isBar)
{
if (isBar())
{
bar();
return 1;
}
else
return 0;
}
int main()
{
for (int i = 0; i < 10; ++i)
{
cout << i << endl;
}
::MessageBox(0, 0, 0, 0);
return 0;
}
but not:
#include <windows.h>
int Foo(bool isBar)
{
if(isBar())
{
bar();
return 1;
}
else
return 0;
}
int main()
{
for(int i = 0; i < 10; ++i)
{
cout << i << endl;
}
::MessageBox(0, 0, 0, 0);
return 0;
}
[attachment deleted by admin]
Quote from: Loaden on January 24, 2010, 05:47:53 PM
example, this code:
[...]
How to format it to:
[...]
but not:
[...]
That's simply not possible with the set of options given.
Quote from: MortenMacFly on January 24, 2010, 06:42:03 PM
Quote from: Loaden on January 24, 2010, 05:47:53 PM
example, this code:
[...]
How to format it to:
[...]
but not:
[...]
That's simply not possible with the set of options given.
Do not, AStyle can do that!Launching tool 'AStyle': D:\LoveDEV\tool\AStyle.exe --style=allman --indent=spaces --indent-cases --indent-preprocessor --pad-oper --unpad-paren --keep-one-line-statements --keep-one-line-blocks --convert-tabs --suffix=none D:\Projects\fsefe\main.cpp (in D:\Projects\fsefe)
stdout> formatted D:\Projects\fsefe\main.cpp
Tool execution terminated with status 0
Current code:
#include <windows.h>
int Foo(bool isBar)
{
if( isBar ( ) )
{
bar ( );
return 1;
}
else
return 0;
}
int main()
{
for(int i = 0; i < 10; ++i)
{
cout << i << endl;
}
::MessageBox (0, 0, 0, 0);
return 0;
}
Can formatted to :
#include <windows.h>
int Foo(bool isBar)
{
if (isBar())
{
bar();
return 1;
}
else
return 0;
}
int main()
{
for (int i = 0; i < 10; ++i)
{
cout << i << endl;
}
::MessageBox(0, 0, 0, 0);
return 0;
}[attachment deleted by admin]
And I found a bug: If you run this tool, The CB Editor did not prompt the file has been modified.
[attachment deleted by admin]
Quote from: Loaden on January 25, 2010, 01:11:01 AM
Quote from: MortenMacFly on January 24, 2010, 06:42:03 PM
That's simply not possible with the set of options given.
Do not, AStyle can do that!
Look: I meant it's not possible with the options
given by C::B. You can enhance the plugin if you like and add the appropriate options. It's pretty easy.
Quote from: MortenMacFly on January 25, 2010, 06:26:27 AM
Quote from: Loaden on January 25, 2010, 01:11:01 AM
Quote from: MortenMacFly on January 24, 2010, 06:42:03 PM
That's simply not possible with the set of options given.
Do not, AStyle can do that!
Look: I meant it's not possible with the options given by C::B. You can enhance the plugin if you like and add the appropriate options. It's pretty easy.
But in SVN5731, it's work fine...
OK, I will try it.
Certainly there are problems, I have read the code, my options and CB option is the same. However, the code is not formatted the same.
As another example, thic code:
void test() {}
void func(int i) {}
int main()
{
test();
func(1);
if(int i=0;i<10;++i) test();
return 0;
}
if use run Astyle plugin, it's became to:
void test() {}
void func (int i) {}
int main()
{
test();
func (1);
if (int i = 0; i < 10; ++i) test();
return 0;
}
Notice:
test();
func (1);
AStyle 1.24 release, I think the reason is:
--pad-header / -H
Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...). Any end of line comments will remain in the original column, if possible. This can be used with unpad-paren to remove unwanted spaces.
if(isFoo(a, b))
bar(a, b);
becomes:
if (isFoo(a, b))
bar(a, b);
http://astyle.sourceforge.net/astyle.html (http://astyle.sourceforge.net/astyle.html)
And the : --pad-header will fix this problem. :lol:
Fixed.
http://forums.next.codeblocks.org/index.php/topic,12279.0.html (http://forums.next.codeblocks.org/index.php/topic,12279.0.html)