Fixes in Diff2/Diff3 text views jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 17 Mar 2012 10:21:50 +0000
branchjv
changeset 12192 15f47901fb64
parent 12191 a896c0850f1b
child 12193 c0bdf75cfde5
Fixes in Diff2/Diff3 text views
Tools__ChangeSetDiffTool.st
Tools__CodeView2.st
Tools__Diff3CodeView2.st
--- a/Tools__ChangeSetDiffTool.st	Fri Mar 16 23:23:39 2012 +0000
+++ b/Tools__ChangeSetDiffTool.st	Sat Mar 17 10:21:50 2012 +0000
@@ -585,9 +585,10 @@
     "Do not manually edit this!! If it is corrupted,
      the MenuEditor may not be able to read the specification."
 
+
     "
-     MenuEditor new openOnClass:SVN::DiffBrowser andSelector:#listMenu
-     (Menu new fromLiteralArrayEncoding:(SVN::DiffBrowser listMenu)) startUp
+     MenuEditor new openOnClass:Tools::ChangeSetDiffTool andSelector:#listMenu
+     (Menu new fromLiteralArrayEncoding:(Tools::ChangeSetDiffTool listMenu)) startUp
     "
 
     <resource: #menu>
@@ -621,10 +622,33 @@
             label: '-'
           )
          (MenuItem
-            enabled: hasSelection
-            label: 'Inspect'
-            itemValue: listMenuInspect
+            label: 'Open in...'
             translateLabel: true
+            submenu: 
+           (Menu
+              (
+               (MenuItem
+                  enabled: hasSelection
+                  label: 'Inspector'
+                  itemValue: listMenuInspect
+                  translateLabel: true
+                )
+               (MenuItem
+                  label: 'kdiff3'
+                  itemValue: listMenuOpenInExternal:
+                  translateLabel: true
+                  argument: 'kdiff3'
+                )
+               (MenuItem
+                  label: 'meld'
+                  itemValue: listMenuOpenInExternal:
+                  translateLabel: true
+                  argument: 'meld'
+                )
+               )
+              nil
+              nil
+            )
           )
          )
         nil
@@ -1318,6 +1342,37 @@
         [:diff|diff versionB apply]
 
     "Modified: / 09-12-2009 / 23:10:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+listMenuOpenInExternal: command
+
+    (OperatingSystem canExecuteCommand: command) ifFalse:[
+        Dialog warn: 'Sorry. ', command , ' is not installed or not in PATH'
+    ].
+
+    self selection do:[:item|
+        | base a b cmd |
+        item versionBase notNil ifTrue:[
+            base := Filename newTemporary.
+            base writingFileDo:[:s|s nextPutAll: item versionBase source].
+        ].
+        a := Filename newTemporary.
+        a writingFileDo:[:s|s nextPutAll: item versionA source].
+        b := Filename newTemporary.
+        b writingFileDo:[:s|s nextPutAll: item versionB source].
+
+        base isNil ifTrue:[
+            cmd := '%1 %2 %3' bindWith: command with: a pathName with: b pathName
+        ] ifFalse:[
+            cmd := '%1 %4 %2 %3 ' bindWith: command with: a pathName with: b pathName with: base pathName.
+        ].
+        [ OperatingSystem executeCommand: cmd.
+        a remove.
+        b remove.
+        base notNil ifTrue:[base remove]. ] fork
+    ]
+
+    "Modified: / 17-03-2012 / 08:55:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !ChangeSetDiffTool methodsFor:'queries'!
@@ -1726,5 +1781,5 @@
 !
 
 version_SVN
-    ^ '$Id: Tools__ChangeSetDiffTool.st 7925 2012-03-16 17:08:17Z vranyj1 $'
+    ^ '$Id: Tools__ChangeSetDiffTool.st 7938 2012-03-17 10:21:50Z vranyj1 $'
 ! !
--- a/Tools__CodeView2.st	Fri Mar 16 23:23:39 2012 +0000
+++ b/Tools__CodeView2.st	Sat Mar 17 10:21:50 2012 +0000
@@ -2603,99 +2603,113 @@
 
 !CodeView2::TextView methodsFor:'drawing'!
 
-drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg 
-
-    super 
-        drawFromVisibleLine:startVisLineNr
-        to:endVisLineNr
-        with:fg
-        and:bg.
-    self redrawLines.
-
-    "Created: / 05-04-2010 / 12:08:38 / Jakub <zelenja7@fel.cvut.cz>"
-    "Modified: / 02-05-2010 / 18:46:04 / Jakub <zelenja7@fel.cvut.cz>"
+backgroundForVisibleLine:visLineNr default:bg 
+    | lineNr |
+
+
+    diffMode ifTrue:[
+        lineNr := self visibleLineToListLine:visLineNr.
+        (insertedLines includes:lineNr) ifTrue:[
+            ^self colorInserted
+        ].
+        (changedLines includes:lineNr) ifTrue:[
+            ^self colorChanged
+        ].
+        (deletedLines includes:lineNr) ifTrue:[
+            ^self colorDeleted
+        ].
+    ].
+    ^ bg
+
+    "Modified: / 17-03-2012 / 10:03:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg
+    "draw a visible line range in fg/bg"
+
+    diffMode ifFalse:[
+        super drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg.
+        ^self.
+    ].
+
+    startVisLineNr to: endVisLineNr do:[:visLineNr|
+        self drawVisibleLine: visLineNr with:fg and:bg
+    ]
+
+    "Modified: / 15-12-1999 / 23:19:39 / cg"
+    "Created: / 17-03-2012 / 09:44:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 drawLine:line fromX:x inVisible:visLineNr with:fg and:bg 
-
     super 
         drawLine:line
         fromX:x
         inVisible:visLineNr
         with:fg
-        and:bg.
-    self redrawLines.
+        and:(self backgroundForVisibleLine:visLineNr default:bg).
 
     "Created: / 05-04-2010 / 12:07:07 / Jakub <zelenja7@fel.cvut.cz>"
     "Modified: / 02-05-2010 / 18:46:00 / Jakub <zelenja7@fel.cvut.cz>"
+    "Modified: / 17-03-2012 / 10:05:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-drawLine:lineStringArg inVisible:visLineNr col:col with:fg and:bg 
-
+drawLine:lineStringArg inVisible:visLineNr col:col with:fg and:bg
     super 
         drawLine:lineStringArg
         inVisible:visLineNr
         col:col
         with:fg
-        and:bg.
-    self redrawLines.
+        and:(self backgroundForVisibleLine:visLineNr default:bg).
 
     "Created: / 05-04-2010 / 11:49:42 / Jakub <zelenja7@fel.cvut.cz>"
     "Modified: / 02-05-2010 / 18:45:56 / Jakub <zelenja7@fel.cvut.cz>"
+    "Modified: / 17-03-2012 / 10:04:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 drawLine:lineStringArg inVisible:visLineNr from:startCol to:endColOrNil with:fg and:bg 
-
     super 
         drawLine:lineStringArg
         inVisible:visLineNr
         from:startCol
         to:endColOrNil
         with:fg
-        and:bg.
-    self redrawLines.
+        and:(self backgroundForVisibleLine:visLineNr default:bg).
 
     "Created: / 05-04-2010 / 11:54:54 / Jakub <zelenja7@fel.cvut.cz>"
     "Modified: / 02-05-2010 / 18:45:52 / Jakub <zelenja7@fel.cvut.cz>"
+    "Modified: / 17-03-2012 / 10:04:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 drawLine:lineString inVisible:visLineNr from:startCol with:fg and:bg 
-
     super 
         drawLine:lineString
         inVisible:visLineNr
         from:startCol
         with:fg
-        and:bg.
-    self redrawLines.
+        and:(self backgroundForVisibleLine:visLineNr default:bg).
 
     "Created: / 05-04-2010 / 11:54:26 / Jakub <zelenja7@fel.cvut.cz>"
     "Modified: / 02-05-2010 / 18:45:48 / Jakub <zelenja7@fel.cvut.cz>"
+    "Modified: / 17-03-2012 / 10:04:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 drawVisibleLine:visLineNr with:fg and:bg 
-
     super 
         drawVisibleLine:visLineNr
         with:fg
-        and:bg.
-    self redrawLines.
+        and:(self backgroundForVisibleLine:visLineNr default:bg).
 
     "Created: / 05-04-2010 / 11:49:42 / Jakub <zelenja7@fel.cvut.cz>"
     "Modified: / 02-05-2010 / 18:45:44 / Jakub <zelenja7@fel.cvut.cz>"
-!
-
-redraw
-    "/ thisContext fullPrintAll.   
-    super redraw.
-
-    "Created: / 30-06-2011 / 11:04:32 / cg"
+    "Modified: / 17-03-2012 / 10:04:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 redrawLines
     |i pom|
 
     diffMode ifFalse:[^self].
+    true ifTrue:[^self].
+
 
     pom := self hasSelection.
     (pom) ifTrue:[ ^ self. ].
@@ -2738,7 +2752,7 @@
 
     "Created: / 26-04-2010 / 21:04:31 / Jakub <zelenja7@fel.cvut.cz>"
     "Modified: / 22-06-2010 / 23:28:30 / Jakub <zelenja7@fel.cvut.cz>"
-    "Modified: / 08-04-2011 / 20:52:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 17-03-2012 / 09:27:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CodeView2::TextView methodsFor:'editing'!
@@ -3221,105 +3235,18 @@
 
 !CodeView2::TextView methodsFor:'scrolling'!
 
