commentary
authorClaus Gittinger <cg@exept.de>
Thu, 25 Apr 1996 13:34:57 +0200
changeset 507 90ed76da5ade
parent 506 1f3cf6d5d343
child 508 8d2ab732fca5
commentary
DiffTextView.st
DiffTxtV.st
--- a/DiffTextView.st	Wed Apr 24 17:19:05 1996 +0200
+++ b/DiffTextView.st	Thu Apr 25 13:34:57 1996 +0200
@@ -13,7 +13,7 @@
 TwoColumnTextView subclass:#DiffTextView
 	instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor
 		removedBgColor changedColor changedBgColor changedSpacesOnlyColor
-		changedSpacesOnlyBgColor'
+		changedSpacesOnlyBgColor diffLineNumbers'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Text'
@@ -37,27 +37,38 @@
 
 documentation
 "
-    a view showing diff (see unix manual pages) output in a 
-    user-friendly form.
+    a view showing diff output (see unix manual pages)
+    in a user-friendly form.
     The view is created and opened with:
 
-       d := DiffTextView openOn:text1 and:text2.
+        d := DiffTextView openOn:text1 and:text2
+
+    or:
+        d := DiffTextView openOn:text1 label:l1
+                             and:text2 label:l2
 
-    and it will show the differences side-by-side
+    and it will show the differences side-by-side.
     For a real world application, see the ChangesBrowsers
-    compare function.
+    `compare' function.
+
+    [see also:]
+        TextView EditTextView
 "
 ! !
 
 !DiffTextView class methodsFor:'defaults'!
 
 diffCommand
+    "return the diff-command (with arguments)"
+
     ^ 'diff -b'
 ! !
 
 !DiffTextView methodsFor:'accessing'!
 
 text1:t1 text2:t2
+    "set the two texts which are to be diffed"
+
     |tmpFile1 tmpFile2 name1 tmpName2 stream line text1 text2 diffList pidString|
 
     text1 := t1 asStringCollection.
@@ -69,14 +80,14 @@
     tmpFile1 := Filename newTemporary.
     stream := tmpFile1 writeStream.
     text1 do:[:line |
-	stream nextPutAll:line; cr
+        stream nextPutAll:line; cr
     ].
     stream close.
 
     tmpFile2 := Filename newTemporary.
     stream := tmpFile2 writeStream.
     text2 do:[:line |
-	stream nextPutAll:line; cr
+        stream nextPutAll:line; cr
     ].
     stream close.
 
@@ -84,18 +95,18 @@
      start diff on it ...
     "
     stream := PipeStream 
-		readingFrom:self class diffCommand , ' ' , 
-			    tmpFile1 asString, ' ' , tmpFile2 asString.
+                readingFrom:self class diffCommand , ' ' , 
+                            tmpFile1 asString, ' ' , tmpFile2 asString.
     stream isNil ifTrue:[
-	self error:'cannot execute diff'.
-	text1 := text2 := nil.
+        self error:'cannot execute diff'.
+        text1 := text2 := nil.
     ] ifFalse:[
-	diffList := OrderedCollection new.
-	[stream atEnd] whileFalse:[
-	    line := stream nextLine.
-	    line notNil ifTrue:[diffList add:line]
-	].
-	stream close.
+        diffList := OrderedCollection new.
+        [stream atEnd] whileFalse:[
+            line := stream nextLine.
+            line notNil ifTrue:[diffList add:line]
+        ].
+        stream close.
     ].
 
     tmpFile1 delete.
@@ -108,7 +119,7 @@
 
      v := HVScrollableView for:DiffTextView.
      v scrolledView text1:('../libview/Color.st' asFilename readStream contents)
-		    text2:('../libview/Color.st.old' asFilename readStream contents).
+                    text2:('../libview/Color.st.old' asFilename readStream contents).
      v open
     "
 
@@ -134,6 +145,8 @@
      v text1:t1 text2:t2.
      v open
     "
+
+    "Modified: 25.4.1996 / 13:33:52 / cg"
 ! !
 
 !DiffTextView methodsFor:'initialization'!
@@ -175,6 +188,8 @@
     |idx1 idx2 dIdx dEnd state s nr1 nr2 nr3 op entry c l1 l2 any delta
      textView1 textView2 s1 s2|
 
+    diffLineNumbers := OrderedCollection new.
+
     textView1 := textViews at:1.
     textView2 := textViews at:2.
 
@@ -220,7 +235,6 @@
                     l2 add:'--------'.
                 ]
             ].
-
             "
              in cleanup ?
             "
@@ -229,6 +243,8 @@
                 nr2 := text2 size + 1.
                 state := #finish.
             ] ifFalse:[
+                diffLineNumbers add:l1 size.
+
                 s := ReadStream on:entry.
                 nr1 := Integer readFrom:s.
                 s peek == $, ifTrue:[
@@ -384,10 +400,10 @@
     textView1 list:l1.
     textView2 list:l2
 
-    "Modified: 23.12.1995 / 01:30:01 / cg"
+    "Modified: 25.4.1996 / 13:29:53 / cg"
 ! !
 
 !DiffTextView class methodsFor:'documentation'!
 
 version
-^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.15 1995-12-23 00:30:28 cg Exp $'! !
+^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.16 1996-04-25 11:34:57 cg Exp $'! !
--- a/DiffTxtV.st	Wed Apr 24 17:19:05 1996 +0200
+++ b/DiffTxtV.st	Thu Apr 25 13:34:57 1996 +0200
@@ -13,7 +13,7 @@
 TwoColumnTextView subclass:#DiffTextView
 	instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor
 		removedBgColor changedColor changedBgColor changedSpacesOnlyColor
-		changedSpacesOnlyBgColor'
+		changedSpacesOnlyBgColor diffLineNumbers'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Text'
@@ -37,27 +37,38 @@
 
 documentation
 "
-    a view showing diff (see unix manual pages) output in a 
-    user-friendly form.
+    a view showing diff output (see unix manual pages)
+    in a user-friendly form.
     The view is created and opened with:
 
-       d := DiffTextView openOn:text1 and:text2.
+        d := DiffTextView openOn:text1 and:text2
+
+    or:
+        d := DiffTextView openOn:text1 label:l1
+                             and:text2 label:l2
 
-    and it will show the differences side-by-side
+    and it will show the differences side-by-side.
     For a real world application, see the ChangesBrowsers
-    compare function.
+    `compare' function.
+
+    [see also:]
+        TextView EditTextView
 "
 ! !
 
 !DiffTextView class methodsFor:'defaults'!
 
 diffCommand
