News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

cbDiff plugin

Started by GeO, June 28, 2010, 10:46:04 PM

Previous topic - Next topic

GeO

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:


Unified:


Side by Side:


[attachment deleted by admin]

Loaden

Maybe support subversion? diff in two rev?

MortenMacFly

Quote from: GeO on June 28, 2010, 10:46:04 PM
cbDiff plugin - is a simple plugin, which visually shows the differences between two files.
Cool stuff. I'll try out soon.

Quote from: Loaden on July 12, 2010, 12:56:10 PM
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).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

GeO

Quote from: Loaden on July 12, 2010, 12:56:10 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

dmoore

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
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

MortenMacFly

Quote from: MortenMacFly on July 12, 2010, 04:24:32 PM
Quote from: GeO on June 28, 2010, 10:46:04 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... :-(
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Pecan

Quote from: MortenMacFly on July 19, 2010, 07:16:44 AM
Quote from: MortenMacFly on July 12, 2010, 04:24:32 PM
Quote from: GeO on June 28, 2010, 10:46:04 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.

GeO

Fixed some minor bugs. See first post.

javmss

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?

GeO

Quote from: 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?

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.

daniloz

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!

GeO

Quote from: daniloz on January 13, 2011, 10:35:53 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.
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:
Quote from: daniloz on January 13, 2011, 10:35:53 AM
- 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
Quote from: daniloz on January 13, 2011, 10:35:53 AM
- 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

Quote from: daniloz on January 13, 2011, 10:35:53 AM
- 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.

daniloz

Quote from: GeO on January 13, 2011, 02:05:26 PM
Quote from: daniloz on January 13, 2011, 10:35:53 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.
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... :-(

Quote from: GeO on January 13, 2011, 02:05:26 PM
Quote from: daniloz on January 13, 2011, 10:35:53 AM
- 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...

Quote from: GeO on January 13, 2011, 02:05:26 PM
Quote from: daniloz on January 13, 2011, 10:35:53 AM
- 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... ;-)

GeO

Quote from: daniloz on January 13, 2011, 10:35:53 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!)

Quote from: daniloz on January 13, 2011, 10:35:53 AM
- 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.

oBFusCATed

Probably no one have asked this feature, so there is no way to access it :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]