Author Topic: New Plugin: TabVsSpace  (Read 14286 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
New Plugin: TabVsSpace
« on: November 03, 2005, 07:49:35 pm »
Dear community,

it's ready: My first plugin for Code::Blocks :D called "Tabs versus Spaces". Find it attached.

--> What is does
I often get source code files that have mixed tabs and spaces and/or have trailing tabs/spaces on each line. This makes it somethimes hard to compare files since they seem to differ but in fact are basically the same. My plugin provides an easy-to-use interface to convert tabs into spaces and via verca and/or remove trailing tabs/spaces from source code files (in projects).

--> How to compile/install
If this plugin is placed under [CodeBlocks_CVS]\plugins\contrib\TabVsSpace in the source-code distribution of Code::Blocks it should compile fine (relative path's are set). Don't forget to setup "WX_DIR" under custom variables correctly. The update script ([CodeBlocks_CVS]\update*) will autmatically cover TabsVsSpace for distribution.

--> Help wanted
There are 2 known issues where I would like to ask for help:
1.) If a file is opened in the editor that is being changed it should be reloaded automatically. However - I did not found out how a) regognise whether a file is opened in the editor or not b) whether it has pending (unsaved) changes and c) how to force a reload if required.

2.) Unfortunately I have never used the wxWidgets framework before. The settings dialog for the plugin is a bit ugly but I couldn't find out how to place the controls in a way that they are on the same line (especially the statictext and the checkbox control next to it are quite ugly for now.

Comments and help are appreciated.

With regards,

Morten.

Ps.: Is there a common place where to store 3rd party plugins?

Update: An issue has been detected in the intial version. Please read future posting for an updated version.
« Last Edit: November 20, 2005, 12:07:29 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: New Plugin: TabVsSpace
« Reply #1 on: November 03, 2005, 07:58:52 pm »
it's ready: My first plugin for Code::Blocks :D called "Tabs versus Spaces". Find it attached.

...I forgot to add: Allthough I tested the plugin and tried to make it as secure as possible it is still recommended to make a backup of your sources before using TabVsSpace!

Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Re: New Plugin: TabVsSpace
« Reply #2 on: November 03, 2005, 10:29:59 pm »
it's ready: My first plugin for Code::Blocks :D called "Tabs versus Spaces". Find it attached.
interesting plugin, I also know the problem of tabs/spaces. very frustrating. I am going to look to this plugin.

Quote
2.) Unfortunately I have never used the wxWidgets framework before. The settings dialog for the plugin is a bit ugly but I couldn't find out how to place the controls in a way that they are on the same line (especially the statictext and the checkbox control next to it are quite ugly for now.
Perhaps it is usefull for you to try wxSmith plugin. I think it has everything you need.

Quote
Ps.: Is there a common place where to store 3rd party plugins?
There is the CVS, but therefore you have to be an official developer on SourceForge.
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: New Plugin: TabVsSpace
« Reply #3 on: November 03, 2005, 11:08:50 pm »
Quote
Ps.: Is there a common place where to store 3rd party plugins?
There is the CVS, but therefore you have to be an official developer on SourceForge.

Which, judging by precedent, you will be made when your plugin is placed in CVS.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: New Plugin: TabVsSpace
« Reply #4 on: November 03, 2005, 11:40:27 pm »
Hi,

tomorrow I will post some code here on how to update a file that is open. I have done the same for my clearcase plug-in which is ready (probably release tomorrow).

Why no post of the code now : it's on my laptop, which is not here for the moment.

kind regards,
Lieven

PS : if your dialog is no to complicated I might get it nicely, I am not experienced yet; but I am experimenting and getting the hang of it.
Feel free to mail me a screenshot of you dialog gui (note : i don't have that much free time for the moment, but as said when it is a simple dialog I can give it a try).

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: New Plugin: TabVsSpace
« Reply #5 on: November 04, 2005, 09:12:04 am »
Hi,

No need for the screen shot, I downloaded your sources, had to change the cbp a bit (compiler, linker settings).
I got a bunchof warnings or errors, too much to follow. Got rid of those by removing the
            <Compiler>
               <Add option="-pedantic"/>
               <Add option="-Wall"/>
               <Add option="-g"/>
            </Compiler>
part. Guess it's the pedantic thingy.

Nevertheless, was able to build it then, and run it (well to look at configure).

I'll make a wxSmith for you, then you main cpp file will definetaly become cleaner, but you will end up with 2 more sources (the dialog class implementation) and also a xrc file which you need to put in a zip. You can also work without the xrc file, but that I have not tried out yet.

I could already remove includes of :
//#include <wx/statline.h>
//#include <wx/textctrl.h>
//#include <windows.h>

and still build ok.


Now answering your 1)c) question.