+    "return the diff-command (with arguments)"
+
     ^ 'diff -b'
 ! !
 
 !DiffTextView methodsFor:'accessing'!
 
 text1:t1 text2:t2
+    "set the two texts which are to be diffed"
+
     |tmpFile1 tmpFile2 name1 tmpName2 stream line text1 text2 diffList pidString|
 
     text1 := t1 asStringCollection.
@@ -69,14 +80,14 @@
     tmpFile1 := Filename newTemporary.
     stream := tmpFile1 writeStream.
     text1 do:[:line |
-	stream nextPutAll:line; cr
+        stream nextPutAll:line; cr
     ].
     stream close.
 
     tmpFile2 := Filename newTemporary.
     stream := tmpFile2 writeStream.
     text2 do:[:line |
-	stream nextPutAll:line; cr
+        stream nextPutAll:line; cr
     ].
     stream close.
 
@@ -84,18 +95,18 @@
      start diff on it ...
     "
     stream := PipeStream 
-		readingFrom:self class diffCommand , ' ' , 
-			    tmpFile1 asString, ' ' , tmpFile2 asString.
+                readingFrom:self class diffCommand , ' ' , 
+                            tmpFile1 asString, ' ' , tmpFile2 asString.
     stream isNil ifTrue:[
-	self error:'cannot execute diff'.
-	text1 := text2 := nil.
+        self error:'cannot execute diff'.
+        text1 := text2 := nil.
     ] ifFalse:[
-	diffList := OrderedCollection new.
-	[stream atEnd] whileFalse:[
-	    line := stream nextLine.
-	    line notNil ifTrue:[diffList add:line]
-	].
-	stream close.
+        diffList := OrderedCollection new.
+        [stream atEnd] whileFalse:[
+            line := stream nextLine.
+            line notNil ifTrue:[diffList add:line]
+        ].
+        stream close.
     ].
 
     tmpFile1 delete.
@@ -108,7 +119,7 @@
 
      v := HVScrollableView for:DiffTextView.
      v scrolledView text1:('../libview/Color.st' asFilename readStream contents)
-		    text2:('../libview/Color.st.old' asFilename readStream contents).
+                    text2:('../libview/Color.st.old' asFilename readStream contents).
      v open
     "
 
@@ -134,6 +145,8 @@
      v text1:t1 text2:t2.
      v open
     "
+
+    "Modified: 25.4.1996 / 13:33:52 / cg"
 ! !
 
 !DiffTextView methodsFor:'initialization'!
@@ -175,6 +188,8 @@
     |idx1 idx2 dIdx dEnd state s nr1 nr2 nr3 op entry c l1 l2 any delta
      textView1 textView2 s1 s2|
 
+    diffLineNumbers := OrderedCollection new.
+
     textView1 := textViews at:1.
     textView2 := textViews at:2.
 
@@ -220,7 +235,6 @@
                     l2 add:'--------'.
                 ]
             ].
-
             "
              in cleanup ?
             "
@@ -229,6 +243,8 @@
                 nr2 := text2 size + 1.
                 state := #finish.
             ] ifFalse:[
+                diffLineNumbers add:l1 size.
+
                 s := ReadStream on:entry.
                 nr1 := Integer readFrom:s.
                 s peek == $, ifTrue:[
@@ -384,10 +400,10 @@
     textView1 list:l1.
     textView2 list:l2
 
-    "Modified: 23.12.1995 / 01:30:01 / cg"
+    "Modified: 25.4.1996 / 13:29:53 / cg"
 ! !
 
 !DiffTextView class methodsFor:'documentation'!
 
 version
-^ '$Header: /cvs/stx/stx/libtool/Attic/DiffTxtV.st,v 1.15 1995-12-23 00:30:28 cg Exp $'! !
+^ '$Header: /cvs/stx/stx/libtool/Attic/DiffTxtV.st,v 1.16 1996-04-25 11:34:57 cg Exp $'! !