Autoformat of initialized data structures is UGLY.

The autoformatting apparently applies code-like rules to braces inside of data structure initialization, causing it to turn code like:

prog_uchar myfont[47][5] = {
  {0, 0, 0, 0, 0}, // space!
  {0x3f, 0x48, 0x48, 0x48, 0x3f}, // A
  {0x7f, 0x49, 0x49, 0x49, 0x36},
  {0x3e, 0x41, 0x41, 0x41, 0x22},

Into this ugly bit of stuff:

prog_uchar myfont[47][5] = {
  {
    0, 0, 0, 0, 0  }
  , // space!
  {
    0x3f, 0x48, 0x48, 0x48, 0x3f  }
  , // A
  {
    0x7f, 0x49, 0x49, 0x49, 0x36  }
  ,
  {
    0x3e, 0x41, 0x41, 0x41, 0x22  }
  ,

I think it ought to leave data initializers entirely alone?

I'd agree that it shouldn't format so. Though I don't know about "entirely alone".

The source for the formatter is here of course, if anyone wants to take a stab at it:
http://svn.berlios.de/viewcvs/*checkout*/arduino/trunk/app/tools/AutoFormat.java

Here is what eclipse did to a similar piece of java:
Before auto format:
byte [] [] myfont= {
{0, 0, 0, 0, 0}, // space!
{0x3f, 0x48, 0x48, 0x48, 0x3f}, // A
{0x7f, 0x49, 0x49, 0x49, 0x36},
{0x3e, 0x41, 0x41, 0x41, 0x22}};

After:
byte[][] myfont = { { 0, 0, 0, 0, 0 }, // space!
{ 0x3f, 0x48, 0x48, 0x48, 0x3f }, // A
{ 0x7f, 0x49, 0x49, 0x49, 0x36 }, { 0x3e, 0x41, 0x41, 0x41, 0x22 } };

The lines that did not end in a comment were concatenated (presumably to the default width)

I have a suggestion for future editions of the arduino IDE.

Use an external program to format the code. Specifically, use gnu indent. Indent can be configured to show code in several different styles, so individual users can tweak it. There should be GPL versions for all the relevant platforms. That way the arduino code doesn't have to do something outside of it's "core competence," and the developers can concentrate on more vital areas.

eh?

What is its core competency? :slight_smile: They wrote an IDE instead of using eclipse.

I don't like the idea of more shelling out, and having to package stuff for any platform. It should be in java so it will work on any platform without multiple copies and etc.