fldiff - graphical diff program

Last Updated: Nov 13, 2006

fldiff (screenshot) is a graphical diff program that shows the differences between two files/directories, or a file/directory and a CVS or Subversion repository. It is inspired by xdiff (Motif-based) and xxdiff (Qt-based), whose choice of GUI toolkit has hampered their portability to many of the systems I work with.

fldiff uses the Fast Light Toolkit (FLTK) and has been tested on AIX, IRIX, Linux, MacOS X, and Solaris, and should also run on Windows.

fldiff is copyright 2005-2006 by Michael Sweet and is free software provided under the terms of the GNU General Public License v2. Please report any problems and suggestions on the fltk.general newsgroup.

News

fldiff 1.1 - Nov 13, 2006

A couple new features and a minor bug fix since the 1.0.1 release:

Downloading fldiff

The current release of fldiff is available here:

fldiff-1.1-source.tar.gz

The fldiff source code is available via Subversion from the following URL:

http://svn.easysw.com/public/fltk/applications/trunk/fldiff/

You can keep up-to-date by using Subversion to download the source code:

svn co http://svn.easysw.com/public/fltk/applications/trunk/fldiff/ fldiff

Compiling fldiff

Run the following commands after downloading the tarball:

./configure
make

Alternately, you can create an RPM using the following command:

rpmbuild -ta fldiff-1.1-source.tar.gz

Using fldiff

The current version is very simple. Run fldiff with two filenames to show the differences between them, or with one filename to show the changes against the current CVS or Subversion repos:

fldiff old new

fldiff file
fldiff file :revision

fldiff directory
fldiff directory :revision

After doing the diff, a window will appear with the diff:

The fldiff Window
The fldiff Window

The bar in the center of the window shows the changes in the entire file in yellow - the darkened box is the part of the diff you are viewing. If the diff is larger than can be represented in the change bar, a small zoom overlay will appear showing a full window's worth of changes centered at the mouse position.

Click in the change bar to immediately move to that position in the file or the up/down arrow button to move up or down in the diff. You can also use the PageUp, PageDown, Up, Down, BackSpace, Space, Home, End, N, and P keys to move up and down within the diff. The N and P keys show the next and previous changes in the diff, respectively.

Use the scrollbars to scroll within the diff; the scrollbars are linked so scrolling one side also scrolls the other side.

You can search both sides of the diff by pressing CTRL+f or choosing Find... from the Search menu. Repeat the search by pressing CTRL+g or choosing Find Next from the Search menu.

Drag the mouse to select the text on either side. Press CTRL+a to select all of the text on the left or SHIFT+CTRL+a to select all of the text on the right. Press CTRL+c to copy the corresponding lines of text to the clipboard.

The File menu allows you to open new diffs and close the current diff. You can also drop files in the diff window to open new diffs or double-click on filenames when comparing directories.

Choose Preferences from the Edit menu to show the preferences dialog which allows you to customize the display. These preferences and the current window size are remembered each time you run the program or open a new file.

Design Details

The diff display is implemented in the DiffView widget class derived from Fl_Group. The load() method uses the diff, cvs, or svn commands to obtain a unified diff and then builds an array of lines w/changes that are displayed by the draw() method. A custom handle() method intercepts mouse clicks and drags in the change bar.

The application window is implemented in the DiffWindow widget class derived from Fl_Overlay_Window. Inline methods are provided which map to the DiffView widget methods, and static callbacks handle the higher-level ops.

The open/compare window is implemented in the DiffOpenWindow widget class derived from Fl_Double_Window. The file/directory choosers are implemented using the DiffChooser widget class, which in turn uses the Fl_File_Input, Fl_File_Browser, and FavoritesMenu classes. Favorite management is handled by the FavoritesWindow class.