-basicScrollDown:nLines 
-    |i|
-
-    (lastFirstLine isNil) ifTrue:[
-        lastFirstLine := firstLineShown.
-    ].
-    super scrollDown:nLines.
-    (lastFirstLine = firstLineShown) ifFalse:[
-        i := 1.
-        [
-            i <= changedLines size
-        ] whileTrue:[
-            super 
-                drawVisibleLine:(changedLines at:i)
-                with:fgColor
-                and:Color white.
-            changedLines at:i put:(changedLines at:i) - nLines.
-            i := i + 1.
-        ].
-        i := 1.
-        [
-            i <= insertedLines size
-        ] whileTrue:[
-            super 
-                drawVisibleLine:(insertedLines at:i)
-                with:fgColor
-                and:Color white.
-            insertedLines at:i put:(insertedLines at:i) - nLines.
-            i := i + 1.
-        ].
-        i := 1.
-        [
-            i <= deletedLines size
-        ] whileTrue:[
-            super 
-                drawVisibleLine:(deletedLines at:i)
-                with:fgColor
-                and:Color white.
-            deletedLines at:i put:(deletedLines at:i) - nLines.
-            i := i + 1.
-        ].
-        lastFirstLine := firstLineShown.
-        self redrawLines.
-    ].
-
-    "Created: / 06-04-2010 / 14:03:28 / Jakub <zelenja7@fel.cvut.cz>"
-    "Modified: / 02-05-2010 / 19:29:23 / Jakub <zelenja7@fel.cvut.cz>"
+basicScrollDown:nLines
+
+    super scrollDown: nLines
+
+    "Created: / 17-03-2012 / 10:06:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-basicScrollUp:nLines 
-    |i|
-
-    (scrolled isNil) ifTrue:[
-        scrolled := false.
-    ].
-    (lastFirstLine isNil) ifTrue:[
-        lastFirstLine := firstLineShown.
-    ].
-    super scrollUp:nLines.
-    (lastFirstLine = firstLineShown) ifFalse:[
-        i := 1.
-        [
-            i <= insertedLines size
-        ] whileTrue:[
-            super 
-                drawVisibleLine:(insertedLines at:i)
-                with:fgColor
-                and:Color white.
-            insertedLines at:i put:(insertedLines at:i) + nLines.
-            i := i + 1.
-        ].
-        i := 1.
-        [
-            i <= deletedLines size
-        ] whileTrue:[
-            super 
-                drawVisibleLine:(deletedLines at:i)
-                with:fgColor
-                and:Color white.
-            deletedLines at:i put:(deletedLines at:i) + nLines.
-            i := i + 1.
-        ].
-        i := 1.
-        [
-            i <= changedLines size
-        ] whileTrue:[
-            super 
-                drawVisibleLine:(changedLines at:i)
-                with:fgColor
-                and:Color white.
-            changedLines at:i put:(changedLines at:i) + nLines.
-            i := i + 1.
-        ].
-        lastFirstLine := firstLineShown.
-        self redrawLines.
-    ].
-
-    "Created: / 06-04-2010 / 14:03:46 / Jakub <zelenja7@fel.cvut.cz>"
-    "Modified: / 02-05-2010 / 19:19:27 / Jakub <zelenja7@fel.cvut.cz>"
+basicScrollUp:nLines
+
+    super scrollUp: nLines
+
+    "Created: / 17-03-2012 / 10:06:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 originChanged:delta
@@ -3337,6 +3264,7 @@
     self basicScrollDown: nLines.
 
     "Modified: / 06-04-2010 / 14:04:28 / Jakub <zelenja7@fel.cvut.cz>"
+    "Modified: / 17-03-2012 / 10:06:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 scrollUp:nLines
@@ -3345,6 +3273,7 @@
     self basicScrollUp: nLines.
 
     "Modified: / 06-04-2010 / 14:05:40 / Jakub <zelenja7@fel.cvut.cz>"
+    "Modified: / 17-03-2012 / 10:06:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CodeView2::TextView methodsFor:'undo & again'!
@@ -3368,7 +3297,7 @@
 !CodeView2 class methodsFor:'documentation'!
 
 version
-    ^ '$Id: Tools__CodeView2.st 7912 2012-02-22 13:18:20Z vranyj1 $'
+    ^ '$Id: Tools__CodeView2.st 7938 2012-03-17 10:21:50Z vranyj1 $'
 !
 
 version_CVS
@@ -3376,7 +3305,7 @@
 !
 
 version_SVN
-    ^ '$Id: Tools__CodeView2.st 7912 2012-02-22 13:18:20Z vranyj1 $'
+    ^ '$Id: Tools__CodeView2.st 7938 2012-03-17 10:21:50Z vranyj1 $'
 ! !
 
 CodeView2 initialize!
