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 » Mon Jun 10, 2013 1:36 pm

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 » Mon Jun 17, 2013 12:23 am

Hot fixes
You do not have the required permissions to view the files attached to this post.

User avatar
eranif
CodeLite Plugin
Posts: 6110
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: New Plugin: Code Beautifier

Post by eranif » Mon Jun 17, 2013 12:35 am

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: 6110
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: New Plugin: Code Beautifier

Post by eranif » Sat Jul 06, 2013 8:54 am

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 » Mon Jul 08, 2013 11:40 pm

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 » Mon Jul 08, 2013 11:46 pm

- 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 » Mon Jul 08, 2013 11:48 pm

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 » Mon Oct 14, 2013 3:48 pm

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 » Tue Oct 15, 2013 12:25 am

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

Post Reply