--- a/DiffTextView.st Thu Nov 16 16:18:36 1995 +0100
+++ b/DiffTextView.st Thu Nov 16 17:27:16 1995 +0100
@@ -11,7 +11,8 @@
"
TwoColumnTextView subclass:#DiffTextView
- instanceVariableNames:''
+ instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor
+ removedBgColor changedColor changedBgColor'
classVariableNames:''
poolDictionaries:''
category:'Views-Text'
@@ -34,7 +35,7 @@
!
version
- ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.9 1995-11-11 15:39:50 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.10 1995-11-16 16:27:16 cg Exp $'
!
documentation
@@ -57,6 +58,34 @@
^ 'diff -b'
! !
+
+!DiffTextView methodsFor:'initialization'!
+
+initStyle
+ super initStyle.
+
+ showSeparators := false.
+
+ useColors := ColoredListEntry notNil.
+ useColors ifTrue:[
+ device hasColors ifTrue:[
+ addedColor := Color black.
+ addedBgColor := Color green.
+
+ removedColor := Color white.
+ removedBgColor := Color red.
+
+ changedColor := Color white.
+ changedBgColor := Color blue.
+ ] ifFalse:[
+ addedBgColor := removedBgColor := changedBgColor := Color black.
+ addedColor := removedColor := changedColor := Color white.
+ ]
+ ].
+
+ "Created: 16.11.1995 / 16:59:48 / cg"
+! !
+
!DiffTextView methodsFor:'private'!
updateListsFrom:text1 and:text2 diffs:diffList
@@ -102,8 +131,10 @@
except for the first chunk, add a separating line
"
l1 size ~~ 0 ifTrue:[
- l1 add:'--------'.
- l2 add:'--------'.
+ showSeparators ifTrue:[
+ l1 add:'--------'.
+ l2 add:'--------'.
+ ]
].
"
@@ -134,50 +165,79 @@
] ifFalse:[
op == $a ifTrue:[
state := #added.
- l1 add:(text1 at:idx1).
- idx1 := idx1 + 1.
] ifFalse:[
op == $d ifTrue:[
state := #deleted
+ ] ifFalse:[
+ self halt:'unexpected diff entry'.
]
]
].
].
+nr1 print. ' ' print. op print. ' ' print. nr2 print. ' , ' print. nr3 printNL.
+
+"/ state == #added ifTrue:[
+"/ l1 add:(text1 at:idx1).
+"/ idx1 := idx1 + 1.
+"/ ].
+
"
copy over unchanged lines
"
any := false.
[idx1 < nr1] whileTrue:[
+'< add:' print. idx1 printNL.
l1 add:(text1 at:idx1).
idx1 := idx1 + 1.
any := true.
].
[idx2 < nr2] whileTrue:[
+'> add:' print. idx2 printNL.
l2 add:(text2 at:idx2).
idx2 := idx2 + 1.
any := true.
].
+ state == #added ifTrue:[
+ l1 add:(text1 at:idx1).
+ idx1 := idx1 + 1.
+ ].
+ state == #deleted ifTrue:[
+ l2 add:(text2 at:idx2).
+ idx2 := idx2 + 1.
+ ].
+
+
"
add a separating line, except at end
"
any ifTrue:[
state ~~ #finish ifTrue:[
- l1 add:'--------'.
- l2 add:'--------'.
+ showSeparators ifTrue:[
+ l1 add:'--------'.
+ l2 add:'--------'.
+ ]
]
].
] ifFalse:[
state == #changed ifTrue:[
(entry at:1) == $< ifTrue:[
- l1 add:(text1 at:idx1).
+ useColors ifTrue:[
+ l1 add:(ColoredListEntry string:(text1 at:idx1) foregroundColor:changedColor backgroundColor:changedBgColor).
+ ] ifFalse:[
+ l1 add:(text1 at:idx1).
+ ].
idx1 := idx1 + 1
] ifFalse:[
(entry at:1) == $> ifTrue:[
- l2 add:(text2 at:idx2).
+ useColors ifTrue:[
+ l2 add:(ColoredListEntry string:(text2 at:idx2) foregroundColor:changedColor backgroundColor:changedBgColor)
+ ] ifFalse:[
+ l2 add:(text2 at:idx2).
+ ].
idx2 := idx2 + 1
] ifFalse:[
(entry at:1) == $- ifTrue:[
@@ -190,7 +250,11 @@
] ifFalse:[
state == #added ifTrue:[
(entry at:1) == $> ifTrue:[
- l2 add:(text2 at:idx2).
+ useColors ifTrue:[
+ l2 add:(ColoredListEntry string:(text2 at:idx2) foregroundColor:addedColor backgroundColor:addedBgColor )
+ ] ifFalse:[
+ l2 add:(text2 at:idx2).
+ ].
idx2 := idx2 + 1.
l1 add:nil
] ifFalse:[
@@ -200,7 +264,11 @@
] ifFalse:[
state == #deleted ifTrue:[
(entry at:1) == $< ifTrue:[
- l1 add:(text1 at:idx1).
+ useColors ifTrue:[
+ l1 add:(ColoredListEntry string:(text1 at:idx1) foregroundColor:removedColor backgroundColor:removedBgColor ).
+ ] ifFalse:[
+ l1 add:(text1 at:idx1).
+ ].
idx1 := idx1 + 1.
l2 add:nil
] ifFalse:[
@@ -222,6 +290,8 @@
].
textView1 list:l1.
textView2 list:l2
+
+ "Modified: 16.11.1995 / 17:09:35 / cg"
! !
!DiffTextView methodsFor:'accessing'!
--- a/DiffTxtV.st Thu Nov 16 16:18:36 1995 +0100
+++ b/DiffTxtV.st Thu Nov 16 17:27:16 1995 +0100
@@ -11,7 +11,8 @@
"
TwoColumnTextView subclass:#DiffTextView
- instanceVariableNames:''
+ instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor
+ removedBgColor changedColor changedBgColor'
classVariableNames:''
poolDictionaries:''
category:'Views-Text'
@@ -34,7 +35,7 @@
!
version
- ^ '$Header: /cvs/stx/stx/libtool/Attic/DiffTxtV.st,v 1.9 1995-11-11 15:39:50 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Attic/DiffTxtV.st,v 1.10 1995-11-16 16:27:16 cg Exp $'
!
documentation
@@ -57,6 +58,34 @@
^ 'diff -b'
! !
+
+!DiffTextView methodsFor:'initialization'!
+
+initStyle
+ super initStyle.
+
+ showSeparators := false.
+
+ useColors := ColoredListEntry notNil.
+ useColors ifTrue:[
+ device hasColors ifTrue:[
+ addedColor := Color black.
+ addedBgColor := Color green.
+
+ removedColor := Color white.
+ removedBgColor := Color red.
+
+ changedColor := Color white.
+ changedBgColor := Color blue.
+ ] ifFalse:[
+ addedBgColor := removedBgColor := changedBgColor := Color black.
+ addedColor := removedColor := changedColor := Color white.
+ ]
+ ].
+
+ "Created: 16.11.1995 / 16:59:48 / cg"
+! !
+
!DiffTextView methodsFor:'private'!
updateListsFrom:text1 and:text2 diffs:diffList
@@ -102,8 +131,10 @@
except for the first chunk, add a separating line
"
l1 size ~~ 0 ifTrue:[
- l1 add:'--------'.
- l2 add:'--------'.
+ showSeparators ifTrue:[
+ l1 add:'--------'.
+ l2 add:'--------'.
+ ]
].
"
@@ -134,50 +165,79 @@
] ifFalse:[
op == $a ifTrue:[
state := #added.
- l1 add:(text1 at:idx1).
- idx1 := idx1 + 1.
] ifFalse:[
op == $d ifTrue:[
state := #deleted
+ ] ifFalse:[
+ self halt:'unexpected diff entry'.
]
]
].
].
+nr1 print. ' ' print. op print. ' ' print. nr2 print. ' , ' print. nr3 printNL.
+
+"/ state == #added ifTrue:[
+"/ l1 add:(text1 at:idx1).
+"/ idx1 := idx1 + 1.
+"/ ].
+
"
copy over unchanged lines
"
any := false.
[idx1 < nr1] whileTrue:[
+'< add:' print. idx1 printNL.
l1 add:(text1 at:idx1).
idx1 := idx1 + 1.
any := true.
].
[idx2 < nr2] whileTrue:[
+'> add:' print. idx2 printNL.
l2 add:(text2 at:idx2).
idx2 := idx2 + 1.
any := true.
].
+ state == #added ifTrue:[
+ l1 add:(text1 at:idx1).
+ idx1 := idx1 + 1.
+ ].
+ state == #deleted ifTrue:[
+ l2 add:(text2 at:idx2).
+ idx2 := idx2 + 1.
+ ].
+
+
"
add a separating line, except at end
"
any ifTrue:[
state ~~ #finish ifTrue:[
- l1 add:'--------'.
- l2 add:'--------'.
+ showSeparators ifTrue:[
+ l1 add:'--------'.
+ l2 add:'--------'.
+ ]
]
].
] ifFalse:[
state == #changed ifTrue:[
(entry at:1) == $< ifTrue:[
- l1 add:(text1 at:idx1).
+ useColors ifTrue:[
+ l1 add:(ColoredListEntry string:(text1 at:idx1) foregroundColor:changedColor backgroundColor:changedBgColor).
+ ] ifFalse:[
+ l1 add:(text1 at:idx1).
+ ].
idx1 := idx1 + 1
] ifFalse:[
(entry at:1) == $> ifTrue:[
- l2 add:(text2 at:idx2).
+ useColors ifTrue:[
+ l2 add:(ColoredListEntry string:(text2 at:idx2) foregroundColor:changedColor backgroundColor:changedBgColor)
+ ] ifFalse:[
+ l2 add:(text2 at:idx2).
+ ].
idx2 := idx2 + 1
] ifFalse:[
(entry at:1) == $- ifTrue:[
@@ -190,7 +250,11 @@
] ifFalse:[
state == #added ifTrue:[
(entry at:1) == $> ifTrue:[
- l2 add:(text2 at:idx2).
+ useColors ifTrue:[
+ l2 add:(ColoredListEntry string:(text2 at:idx2) foregroundColor:addedColor backgroundColor:addedBgColor )
+ ] ifFalse:[
+ l2 add:(text2 at:idx2).
+ ].
idx2 := idx2 + 1.
l1 add:nil
] ifFalse:[
@@ -200,7 +264,11 @@
] ifFalse:[
state == #deleted ifTrue:[
(entry at:1) == $< ifTrue:[
- l1 add:(text1 at:idx1).
+ useColors ifTrue:[
+ l1 add:(ColoredListEntry string:(text1 at:idx1) foregroundColor:removedColor backgroundColor:removedBgColor ).
+ ] ifFalse:[
+ l1 add:(text1 at:idx1).
+ ].
idx1 := idx1 + 1.
l2 add:nil
] ifFalse:[
@@ -222,6 +290,8 @@
].
textView1 list:l1.
textView2 list:l2
+
+ "Modified: 16.11.1995 / 17:09:35 / cg"
! !
!DiffTextView methodsFor:'accessing'!