Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: GeO on June 28, 2010, 10:46:04 pm

Title: cbDiff plugin
Post by: GeO on June 28, 2010, 10:46:04 pm
cbDiff plugin - is a simple plugin, which visually shows the differences between two files.
You can view the differences in table or side by side mode or as a unified diff.
In table and side by side mode you can set the highlight language you want.

Source and cbDiff.cbp with targets for Unix and windows are attached.
Just open the project, build it and install the plugin.
You can use the plugin from menu bar "File->Diff Files..." or from within the editor- and projectcontext menus "Diff with".
You can save the generated diff as .diff file, by clicking "Save as..."
and there are some settings at "Environment Settings->cbDiff Settings".

ToDo list:
 - Make it possible to change the files in the view
 - Improve scroll synchronization done
 - Some problems with large files (like CodeBlocks.cbp) done
 - [Your suggestion here] :lol:

Note for developers:
You can use cbDiff from within your plugin (useful for version control plugins)
look at README it will show you the (ugly :?, but working :)) way.

Thanks to Tatsuhiko Kubo <cubicdaiya@gmail.com> for the diff template library

Changes 1.1.1
* fixed windows bugs reported by daniloz
* reorganized projectlayout
* updated to dtl 1.12 
* some code cleanup

Changes 1.1.01
* added possibility to switch the view mode and the highlight language within the editor
* added settings for default view mode and default highlight language
* added context menu entry "Diff with...": (as suggested by javmss)
   - on project tree it shows the project files and on an editor it shows all open files
* updated dtl to 1.11

Changes since alpha
* Improved scroll synchronization
* No more problems with large files (like CodeBlocks.cbp)
* Updated to dtl 1.09

If you find some bugs or you have some suggestions please report them.

GeO

Some screen shots:

