--- a/DiffTextView.st Fri Jul 09 16:55:32 1999 +0200
+++ b/DiffTextView.st Fri Jul 09 16:56:18 1999 +0200
@@ -59,6 +59,11 @@
see the ChangesBrowsers `compare',
or the browsers 'compare with repository' functions.
+ Notice:
+ A diff command must be available on your system and found
+ along the PATH (you will see a warning on stderr, if there is no diff).
+ We use gnu-diff.
+
[see also:]
TextView EditTextView Diff3TextView
@@ -99,11 +104,18 @@
diffCommand
"return the diff-command (with argument placeHolders)"
- OperatingSystem isMSDOSlike ifTrue:[
- ^ DiffCommandTemplate ? 'diff %1 %2'
+ DiffCommandTemplate isNil ifTrue:[
+ OperatingSystem isMSDOSlike ifTrue:[
+ (OperatingSystem canExecuteCommand:'diff') ifFalse:[
+ 'DiffTextView [warning]: no diff command found' errorPrintCR.
+ ^ nil
+ ].
+ DiffCommandTemplate := 'diff %1 %2'
+ ] ifFalse:[
+ DiffCommandTemplate := 'diff -b %1 %2'
+ ]
].
-
- ^ DiffCommandTemplate ? 'diff -b %1 %2'
+ ^ DiffCommandTemplate
"Modified: / 30.1.1998 / 12:12:49 / cg"
!
@@ -128,59 +140,64 @@
execute DiffCommand and update the two textViews."
|tmpFile1 tmpFile2 name1 tmpName2 stream line
- text1 text2 diffList pidString diffCmd|
+ text1 text2 diffList pidString diffTemplate diffCmd|
text1 := t1 asStringCollection.
text2 := t2 asStringCollection.
- "
- save them texts in two temporary files ...
- "
- tmpFile1 := Filename newTemporary.
- stream := tmpFile1 writeStream.
- text1 do:[:line |
- line notNil ifTrue:[
- stream nextPutAll:line.
+ diffTemplate := self class diffCommand.
+ diffTemplate isNil ifTrue:[
+ "/ self warn:'no diff command available'.
+ ] ifFalse:[
+ "
+ save them texts in two temporary files ...
+ "
+ tmpFile1 := Filename newTemporary.
+ stream := tmpFile1 writeStream.
+ text1 do:[:line |
+ line notNil ifTrue:[
+ stream nextPutAll:line.
+ ].
+ stream cr
].
- stream cr
- ].
- stream close.
+ stream close.
- tmpFile2 := Filename newTemporary.
- stream := tmpFile2 writeStream.
- text2 do:[:line |
- line notNil ifTrue:[
- stream nextPutAll:line.
+ tmpFile2 := Filename newTemporary.
+ stream := tmpFile2 writeStream.
+ text2 do:[:line |
+ line notNil ifTrue:[
+ stream nextPutAll:line.
+ ].
+ stream cr
].
- stream cr
- ].
- stream close.
+ stream close.
- "
- start diff on it ...
- "
- diffCmd := self class diffCommand
+ "
+ start diff on it ...
+ "
+ diffCmd := diffTemplate
bindWith:tmpFile1 asString
with:tmpFile2 asString.
- stream := PipeStream readingFrom:diffCmd.
- stream isNil ifTrue:[
- stream := PipeStream readingFrom:('support' , Filename separator asString , diffCmd).
+ stream := PipeStream readingFrom:diffCmd.
+ stream isNil ifTrue:[
+ stream := PipeStream readingFrom:('support' , Filename separator asString , diffCmd).
+ ].
+ stream isNil ifTrue:[
+ 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.
+ ].
+
+ tmpFile1 delete.
+ tmpFile2 delete.
].
- stream isNil ifTrue:[
- 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.
- ].
-
- tmpFile1 delete.
- tmpFile2 delete.
self updateListsFrom:text1 and:text2 diffs:diffList
@@ -221,6 +238,11 @@
!DiffTextView methodsFor:'initialization'!
+addNextPreviousButtons
+ super addNextPreviousButtons.
+ nextPrevButtonPanel beVisible.
+!
+
initStyle
super initStyle.
@@ -341,7 +363,7 @@
op == $c ifTrue:[
state := #changed.
] ifFalse:[
- op == $a ifTrue:[
+ (op == $a) ifTrue:[
state := #added.
] ifFalse:[
op == $d ifTrue:[
@@ -494,4 +516,4 @@
!DiffTextView class methodsFor:'documentation'!
version
-^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.24 1999-07-07 13:01:09 cg Exp $'! !
+^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.25 1999-07-09 14:56:18 cg Exp $'! !
--- a/DiffTxtV.st Fri Jul 09 16:55:32 1999 +0200
+++ b/DiffTxtV.st Fri Jul 09 16:56:18 1999 +0200
@@ -59,6 +59,11 @@
see the ChangesBrowsers `compare',
or the browsers 'compare with repository' functions.
+ Notice:
+ A diff command must be available on your system and found
+ along the PATH (you will see a warning on stderr, if there is no diff).
+ We use gnu-diff.
+
[see also:]
TextView EditTextView Diff3TextView
@@ -99,11 +104,18 @@
diffCommand
"return the diff-command (with argument placeHolders)"
- OperatingSystem isMSDOSlike ifTrue:[
- ^ DiffCommandTemplate ? 'diff %1 %2'
+ DiffCommandTemplate isNil ifTrue:[
+ OperatingSystem isMSDOSlike ifTrue:[
+ (OperatingSystem canExecuteCommand:'diff') ifFalse:[
+ 'DiffTextView [warning]: no diff command found' errorPrintCR.
+ ^ nil
+ ].
+ DiffCommandTemplate := 'diff %1 %2'
+ ] ifFalse:[
+ DiffCommandTemplate := 'diff -b %1 %2'
+ ]
].
-
- ^ DiffCommandTemplate ? 'diff -b %1 %2'
+ ^ DiffCommandTemplate
"Modified: / 30.1.1998 / 12:12:49 / cg"
!
@@ -128,59 +140,64 @@
execute DiffCommand and update the two textViews."
|tmpFile1 tmpFile2 name1 tmpName2 stream line
- text1 text2 diffList pidString diffCmd|
+ text1 text2 diffList pidString diffTemplate diffCmd|
text1 := t1 asStringCollection.
text2 := t2 asStringCollection.
- "
- save them texts in two temporary files ...
- "
- tmpFile1 := Filename newTemporary.
- stream := tmpFile1 writeStream.
- text1 do:[:line |
- line notNil ifTrue:[
- stream nextPutAll:line.
+ diffTemplate := self class diffCommand.
+ diffTemplate isNil ifTrue:[
+ "/ self warn:'no diff command available'.
+ ] ifFalse:[
+ "
+ save them texts in two temporary files ...
+ "
+ tmpFile1 := Filename newTemporary.
+ stream := tmpFile1 writeStream.
+ text1 do:[:line |
+ line notNil ifTrue:[
+ stream nextPutAll:line.
+ ].
+ stream cr
].
- stream cr
- ].
- stream close.
+ stream close.
- tmpFile2 := Filename newTemporary.
- stream := tmpFile2 writeStream.
- text2 do:[:line |
- line notNil ifTrue:[
- stream nextPutAll:line.
+ tmpFile2 := Filename newTemporary.
+ stream := tmpFile2 writeStream.
+ text2 do:[:line |
+ line notNil ifTrue:[
+ stream nextPutAll:line.
+ ].
+ stream cr
].
- stream cr
- ].
- stream close.
+ stream close.
- "
- start diff on it ...
- "
- diffCmd := self class diffCommand
+ "
+ start diff on it ...
+ "
+ diffCmd := diffTemplate
bindWith:tmpFile1 asString
with:tmpFile2 asString.
- stream := PipeStream readingFrom:diffCmd.
- stream isNil ifTrue:[
- stream := PipeStream readingFrom:('support' , Filename separator asString , diffCmd).
+ stream := PipeStream readingFrom:diffCmd.
+ stream isNil ifTrue:[
+ stream := PipeStream readingFrom:('support' , Filename separator asString , diffCmd).
+ ].
+ stream isNil ifTrue:[
+ 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.
+ ].
+
+ tmpFile1 delete.
+ tmpFile2 delete.
].
- stream isNil ifTrue:[
- 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.
- ].
-
- tmpFile1 delete.
- tmpFile2 delete.
self updateListsFrom:text1 and:text2 diffs:diffList
@@ -221,6 +238,11 @@
!DiffTextView methodsFor:'initialization'!
+addNextPreviousButtons
+ super addNextPreviousButtons.
+ nextPrevButtonPanel beVisible.
+!
+
initStyle
super initStyle.
@@ -341,7 +363,7 @@
op == $c ifTrue:[
state := #changed.
] ifFalse:[
- op == $a ifTrue:[
+ (op == $a) ifTrue:[
state := #added.
] ifFalse:[
op == $d ifTrue:[
@@ -494,4 +516,4 @@
!DiffTextView class methodsFor:'documentation'!
version
-^ '$Header: /cvs/stx/stx/libtool/Attic/DiffTxtV.st,v 1.24 1999-07-07 13:01:09 cg Exp $'! !
+^ '$Header: /cvs/stx/stx/libtool/Attic/DiffTxtV.st,v 1.25 1999-07-09 14:56:18 cg Exp $'! !