DiffTextView.st
changeset 1440 6a68adba9c33
parent 1276 66761d461a39
child 2141 1758f387ebe7
equal deleted inserted replaced
1439:d901436411af 1440:6a68adba9c33
    12 
    12 
    13 TwoColumnTextView subclass:#DiffTextView
    13 TwoColumnTextView subclass:#DiffTextView
    14 	instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor
    14 	instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor
    15 		removedBgColor changedColor changedBgColor changedSpacesOnlyColor
    15 		removedBgColor changedColor changedBgColor changedSpacesOnlyColor
    16 		changedSpacesOnlyBgColor diffLineNumbers'
    16 		changedSpacesOnlyBgColor diffLineNumbers'
    17 	classVariableNames:''
    17 	classVariableNames:'DiffCommandTemplate'
    18 	poolDictionaries:''
    18 	poolDictionaries:''
    19 	category:'Views-Text'
    19 	category:'Views-Text'
    20 !
    20 !
    21 
    21 
    22 !DiffTextView class methodsFor:'documentation'!
    22 !DiffTextView class methodsFor:'documentation'!
    88 ! !
    88 ! !
    89 
    89 
    90 !DiffTextView class methodsFor:'defaults'!
    90 !DiffTextView class methodsFor:'defaults'!
    91 
    91 
    92 diffCommand
    92 diffCommand
    93     "return the diff-command (with arguments)"
    93     "return the diff-command (with argument placeHolders)"
    94 
    94 
    95     ^ 'diff -b'
    95     OperatingSystem isMSDOSlike ifTrue:[
       
    96         ^ DiffCommandTemplate ? 'diff %1 %2'
       
    97     ].
       
    98 
       
    99     ^ DiffCommandTemplate ? 'diff -b %1 %2'
       
   100 
       
   101     "Modified: / 30.1.1998 / 12:12:49 / cg"
       
   102 !
       
   103 
       
   104 diffCommandTemplate:aCommandTemplateString
       
   105     "set the diff-command template"
       
   106 
       
   107     OperatingSystem isMSDOSlike ifTrue:[
       
   108         ^ DiffCommandTemplate ? 'diff %1 %2'
       
   109     ].
       
   110 
       
   111     ^ DiffCommandTemplate ? 'diff -b %1 %2'
       
   112 
       
   113     "Modified: / 30.1.1998 / 12:10:34 / cg"
       
   114     "Created: / 30.1.1998 / 12:12:37 / cg"
    96 ! !
   115 ! !
    97 
   116 
    98 !DiffTextView methodsFor:'accessing'!
   117 !DiffTextView methodsFor:'accessing'!
    99 
   118 
   100 text1:t1 text2:t2
   119 text1:t1 text2:t2
   101     "set the two texts which are to be diffed"
   120     "set the two texts which are to be diffed;
   102 
   121      execute DiffCommand and update the two textViews."
   103     |tmpFile1 tmpFile2 name1 tmpName2 stream line text1 text2 diffList pidString|
   122 
       
   123     |tmpFile1 tmpFile2 name1 tmpName2 stream line 
       
   124      text1 text2 diffList pidString diffCmd|
   104 
   125 
   105     text1 := t1 asStringCollection.
   126     text1 := t1 asStringCollection.
   106     text2 := t2 asStringCollection.
   127     text2 := t2 asStringCollection.
   107 
   128 
   108     "
   129     "
   123     stream close.
   144     stream close.
   124 
   145 
   125     "
   146     "
   126      start diff on it ...
   147      start diff on it ...
   127     "
   148     "
   128     stream := PipeStream 
   149     diffCmd := self class diffCommand 
   129                 readingFrom:self class diffCommand , ' ' , 
   150                     bindWith:tmpFile1 asString
   130                             tmpFile1 asString, ' ' , tmpFile2 asString.
   151                     with:tmpFile2 asString.
       
   152 
       
   153     stream := PipeStream readingFrom:diffCmd.
   131     stream isNil ifTrue:[
   154     stream isNil ifTrue:[
   132         self error:'cannot execute diff'.
   155         self error:'cannot execute diff'.
   133         text1 := text2 := nil.
   156         text1 := text2 := nil.
   134     ] ifFalse:[
   157     ] ifFalse:[
   135         diffList := OrderedCollection new.
   158         diffList := OrderedCollection new.
   175      v := DiffTextView new.
   198      v := DiffTextView new.
   176      v text1:t1 text2:t2.
   199      v text1:t1 text2:t2.
   177      v open
   200      v open
   178     "
   201     "
   179 
   202 
   180     "Modified: 25.4.1996 / 13:33:52 / cg"
   203     "Modified: / 30.1.1998 / 12:12:13 / cg"
   181 ! !
   204 ! !
   182 
   205 
   183 !DiffTextView methodsFor:'initialization'!
   206 !DiffTextView methodsFor:'initialization'!
   184 
   207 
   185 initStyle
   208 initStyle
   449 ! !
   472 ! !
   450 
   473 
   451 !DiffTextView class methodsFor:'documentation'!
   474 !DiffTextView class methodsFor:'documentation'!
   452 
   475 
   453 version
   476 version
   454 ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.21 1997-08-07 10:54:51 cg Exp $'! !
   477 ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.22 1998-01-30 11:24:57 cg Exp $'! !