This is how you can 'force' reload the current open editor , ie the editor pane that has the focus :

   cbEditor* Editor = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
   if(Editor)
   {
      Editor->Reload();
   }


kind regards,
Lieven

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: New Plugin: TabVsSpace
« Reply #6 on: November 04, 2005, 09:44:10 am »
Perhaps it is usefull for you to try wxSmith plugin. I think it has everything you need.
Thanks for the comments. I first tried wxSmith, indeed. But I have a very basic problem: I am not used to this "grid and sizer based" GUI programming. The GUI's I've developed so far had a discrete resizable grid where I could place my controls. So I am actually a bit lost with StaticSizer, GridSizer, wxExpand and all those things. So I thought it would be better to first understand the basics before starting with a RAD tool. I just haven't found the time yet to read about that. Once I understand the "magic" behind I am going to definetely use a RAD tool -> wxSmith :D.

Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: New Plugin: TabVsSpace
« Reply #7 on: November 04, 2005, 09:48:40 am »
Guess it's the pedantic thingy.
Yes, that's it but on my machine there are just 3 warnings about C99 standard and that's it. What else is it on you machine?

Quote
I'll make a wxSmith for you, [...]
Thanks a lot. The will help me, for sure. I've explained above why I havent used wxSmith ini the first attempt. No I have had a lok inside a wxSmith and XRC file... I guess that might even help me to understand what's going on...

Quote
Now answering your 1)c) question.
Thanks again - I'll give it a try and post an updated version when it's implemented.

With regards,

Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Warning: Issue with TabVsSpace
« Reply #8 on: November 04, 2005, 10:21:53 am »
Warning:
I've just used my plugin on a huge project. It seems that there is an issue with the buffer I am using to read from file. It happens that when the file is written sometimes too much data is written thus resulting in a broken output file. The "good news" is: No data can be lost, only buffer characters are written too much to the file. This seems not to happen if the plugin is used on a single file only.

I am going to look what's happening and going to repost this plugin asap.

Big sorry for that!

Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Updated: New Plugin: TabVsSpace
« Reply #9 on: November 04, 2005, 01:01:02 pm »
I've just updated the issue that I had discovered. Please find attachedf the new version.
What's new:
- Fixed bug with file buffer
- Warning if files are opened in editor that might be affected by the plugin'S operation
- Automatically triggers check for externally modified files after plugin operation.

Morten.


[attachment deleted by admin]
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: New Plugin: TabVsSpace
« Reply #10 on: November 18, 2005, 08:25:55 pm »
I am releasing hereby a new version that reflects the changes done to CVS (HEAD) recently. The version attached to this post will compile under the current CVS HEAD version of Code::Blocks. I furthermore added another project file that makes use of the new global user variables. This should be preferred when using Code::Blocks from CVS.

Please note: This version will not compile with the RC2 SDK, it is for CVS HEAD only. For RC2 please use the version from the previous message.
Morten.

Edit: Removed attached version (an update has been released).
« Last Edit: November 20, 2005, 12:05:14 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: New Plugin: TabVsSpace
« Reply #11 on: November 19, 2005, 02:06:33 pm »
A new version!
Finally I've done the re-design of the settings dialog with (the outstanding) wxSmith plugin. It no longer looks that ugly as in the beginning. Please note that this version will run on CVS HEAD only. For a RC2 version see below.

Morten.

Ps.: wxSmith worked like a charm. Excellent!

Edit: Removed old version, update available.
« Last Edit: December 01, 2005, 08:36:26 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: New Plugin: TabVsSpace
« Reply #12 on: November 26, 2005, 10:37:28 pm »
...another version which resolves some UniCode issues and shows the number of replacements done in the C::B log window. Again: This is for SVN-HEAD only.


Morten.

Edit: Updated and removed old one here, please apply the new version for SVN head.
« Last Edit: January 25, 2006, 09:57:46 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: New Plugin: TabVsSpace
« Reply #13 on: January 25, 2006, 09:56:45 am »
Attached is the updated plugin according to new API as of SVN revision 1808 and above.
Furthermore some enhancements concerning Unicode have been added.
Morten.

Ps.: Warning: Allthough I am using the plugin successfully I don't guarantee that this plugin is 100% working. Please always keep a backup of your sources.

Edit: Removed again because of unresolved issues. :(
« Last Edit: January 25, 2006, 10:02:22 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: New Plugin: TabVsSpace
« Reply #14 on: February 22, 2006, 09:58:24 pm »
Finally the update for the TabVsSpace plugin is ready. I've changed the code to work much better than before and to be Unicode compatible. Furthermotre the plugin is now compatible with the current SVN head. Find the update attached.
With regards, Morten.

[attachment deleted by admin]
« Last Edit: February 22, 2006, 09:59:59 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