--- a/Tools__Diff3CodeView2.st	Fri Mar 16 23:23:39 2012 +0000
+++ b/Tools__Diff3CodeView2.st	Sat Mar 17 10:21:50 2012 +0000
@@ -21,8 +21,8 @@
 !
 
 Object subclass:#Diff3Data
-	instanceVariableNames:'text1 list1 text2 list2 text3 list3 inserted2 inserted3 deleted
-		changed'
+	instanceVariableNames:'text1 list1 text2 list2 text3 list3 inserted1 inserted2 inserted3
+		deleted changed'
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:Diff3CodeView2
@@ -75,7 +75,7 @@
         list:(data list1);
         deletedLines:#();
         changedLines:(data changed);
-        insertedLines:#();    
+        insertedLines:(data inserted1);    
         originDiffText:t1;
         emptyLines:#().
 
@@ -121,6 +121,10 @@
     deleted := something.
 !
 
+inserted1
+    ^ inserted1
+!
+
 inserted2
     ^ inserted2
 !
@@ -182,14 +186,15 @@
 addLines: total from: src to: dst offset: offset length: len
     | start stop |
 
-    start := offset min: src size.
-    stop  := (offset + len - 1) min: src size.
+    start := offset.
+    stop  := (offset + len - 1).
+
 
-    start < stop ifTrue:[
-        start to: stop do:[:i|
-            dst add: (src at: i).
-        ].
+    start to: stop do:[:i|                     
+        dst add: (src at: i).
     ].
+
+
     (total - (stop - start + 1)) timesRepeat: [ dst add: nil ].
 
     "Created: / 16-03-2012 / 22:20:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -202,6 +207,7 @@
     list2 := StringCollection new.
     list3 := StringCollection new.
     changed := OrderedCollection new.
+    inserted1 := OrderedCollection new.
     inserted2 := OrderedCollection new.
     inserted3 := OrderedCollection new.
 
@@ -229,7 +235,15 @@
             self addLines: len from: t1c to: list1 offset: chunk original offset length: chunk original length.
             self addLines: len from: t2c to: list2 offset: chunk left     offset length: chunk left     length.
             self addLines: len from: t3c to: list3 offset: chunk right    offset length: chunk right    length.
-            lnr to:(lnr + len -1) do:[:i|changed add: i].
+"/            chunk isInsertionInOriginal ifTrue:[
+"/                lnr to:(lnr + len -1) do:[:i|inserted1 add: i].
+"/            ] ifFalse:[chunk isInsertionInLeft ifTrue:[
+"/                lnr to:(lnr + len -1) do:[:i|inserted2 add: i].
+"/            ] ifFalse:[chunk isInsertionInRight ifTrue:[
+"/                lnr to:(lnr + len -1) do:[:i|inserted3 add: i].
+"/            ] ifFalse:[
+                lnr to:(lnr + len -1) do:[:i|changed add: i].
+"/            ]]]
         ].
         chunk isChunk ifTrue:[
             chunk side == #original ifTrue:[
@@ -238,16 +252,16 @@
                 self addLines: len from: t1c to: list3 offset: chunk offset length: len.
             ].
             chunk side == #left ifTrue:[
-                self addLines: len from: t1c to: list1 offset: chunk offset length: len.
+                self addLines: len from: t1c to: list1 offset: chunk offset length: 0"len".
                 self addLines: len from: t2c to: list2 offset: chunk offset length: len.
-                self addLines: len from: t3c to: list3 offset: chunk offset length: len.
-                lnr to:(lnr + len - 1) do:[:i| changed add:i ].
+                self addLines: len from: t3c to: list3 offset: chunk offset length: 0"len".
+                lnr to:(lnr + len - 1) do:[:i| "changed"inserted2 add:i ].
             ].
             chunk side == #right ifTrue:[
-                self addLines: len from: t1c to: list1 offset: chunk offset length: len.
-                self addLines: len from: t2c to: list2 offset: chunk offset length: len.
+                self addLines: len from: t1c to: list1 offset: chunk offset length: 0"len".
+                self addLines: len from: t2c to: list2 offset: chunk offset length: 0"len".
                 self addLines: len from: t3c to: list3 offset: chunk offset length: len.
-                lnr to:(lnr + len - 1) do:[:i|changed add: i].
+                lnr to:(lnr + len - 1) do:[:i|"changed"inserted3 add: i].
             ]
         ].
         lnr := lnr + len.
@@ -259,5 +273,5 @@
 !Diff3CodeView2 class methodsFor:'documentation'!
 
 version_SVN
-    ^ '$Id: Tools__Diff3CodeView2.st 7937 2012-03-16 23:23:39Z vranyj1 $'
+    ^ '$Id: Tools__Diff3CodeView2.st 7938 2012-03-17 10:21:50Z vranyj1 $'
 ! !