Diff Package

This package like so much of the other things in my portfolio was built out of a need, in this case in the growing application Code Bank I was adding support for local databases. In doing so I was essentially detaching Code Bank from it's server side dependencies though it is still there for those who need it. With the addition of local database support I didn't want to loose many features, one of which is the very powerfull Diff View. However I hit a wall, when not using the server I don't have access to the PHP Pear Text_Diff library I was using on the server to generate the unified diff map that the Diff View component uses to render the differences. So I did some digging on the internet, but that turned up dry, apparently its not that common for people to want to generate diff files on the fly. So knowing that the Text_Diff library works very well and effeciently I began the process of porting said library to ActionScript 3. After only a few hours and a few less hairs on my head I managed to port 80% of the library that works just as effectiently and accuratly. The 80% I've successfully ported was the 80% I needed, I ended up only porting what I needed from the library. For now the library only supports unified diff rendering, in the future I plan to add support for rendering inline and context diffs.

The library is free for anyone to use, as always though it is protected by a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License if you are a commercial entitiy looking to use this code in your application please use the contact form above and I'm sure we can work something out. You can dowload the library here and see the result bellow (captured from the flex builder 3 debug perspective).

ASDocs are available here, see the bellow snippit on how to get it working.

Snippit

//Init the diff engine
var diffEngine:Diff=new Diff();
diffEngine.diff(changedText,baseText);

//Create the params dictionary
var params:Dictionary=new Dictionary();
params.leading_context_lines=1;
params.trailing_context_lines=1;

//Init the renderer
var diffRenderer:UnifiedDiffRenderer=new UnifiedDiffRenderer(params);

trace(diffRenderer.render(diffEngine));

Result

@@ -108,11 +108,11 @@
          */
-        private function onMouseOut(e:MouseEvent):void {
-            target.removeEventListener(MouseEvent.MOUSE_MOVE,trackPosition); //Stop listening
-            
-            //Stop the timer
-            timer.stop();
-            
-            //Hide the tooltip
-            this.visible=false;
-        }
+        /*private function onMouseOut(e:MouseEvent):void {
+            target.removeEventListener(MouseEvent.MOUSE_MOVE,trackPosition); //Stop listening
+            
+            //Stop the timer
+            timer.stop();
+            
+            //Hide the tooltip
+            this.visible=false;
+        }*/