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. |