Page 1 of 1

New Plugin: Code Beautifier

Posted: Mon Jun 10, 2013 1:36 pm
by NilC
This code formatter, based on "Uncrustify Code Beautifier", support C++11.

Correct formatting lambdas, empty initialiling block (list "new Rect({}, {})"), others. Has more than 350 settings.

Re: New Plugin: Code Beautifier

Posted: Mon Jun 17, 2013 12:23 am
by NilC
Hot fixes

Re: New Plugin: Code Beautifier

Posted: Mon Jun 17, 2013 12:35 am
by eranif
Thanks for sharing this plugin.
I see that it does not support CMake build for codelite on Mac / Linux..
I will look at it tomorrow and will update the proper files

Thanks,
Eran

Re: New Plugin: Code Beautifier

Posted: Sat Jul 06, 2013 8:54 am
by eranif
Hi NilC,

I finally got the time to have a look at this plugin.

I compiled it under Windows (had to tweak the patch a bit) and it runs
However, the first file I tried to indent - the output was less than desire...

here is the source code I tried to indent:

Code: Select all

#include <wx/app.h>
#include <wx/event.h>
#include "MainFrame.h"
#include <wx/image.h>

// Define the MainApp
class MainApp : public wxApp
{
public:
    MainApp() {}
    virtual ~MainApp() {}

    virtual bool OnInit() {
        // Add the common image handlers
        wxImage::AddHandler( new wxPNGHandler );
        wxImage::AddHandler( new wxJPEGHandler );
        wxImage::AddHandler( new wxGIFHandler );

        MainFrame *mainFrame = new MainFrame(NULL);
        SetTopWindow(mainFrame);
        return GetTopWindow()->Show();
    }
};

DECLARE_APP(MainApp)
IMPLEMENT_APP(MainApp)
and here is how it looks after I "beautified" it:

Code: Select all

#include <wx/app.h>
#include <wx/event.h>
#include "MainFrame.h"
#include <wx/image.h>

// Define the MainApp
class MainApp : public wxApp
{
public:
MainApp() {
}
virtual ~MainApp() {
}

virtual bool OnInit() {
	// Add the common image handlers
	wxImage::AddHandler( new wxPNGHandler );
	wxImage::AddHandler( new wxJPEGHandler );
	wxImage::AddHandler( new wxGIFHandler );

	MainFrame * mainFrame = new MainFrame(NULL);
	SetTopWindow(mainFrame);
	return GetTopWindow()->Show();
}
};

DECLARE_APP(MainApp)
IMPLEMENT_APP(MainApp)
Everything moved to the left (I think its because I have function definitions in the header file)

Maybe you can give me some hint on which settings I should tweak in the (very long) uncrustify.cfg file?
For now, I am going to add the sources to git - but they won't be compiled with codelite (this is so I can work on them on different machines)

General comments:

- I think that the plugin should honor the editor settings (e.g. in the "Global Editor Preferences -> Indent" I have use spaces for idnenting, this should be honored by the plugin as well)
- Maybe providing a UI for the configuration file with the most common flags ( I can do this )
- The configuration file should go to 'config' folder
- Keyboard shortcut
- Allow indenting selection only

Thats it for now,
Eran

Re: New Plugin: Code Beautifier

Posted: Mon Jul 08, 2013 11:40 pm
by NilC
Try

Code: Select all

indent_class = true
indent_col1_comment = true //this one for comments

Re: New Plugin: Code Beautifier

Posted: Mon Jul 08, 2013 11:46 pm
by NilC
- I think that the plugin should honor the editor settings (e.g. in the "Global Editor Preferences -> Indent" I have use spaces for idnenting, this should be honored by the plugin as well)
- Maybe providing a UI for the configuration file with the most common flags ( I can do this )
- The configuration file should go to 'config' folder
- Keyboard shortcut
Agree. I'll work on 1, 3 and 4 points when I'll get free time. Also need to think about formatting after "Implements All Un-implemented Functions" command.
- Allow indenting selection only
Hmm, it should works already. Uncrustify Code Beautifier use just whole file, so i'm using uncrustify.buffer file for copy just selection. Don't forget about settings, which I posted early.

Re: New Plugin: Code Beautifier

Posted: Mon Jul 08, 2013 11:48 pm
by NilC
Also, here my config

Re: New Plugin: Code Beautifier

Posted: Mon Oct 14, 2013 3:48 pm
by NilC
Improvement patch. New version of Code Beautifier

Re: New Plugin: Code Beautifier

Posted: Tue Oct 15, 2013 12:25 am
by NilC
Another patch. Fixing arguments.