Table:
(http://img704.imageshack.us/img704/958/cbdifftab.th.png) (http://img704.imageshack.us/i/cbdifftab.png/)

Unified:
(http://img163.imageshack.us/img163/1774/cbdiffuni.th.png) (http://img163.imageshack.us/i/cbdiffuni.png/)

Side by Side:
(http://img682.imageshack.us/img682/3875/cbdiffsbs.th.png) (http://img682.imageshack.us/i/cbdiffsbs.png/)

[attachment deleted by admin]
Title: Re: cbDiff plugin [alpha]
Post by: Loaden on July 12, 2010, 12:56:10 pm
Maybe support subversion? diff in two rev?
Title: Re: cbDiff plugin [alpha]
Post by: MortenMacFly on July 12, 2010, 04:24:32 pm
cbDiff plugin - is a simple plugin, which visually shows the differences between two files.
Cool stuff. I'll try out soon.

Maybe support subversion? diff in two rev?
Good point, that would certainly be useful. However, it should not be too specific to SVN or generic enough it also works with other "diff generating" tools (like any other version control diff command).
Title: Re: cbDiff plugin [alpha]
Post by: GeO on July 16, 2010, 07:29:05 pm
Maybe support subversion? diff in two rev?
Yes it's possible to call a "Diff" function from outside (look at the readme),
so other plugin developers of version control systems (like svn, cvs, git, hg, bazaar and so on....) can use it.

Greets GeO
Title: Re: cbDiff plugin [alpha]
Post by: dmoore on July 17, 2010, 01:38:43 am
GeO: Thanks for doing this, should be a very useful tool.

I'm planning to implement version control revision browsing in my FileManager plugin. Will have to figure out a way to allow diff viewing between revisions using your plugin
Title: Re: cbDiff plugin [alpha]
Post by: MortenMacFly on July 19, 2010, 07:16:44 am
cbDiff plugin - is a simple plugin, which visually shows the differences between two files.
Cool stuff. I'll try out soon.
Strange... I am unable to compile this... :-(
Title: Re: cbDiff plugin [alpha]
Post by: Pecan on July 19, 2010, 01:20:34 pm
cbDiff plugin - is a simple plugin, which visually shows the differences between two files.
Cool stuff. I'll try out soon.
Strange... I am unable to compile this... :-(

For me, when I removed WX_PRECOMP, it compiled ok.
Title: Re: cbDiff plugin
Post by: GeO on October 11, 2010, 03:23:41 pm
Fixed some minor bugs. See first post.
Title: Re: cbDiff plugin
Post by: javmss on January 09, 2011, 08:03:56 pm
Very good!
It fills one of the (few) missing features in Code::Blocks.
Must have!

Now, the suggestions.
I don't know how hard it is, but I believe that would really too much useful if I could:

- Compare two open files by right clicking on its tabs.
- Compare selected files from project file tree.

Any chance to get this done, please?
Title: Re: cbDiff plugin
Post by: GeO on January 12, 2011, 02:04:50 pm
Very good!
It fills one of the (few) missing features in Code::Blocks.
Must have!

Now, the suggestions.
I don't know how hard it is, but I believe that would really too much useful if I could:

- Compare two open files by right clicking on its tabs.
- Compare selected files from project file tree.

Any chance to get this done, please?

First, thanks for the motivation.
I implemented your suggestion in version 1.1.01 (see start post).
It's now possible to compare the current active file with an other open file, with the context menu of the editor, not the tab.
the same thing is possible with the project files.

As always, any feedback is welcome.
Title: Re: cbDiff plugin
Post by: daniloz on January 13, 2011, 10:35:53 am
First of all, great job!!! This is a really nice plugin... Thank you!!!

I like the new features... However I found some bugs:

- when I use the File|Diff files... menu entry, I got a new tab, but empty. I only get the diff if I resize the tab. I think it's just a refresh missing... :-)

- if I use the "Diff with..." context menu here, nothing happens, i.e. no new tab opened after I select the other file in the list.

And have some suggestions also:

- for me, it would be more natural to have the "Diff with..." context menu when clicking on the tab, instead of on the editor (I'm ok in having both, of course).

- is it possible to have a last entry in the file selection list (from the context menu) to browse for a file? I mean, I'd like to compare an opened file with one that is outside the project, so I'd like to browse the disk for it...

- how difficult it is to have the mouse wheel working on the file selection list (from the context menu)?

Thank's in advance!
Title: Re: cbDiff plugin
Post by: GeO on January 13, 2011, 02:05:26 pm
- when I use the File|Diff files... menu entry, I got a new tab, but empty. I only get the diff if I resize the tab. I think it's just a refresh missing... :-)
- if I use the "Diff with..." context menu here, nothing happens, i.e. no new tab opened after I select the other file in the list.
Which OS do you use? Both of them work for me on Ubuntu, it's probably a Windows problem. I'll look in to.

Now to the suggestions:
- for me, it would be more natural to have the "Diff with..." context menu when clicking on the tab, instead of on the editor (I'm ok in having both, of course).
Yes, this was javmss suggestion too, but i didn't found a possibility to access this menu from a plugin. I'll look again, maybe i can find another way
- is it possible to have a last entry in the file selection list (from the context menu) to browse for a file? I mean, I'd like to compare an opened file with one that is outside the project, so I'd like to browse the disk for it...
Well, i could make a general diff menu, used by all context menus, where you have all three options.
It would something like this: Diff with... -> Open file.. -> submenu with all open files
                                                                 -> Project file.. -> submenu with all project files
                                                                 -> Disk file... -> file selection dialog

- how difficult it is to have the mouse wheel working on the file selection list (from the context menu)?
As far as i know this is not possible, because wxWidget uses the native menus.
Title: Re: cbDiff plugin
Post by: daniloz on January 13, 2011, 02:13:04 pm
- when I use the File|Diff files... menu entry, I got a new tab, but empty. I only get the diff if I resize the tab. I think it's just a refresh missing... :-)
- if I use the "Diff with..." context menu here, nothing happens, i.e. no new tab opened after I select the other file in the list.
Which OS do you use? Both of them work for me on Ubuntu, it's probably a Windows problem. I'll look in to.
Yeah... Windows Vista 32bit here... :-(

- is it possible to have a last entry in the file selection list (from the context menu) to browse for a file? I mean, I'd like to compare an opened file with one that is outside the project, so I'd like to browse the disk for it...
Well, i could make a general diff menu, used by all context menus, where you have all three options.
It would something like this: Diff with... -> Open file.. -> submenu with all open files
                                                                 -> Project file.. -> submenu with all project files
                                                                 -> Disk file... -> file selection dialog
That would be a pretty good solution...

- how difficult it is to have the mouse wheel working on the file selection list (from the context menu)?
As far as i know this is not possible, because wxWidget uses the native menus.
Pitty... :-)

Anyway, thank you again for the plugin and for the support... ;-)
Title: Re: cbDiff plugin
Post by: GeO on January 26, 2011, 11:34:08 am
- when I use the File|Diff files... menu entry, I got a new tab, but empty. I only get the diff if I resize the tab. I think it's just a refresh missing... :-)
- if I use the "Diff with..." context menu here, nothing happens, i.e. no new tab opened after I select the other file in the list.
- is it possible to have a last entry in the file selection list (from the context menu) to browse for a file? I mean, I'd like to compare an opened file with one that is outside the project, so I'd like to browse the disk for it...
fixed and implemented in 1.1.1 (see startpost (http://forums.codeblocks.org/index.php/topic,12829.msg86682.html#msg86682)!)

- for me, it would be more natural to have the "Diff with..." context menu when clicking on the tab, instead of on the editor (I'm ok in having both, of course).
I looked in to the source of codeblocks, but now there is no way to access this contextmenu.
However, it could be made accessible by:
*adding a new ModuleType(mtEditorTab) in globals.h
*adding the method "Manager::Get()->GetPluginManager()->AskPluginsForModuleMenu(mtEditorTab, &pop);" in editormanager.cpp's OnPageContextMenu

That would be a simple task, but maybe the devs don't want that plugins can access this menu, because else it will be overloaded just like the editors context menu.
Title: Re: cbDiff plugin
Post by: oBFusCATed on January 26, 2011, 01:10:16 pm
Probably no one have asked this feature, so there is no way to access it :)
Title: Re: cbDiff plugin
Post by: daniloz on January 26, 2011, 01:34:14 pm
Probably no one have asked this feature, so there is no way to access it :)
This means, if I kindly ask for it, there's a chance it would be implemented?

Btw, I'm kindly asking for it... :-)
Title: Re: cbDiff plugin
Post by: MortenMacFly on January 26, 2011, 01:43:15 pm
Probably no one have asked this feature, so there is no way to access it :)
This means, if I kindly ask for it, there's a chance it would be implemented?
Could GeO provide a patch for this purpose? It seems he has done it already...?!
See:
However, it could be made accessible by:
*adding a new ModuleType(mtEditorTab) in globals.h
*adding the method "Manager::Get()->GetPluginManager()->AskPluginsForModuleMenu(mtEditorTab, &pop);" in editormanager.cpp's OnPageContextMenu
Title: Re: cbDiff plugin
Post by: GeO on January 26, 2011, 02:20:50 pm
Could GeO provide a patch for this purpose? It seems he has done it already...?!

Sure, i didn't test it yet, but it shouldn't break anything.
Title: Re: cbDiff plugin
Post by: oBFusCATed on January 26, 2011, 02:43:00 pm
Only the API/ABI :)
Title: Re: cbDiff plugin
Post by: GeO on January 26, 2011, 03:04:43 pm
Only the API/ABI :)
:) :) Well nothing except these.
Title: Re: cbDiff plugin
Post by: daniloz on July 26, 2011, 08:46:04 am
The compilation of the cbDiff plugin was broken after r7291, so in order to fix that I have to add the following include to cbDiffUtils.cpp:

Code
#include <wx/image.h>

@Geo: BTW, is there any new version around? Where do you usually make them available? Here? ;-)
Title: Re: cbDiff plugin
Post by: GeO on July 26, 2011, 07:14:29 pm
@Geo: BTW, is there any new version around? Where do you usually make them available? Here? ;-)
Well, actually i have a new version, with some cool features, for a while, but it needs some speed improvements.
Maybe i'll find some time this weekend, so i'll finish it.

