User forums > Using Code::Blocks
AStyle formatting help needed
Jewest:
Dear All,
I have found the astyle formatter and I love it.
There is only on thing that I can not make the formatter do in version 17.12, what I have made working in version 12.11.
What I want:
--- Quote ---if(statment1 == 1) statment1++;
--- End quote ---
or
--- Quote ---if(statment1 == 1)
statment1++;
--- End quote ---
transform in:
--- Quote ---if(statment1 == 1)
{
statment1++;
}
--- End quote ---
What do I have so far?
--- Quote ---if(statment1 == 1)
{statment1++;}
--- End quote ---
But I want the break in to new lines in one single step.
Anyone got a suggestion?
thank you in advance,
Jewest
oBFusCATed:
Can you setup the command line version to do it?
Astyle is not a project we develop, it is an external tool we just integrate in the IDE.
Jewest:
I understand, I had version 12.11 doing what is doing what is supposed todo.
is there are way to debug this? can I see the output to the astyle formatter?
I have a feeling that its the parameter sequence that C::B is sending to aStyle.
oBFusCATed:
As far as I know you can install a command line astyle. You need to use the same version.
Otherwise debugging could be done by building cb with debug symbols/no optimizations and using gdb to step through the code...
Jewest:
I did some digging around.
Source file:
--- Code: ---void main()
{
if(def ==1) def=3;
else def=12;
while(def<12) def--;
}
int Foo(bool isBar)
{
if (isBar)
{
bar();
return 1;
}
else
return 0;
}
switch (foo)
{
case 1:
a += 1;
break;
case 2:
{
a += 2;
break;
}
}
--- End code ---
command with aStyle 3.1 command used: astyle -A1 --indent=spaces=2 -f -j < benchmark.cpp > test.cpp
results in:
--- Code: ---void main()
{
if(def ==1)
{
def=3;
}
else
{
def=12;
}
while(def<12)
{
def--;
}
}
int Foo(bool isBar)
{
if (isBar)
{
bar();
return 1;
}
else
{
return 0;
}
}
switch (foo)
{
case 1:
a += 1;
break;
case 2:
{
a += 2;
break;
}
}
--- End code ---
I see "--add-one-line-braces / -J" in the option window of C::B but apparently I am overlooking the "--add-braces / -j" that I need.
Any suggestions which option to enable on the screen?
Navigation
[0] Message Index
[#] Next page
Go to full version