I'm pretty sure it'sn't the most popular plugin of Code::Blocks, but when it comes handy it's good to have it working :)
The original plugin uses AStyle 1.15.3, the new plugin uses AStyle 1.17.0-dev CVS.
There was a big change that makes it easier to use: std::istream instead of the AStyle stream iterator.
The current implementation had a few problems when applying the settings, that's now fixed.
I added the Bracket type combobox so now you can decide if you want Break, Attach, Linux or None when you customize.
I hope it be accepted to replace the current CVS version.
Well, the link, of course: http://gda.utp.edu.co/~ceniza/CodeBlocks/astyle.zip
Wouldn't it be better to create a patch against Code::Blocks CVS and submit it (http://sourceforge.net/tracker/?atid=707418&group_id=126998&func=browse)?
Quote from: fvbommelWouldn't it be better to create a patch against Code::Blocks CVS and submit it?
Yes that is better for patches. But, I think, we have an exception here since he updated to the newest astyle code too (which we keep in our CVS)...
Anyway, thanks Ceniza. Your changes have been applied to CVS :)
Yiannis.
With the new astyle plugin,
the indentation of if(){} blocks is wrong,
when using K&R style (at least there i found it happen),
it's indented one size too much.
this sample, reference "K&R" style
void Notify() {
if(!m_frame->IsRunning()) {
m_gauge->SetValue(0);
}
else {
if(!m_bInit) {
if(m_thread->GetRSSLength()) {
m_bInit = true;
}
}
else {
m_gauge->SetValue(m_thread->GetRSSPos());
m_frame->SetStatusText(
wxString::Format(wxT("Converting Data... %i of %i"),
m_thread->GetRSSPos(),
m_thread->GetRSSLength()
)
);
}
}
}
astyled with "K&R"
void Notify() {
if ( !m_frame->IsRunning() ) {
m_gauge->SetValue( 0 );
}
else {
if ( !m_bInit ) {
if ( m_thread->GetRSSLength() ) {
m_bInit = true;
}
}
else {
m_gauge->SetValue( m_thread->GetRSSPos() );
m_frame->SetStatusText(
wxString::Format( wxT( "Converting Data... %i of %i" ),
m_thread->GetRSSPos(),
m_thread->GetRSSLength()
)
);
}
}
}
is indented one size too much !
btw, the K&R preview-sample misses a bracket '}'
namespace foospace {
int Foo() {
if (isBar) {
bar();
return 1;
} <<<<<<<<<<<<<<<<<<<<<missing
else
return 0;
}
}
Thanks for your feedback.
When I updated and "fixed" the plugin I focused in the Custom style and considered the predefined ones were right, but it seems I was wrong.
I had to enable and disable even more options to get the right results in the predifined styles. Hadn't noticed the sample was wrong for almost all of them.
I tested all the styles this time and they seem to be working as they should now.
I'd really need to make a file to test all the cases, pass it through AStyle, AStyle plugin and compare the results.
By now I'll upload the new files (just 2) which I had to modify. I'll try to make the test file later (I really need to sleep first).
I'll also include a 3rd file (the resource file) where I made a little change.
New files: http://gda.utp.edu.co/~ceniza/CodeBlocks/astyle-020705.zip
Quote from: CenizaThanks for your feedback.
Thanks for your update, works fine now !Quote from: CenizaI'll try to make the test file later (I really need to sleep first).
please don't hurry ! we look forward to hear from you again...
Hey, I played a bit trying to fool Source code formatter (AStyle) plugin (finalbeta 1.0), and found nice benchmarks that make it quite easy. I thought that maybe someone also find this resource valuable, so here it goes: The 2004 Allegro ScreenHack (http://www.allegro.cc/forums/view_thread.php?_id=331094&page=0).
Most of the sources compiles & runs if Allegro game programming library (http://alleg.sourceforge.net/) is set up.
Btw. I found one example that worked *almost* correctly (function alert should go into single line, I suppose):
before (http://img102.imageshack.us/img102/3500/00astylebefore2ex.jpg)
after (http://img102.imageshack.us/img102/5894/02astyleafter7xi.jpg)
Allegro... my old fellow :)
The ScreenHack entries really are a good source for testing, even though they won't test everything (most people uses C so it won't test namespaces, classes, ...).
QuoteBtw. I found one example that worked *almost* correctly (function alert should go into single line, I suppose):
In the original file the call to alert is split and AStyle will keep it split too with some indentation, so... it works correctly? :P
QuoteThanks for your update, works fine now !
Glad to read it :)
Quoteplease don't hurry ! we look forward to hear from you again...
Ok. When I get it done I'll comment about it here.
QuoteNew files: http://gda.utp.edu.co/~ceniza/CodeBlocks/astyle-020705.zip
CVS updated. Thanks :)
Yiannis.
The new AStyle plugin completely deletes lines when they contain German umlauts, e. g.
// **für Test auf U0***************
or
if (U1RBL==0x07) // Änderung
{
...
}
Seems this makes it unusable :-(
Any idea?
Jochen