New Plugin: Code Beautifier

Discussion about CodeLite development process and patches
NilC
CodeLite Enthusiast
Posts: 34
Joined: Fri Sep 14, 2012 1:01 pm
Genuine User: Yes
IDE Question: C++
Contact:

New Plugin: Code Beautifier

Post 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.
You do not have the required permissions to view the files attached to this post.
NilC
CodeLite Enthusiast
Posts: 34
Joined: Fri Sep 14, 2012 1:01 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: New Plugin: Code Beautifier

Post by NilC »

Hot fixes
You do not have the required permissions to view the files attached to this post.
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: New Plugin: Code Beautifier

Post 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
Make sure you have read the HOW TO POST thread
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: New Plugin: Code Beautifier

Post 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
Make sure you have read the HOW TO POST thread
NilC
CodeLite Enthusiast
Posts: 34
Joined: Fri Sep 14, 2012 1:01 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: New Plugin: Code Beautifier

Post by NilC »

Try

Code: Select all

indent_class = true
indent_col1_comment = true //this one for comments
NilC
CodeLite Enthusiast
Posts: 34
Joined: Fri Sep 14, 2012 1:01 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: New Plugin: Code Beautifier

Post 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.
Last edited by NilC on Tue Jul 09, 2013 6:39 pm, edited 4 times in total.
NilC
CodeLite Enthusiast
Posts: 34
Joined: Fri Sep 14, 2012 1:01 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: New Plugin: Code Beautifier

Post by NilC »

Also, here my config
You do not have the required permissions to view the files attached to this post.
NilC
CodeLite Enthusiast
Posts: 34
Joined: Fri Sep 14, 2012 1:01 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: New Plugin: Code Beautifier

Post by NilC »

Improvement patch. New version of Code Beautifier
You do not have the required permissions to view the files attached to this post.
NilC
CodeLite Enthusiast
Posts: 34
Joined: Fri Sep 14, 2012 1:01 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: New Plugin: Code Beautifier

Post by NilC »

Another patch. Fixing arguments.
You do not have the required permissions to view the files attached to this post.
Post Reply