I announce new versions usually in the first post of this thread.

Greets GeO
Title: Re: cbDiff plugin
Post by: UHM on October 26, 2011, 02:17:18 pm
Is there anybody who can help a new user (without C++ knowledge) by sending him
 
   libcbdiff.so

for
Linux version 2.6.27.39-0.3-default (geeko@buildhost) (gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux) ) #1 SMP 2009-11-23 12:57:38 +0100

???

i tried to compile it myself but I failed for hours, because of missing setup.h and other problems.

Thanks & Greetings, Uwe
Title: Re: cbDiff plugin
Post by: oBFusCATed on October 26, 2011, 03:45:44 pm
Do you have the devel package for wxGTK?
Title: Re: cbDiff plugin
Post by: UHM on November 09, 2011, 06:00:11 pm
Yes, maybe th wrong version, maybe with the wrong flags ...
Title: Re: cbDiff plugin
Post by: xunxun on November 23, 2011, 10:29:33 am
The plugin can't be built with latest CB svn & wx2.8-branch svn.

The patch can solve the issue.
Title: Re: cbDiff plugin
Post by: gocad on December 25, 2012, 01:04:46 pm
For Code::Blocks 12.11 rev 8629
Compiled by MinGW32 TDM 4.7.1 with wxWidgets 2.8.12

......
mingw32/bin/ld.exe: warning: cannot find entry symbol nable-auto-import; defaulting to 671c1000
......

You can replace "-enable-auto-import" with "--enable-auto-import" in cbDiff.cbp.

Good Luck !
Title: Re: cbDiff plugin
Post by: LETARTARE on January 17, 2015, 12:11:06 pm
Hello,
for Code::Blocks svn 10035
Compiled by MinGW32 TDM 4.7.1 with wxWidgets 2.8.12 and VISTA

https://github.com/ywx/cbDiff (https://github.com/ywx/cbDiff)

it's work fine.

Thanks to 'gocad'

Best regards
Title: Re: cbDiff plugin
Post by: yvesdm3000 on February 10, 2016, 06:01:41 pm
Seems like someone branched this plugin and added filetype detection. I merged the 2 branches into another branch that can be found here:

https://github.com/yvesdm3000/cbDiff