author | Claus Gittinger <cg@exept.de> |
Fri, 30 Jan 1998 12:24:57 +0100 | |
changeset 1440 | 6a68adba9c33 |
parent 1276 | 66761d461a39 |
child 2141 | 1758f387ebe7 |
permissions | -rw-r--r-- |
36 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
45 | 3 |
All Rights Reserved |
36 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
TwoColumnTextView subclass:#DiffTextView |
|
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
14 |
instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor |
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
15 |
removedBgColor changedColor changedBgColor changedSpacesOnlyColor |
507 | 16 |
changedSpacesOnlyBgColor diffLineNumbers' |
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
17 |
classVariableNames:'DiffCommandTemplate' |
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
18 |
poolDictionaries:'' |
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
19 |
category:'Views-Text' |
36 | 20 |
! |
21 |
||
22 |
!DiffTextView class methodsFor:'documentation'! |
|
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
45 | 27 |
All Rights Reserved |
36 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
507 | 40 |
a view showing diff output (see unix manual pages) |
41 |
in a user-friendly form. |
|
36 | 42 |
The view is created and opened with: |
43 |
||
507 | 44 |
d := DiffTextView openOn:text1 and:text2 |
45 |
||
46 |
or: |
|
47 |
d := DiffTextView openOn:text1 label:l1 |
|
48 |
and:text2 label:l2 |
|
36 | 49 |
|
507 | 50 |
and it will show the differences side-by-side. |
533 | 51 |
|
52 |
For a real world application, |
|
53 |
see the ChangesBrowsers `compare' function. |
|
507 | 54 |
|
55 |
[see also:] |
|
1276 | 56 |
TextView EditTextView Diff3TextView |
519 | 57 |
|
58 |
[author:] |
|
59 |
Claus Gittinger |
|
36 | 60 |
" |
1276 | 61 |
! |
62 |
||
63 |
examples |
|
64 |
" |
|
65 |
[exBegin] |
|
66 |
|text1 text2| |
|
67 |
||
68 |
text1 := 'hello world |
|
69 |
here is some difference |
|
70 |
more text |
|
71 |
this line has been removed |
|
72 |
more text |
|
73 |
more text |
|
74 |
'. |
|
75 |
||
76 |
text2 := 'hello world |
|
77 |
where is the difference ? |
|
78 |
more text |
|
79 |
more text |
|
80 |
more text |
|
81 |
this line has been added |
|
82 |
'. |
|
83 |
||
84 |
DiffTextView openOn:text1 label:'text1' |
|
85 |
and:text2 label:'text2' |
|
86 |
[exEnd] |
|
87 |
" |
|
242 | 88 |
! ! |
36 | 89 |
|
45 | 90 |
!DiffTextView class methodsFor:'defaults'! |
91 |
||
92 |
diffCommand |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
93 |
"return the diff-command (with argument placeHolders)" |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
94 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
95 |
OperatingSystem isMSDOSlike ifTrue:[ |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
96 |
^ DiffCommandTemplate ? 'diff %1 %2' |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
97 |
]. |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
98 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
99 |
^ DiffCommandTemplate ? 'diff -b %1 %2' |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
100 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
101 |
"Modified: / 30.1.1998 / 12:12:49 / cg" |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
102 |
! |
507 | 103 |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
104 |
diffCommandTemplate:aCommandTemplateString |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
105 |
"set the diff-command template" |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
106 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
107 |
OperatingSystem isMSDOSlike ifTrue:[ |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
108 |
^ DiffCommandTemplate ? 'diff %1 %2' |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
109 |
]. |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
110 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
111 |
^ DiffCommandTemplate ? 'diff -b %1 %2' |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
112 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
113 |
"Modified: / 30.1.1998 / 12:10:34 / cg" |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
114 |
"Created: / 30.1.1998 / 12:12:37 / cg" |
45 | 115 |
! ! |
116 |
||
36 | 117 |
!DiffTextView methodsFor:'accessing'! |
118 |
||
119 |
text1:t1 text2:t2 |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
120 |
"set the two texts which are to be diffed; |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
121 |
execute DiffCommand and update the two textViews." |
507 | 122 |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
123 |
|tmpFile1 tmpFile2 name1 tmpName2 stream line |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
124 |
text1 text2 diffList pidString diffCmd| |
36 | 125 |
|
69 | 126 |
text1 := t1 asStringCollection. |
127 |
text2 := t2 asStringCollection. |
|
36 | 128 |
|
129 |
" |
|
130 |
save them texts in two temporary files ... |
|
131 |
" |
|
69 | 132 |
tmpFile1 := Filename newTemporary. |
133 |
stream := tmpFile1 writeStream. |
|
36 | 134 |
text1 do:[:line | |
507 | 135 |
stream nextPutAll:line; cr |
36 | 136 |
]. |
137 |
stream close. |
|
138 |
||
69 | 139 |
tmpFile2 := Filename newTemporary. |
140 |
stream := tmpFile2 writeStream. |
|
36 | 141 |
text2 do:[:line | |
507 | 142 |
stream nextPutAll:line; cr |
36 | 143 |
]. |
144 |
stream close. |
|
145 |
||
146 |
" |
|
147 |
start diff on it ... |
|
148 |
" |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
149 |
diffCmd := self class diffCommand |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
150 |
bindWith:tmpFile1 asString |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
151 |
with:tmpFile2 asString. |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
152 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
153 |
stream := PipeStream readingFrom:diffCmd. |
36 | 154 |
stream isNil ifTrue:[ |
507 | 155 |
self error:'cannot execute diff'. |
156 |
text1 := text2 := nil. |
|
45 | 157 |
] ifFalse:[ |
507 | 158 |
diffList := OrderedCollection new. |
159 |
[stream atEnd] whileFalse:[ |
|
160 |
line := stream nextLine. |
|
161 |
line notNil ifTrue:[diffList add:line] |
|
162 |
]. |
|
163 |
stream close. |
|
36 | 164 |
]. |
45 | 165 |
|
69 | 166 |
tmpFile1 delete. |
167 |
tmpFile2 delete. |
|
36 | 168 |
|
169 |
self updateListsFrom:text1 and:text2 diffs:diffList |
|
170 |
||
171 |
" |
|
172 |
|v| |
|
173 |
||
174 |
v := HVScrollableView for:DiffTextView. |
|
175 |
v scrolledView text1:('../libview/Color.st' asFilename readStream contents) |
|
507 | 176 |
text2:('../libview/Color.st.old' asFilename readStream contents). |
36 | 177 |
v open |
178 |
" |
|
179 |
||
180 |
" |
|
181 |
|v t1 t2| |
|
182 |
||
183 |
t1 := ' |
|
184 |
one |
|
185 |
two |
|
186 |
three |
|
187 |
four |
|
188 |
'. |
|
189 |
t2 := ' |
|
190 |
one |
|
191 |
two-a |
|
192 |
two-b |
|
193 |
three |
|
194 |
three-b |
|
195 |
four |
|
196 |
'. |
|
197 |
||
198 |
v := DiffTextView new. |
|
199 |
v text1:t1 text2:t2. |
|
69 | 200 |
v open |
36 | 201 |
" |
507 | 202 |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
203 |
"Modified: / 30.1.1998 / 12:12:13 / cg" |
36 | 204 |
! ! |
183 | 205 |
|
206 |
!DiffTextView methodsFor:'initialization'! |
|
207 |
||
208 |
initStyle |
|
209 |
super initStyle. |
|
210 |
||
211 |
showSeparators := false. |
|
212 |
||
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
213 |
(useColors := device hasColors) ifTrue:[ |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
214 |
addedColor := Color black. |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
215 |
addedBgColor := Color green. |
183 | 216 |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
217 |
removedColor := Color white. |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
218 |
removedBgColor := Color red. |
183 | 219 |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
220 |
changedColor := Color white. |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
221 |
changedBgColor := Color blue. |
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
222 |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
223 |
changedSpacesOnlyColor := Color white. |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
224 |
changedSpacesOnlyBgColor := Color blue lightened. |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
225 |
] ifFalse:[ |
623 | 226 |
showSeparators := true. |
227 |
||
228 |
(useColors := device hasGreyscales) ifTrue:[ |
|
229 |
addedBgColor := removedBgColor := changedBgColor := Color grey:80. |
|
230 |
addedColor := removedColor := changedColor := Color black. |
|
231 |
] ifFalse:[ |
|
232 |
addedBgColor := removedBgColor := changedBgColor := Color black. |
|
233 |
addedColor := removedColor := changedColor := Color white. |
|
234 |
]. |
|
235 |
||
236 |
changedSpacesOnlyColor := Color white. |
|
237 |
changedSpacesOnlyBgColor := Color black. |
|
183 | 238 |
]. |
239 |
||
240 |
"Created: 16.11.1995 / 16:59:48 / cg" |
|
623 | 241 |
"Modified: 14.6.1996 / 16:14:39 / cg" |
183 | 242 |
! ! |
243 |
||
244 |
!DiffTextView methodsFor:'private'! |
|
245 |
||
246 |
updateListsFrom:text1 and:text2 diffs:diffList |
|
247 |
"given the two texts in text1 and text2, and the diff-output in diffList, |
|
248 |
update my views contents" |
|
249 |
||
250 |
|idx1 idx2 dIdx dEnd state s nr1 nr2 nr3 op entry c l1 l2 any delta |
|
318 | 251 |
textView1 textView2 s1 s2| |
183 | 252 |
|
507 | 253 |
diffLineNumbers := OrderedCollection new. |
254 |
||
183 | 255 |
textView1 := textViews at:1. |
256 |
textView2 := textViews at:2. |
|
257 |
||
258 |
l1 := OrderedCollection new. |
|
259 |
l2 := OrderedCollection new. |
|
260 |
||
261 |
idx1 := 1. |
|
262 |
idx2 := 1. |
|
263 |
||
264 |
dIdx := 1. |
|
265 |
dEnd := diffList size + 1. |
|
266 |
state := #initial. |
|
267 |
[dIdx <= dEnd] whileTrue:[ |
|
268 |
dIdx == dEnd ifTrue:[ |
|
269 |
"dummy cleanup entry" |
|
270 |
entry := nil. |
|
271 |
state := #initial. |
|
272 |
] ifFalse:[ |
|
273 |
entry := diffList at:dIdx. |
|
274 |
]. |
|
275 |
||
276 |
state == #initial ifTrue:[ |
|
277 |
"entry is of the form <nr> <op> <offs> [<offs2>]" |
|
278 |
||
279 |
" |
|
280 |
fill up to size difference from previous change |
|
281 |
" |
|
282 |
delta := l1 size - l2 size. |
|
283 |
delta > 0 ifTrue:[ |
|
284 |
delta timesRepeat:[l2 add:nil] |
|
285 |
] ifFalse:[ |
|
286 |
delta < 0 ifTrue:[ |
|
287 |
delta negated timesRepeat:[l1 add:nil] |
|
288 |
] |
|
289 |
]. |
|
290 |
||
291 |
" |
|
292 |
except for the first chunk, add a separating line |
|
293 |
" |
|
294 |
l1 size ~~ 0 ifTrue:[ |
|
295 |
showSeparators ifTrue:[ |
|
296 |
l1 add:'--------'. |
|
297 |
l2 add:'--------'. |
|
298 |
] |
|
299 |
]. |
|
300 |
" |
|
301 |
in cleanup ? |
|
302 |
" |
|
303 |
entry isNil ifTrue:[ |
|
304 |
nr1 := text1 size + 1. |
|
305 |
nr2 := text2 size + 1. |
|
306 |
state := #finish. |
|
307 |
] ifFalse:[ |
|
507 | 308 |
diffLineNumbers add:l1 size. |
309 |
||
183 | 310 |
s := ReadStream on:entry. |
311 |
nr1 := Integer readFrom:s. |
|
312 |
s peek == $, ifTrue:[ |
|
313 |
s next. |
|
314 |
Integer readFrom:s |
|
315 |
]. |
|
316 |
op := s next. |
|
317 |
nr2 := Integer readFrom:s. |
|
318 |
s peek == $, ifTrue:[ |
|
319 |
s next. |
|
320 |
nr3 := Integer readFrom:s |
|
321 |
] ifFalse:[ |
|
322 |
nr3 := nil |
|
323 |
]. |
|
324 |
||
325 |
op == $c ifTrue:[ |
|
326 |
state := #changed. |
|
327 |
] ifFalse:[ |
|
328 |
op == $a ifTrue:[ |
|
329 |
state := #added. |
|
330 |
] ifFalse:[ |
|
331 |
op == $d ifTrue:[ |
|
332 |
state := #deleted |
|
333 |
] ifFalse:[ |
|
334 |
self halt:'unexpected diff entry'. |
|
335 |
] |
|
336 |
] |
|
337 |
]. |
|
338 |
||
339 |
]. |
|
340 |
||
341 |
"/ nr1 print. ' ' print. op print. ' ' print. nr2 print. ' , ' print. nr3 printNL. |
|
342 |
||
343 |
" |
|
344 |
copy over unchanged lines |
|
345 |
" |
|
346 |
any := false. |
|
347 |
[idx1 < nr1] whileTrue:[ |
|
348 |
"/ '< add:' print. idx1 printNL. |
|
349 |
l1 add:(text1 at:idx1). |
|
350 |
idx1 := idx1 + 1. |
|
351 |
any := true. |
|
352 |
]. |
|
353 |
[idx2 < nr2] whileTrue:[ |
|
354 |
"/ '> add:' print. idx2 printNL. |
|
355 |
l2 add:(text2 at:idx2). |
|
356 |
idx2 := idx2 + 1. |
|
357 |
any := true. |
|
358 |
]. |
|
359 |
||
360 |
state == #added ifTrue:[ |
|
361 |
l1 add:(text1 at:idx1). |
|
362 |
idx1 := idx1 + 1. |
|
363 |
]. |
|
364 |
state == #deleted ifTrue:[ |
|
365 |
l2 add:(text2 at:idx2). |
|
366 |
idx2 := idx2 + 1. |
|
367 |
]. |
|
368 |
||
369 |
||
370 |
" |
|
371 |
add a separating line, except at end |
|
372 |
" |
|
373 |
any ifTrue:[ |
|
374 |
state ~~ #finish ifTrue:[ |
|
375 |
showSeparators ifTrue:[ |
|
376 |
l1 add:'--------'. |
|
377 |
l2 add:'--------'. |
|
378 |
] |
|
379 |
] |
|
380 |
]. |
|
381 |
||
382 |
] ifFalse:[ |
|
383 |
state == #changed ifTrue:[ |
|
384 |
(entry at:1) == $< ifTrue:[ |
|
385 |
useColors ifTrue:[ |
|
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
386 |
(l2 size >= idx1 |
318 | 387 |
and:[(s2 := l2 at:idx1) notNil |
388 |
and:[s2 asString withoutSeparators = (text1 at:idx1) withoutSeparators]]) ifTrue:[ |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
389 |
l1 add:(Text string:(text1 at:idx1) |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
390 |
foregroundColor:changedSpacesOnlyColor |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
391 |
backgroundColor:changedSpacesOnlyBgColor). |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
392 |
l2 at:idx1 put:(Text string:(l2 at:idx1) asString |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
393 |
foregroundColor:changedSpacesOnlyColor |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
394 |
backgroundColor:changedSpacesOnlyBgColor). |
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
395 |
] ifFalse:[ |
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
396 |
l1 add:(Text string:(text1 at:idx1) |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
397 |
foregroundColor:changedColor |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
398 |
backgroundColor:changedBgColor). |
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
399 |
] |
183 | 400 |
] ifFalse:[ |
401 |
l1 add:(text1 at:idx1). |
|
402 |
]. |
|
403 |
idx1 := idx1 + 1 |
|
404 |
] ifFalse:[ |
|
405 |
(entry at:1) == $> ifTrue:[ |
|
406 |
useColors ifTrue:[ |
|
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
407 |
(l1 size >= idx2 |
318 | 408 |
and:[(s1 := l1 at:idx2) notNil |
409 |
and:[s1 asString withoutSeparators = (text2 at:idx2) withoutSeparators]]) ifTrue:[ |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
410 |
l2 add:(Text string:(text2 at:idx2) foregroundColor:changedSpacesOnlyColor backgroundColor:changedSpacesOnlyBgColor). |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
411 |
l1 at:idx2 put:(Text string:(l1 at:idx2) asString foregroundColor:changedSpacesOnlyColor backgroundColor:changedSpacesOnlyBgColor). |
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
412 |
] ifFalse:[ |
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
413 |
l2 add:(Text string:(text2 at:idx2) foregroundColor:changedColor backgroundColor:changedBgColor) |
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
414 |
] |
183 | 415 |
] ifFalse:[ |
416 |
l2 add:(text2 at:idx2). |
|
417 |
]. |
|
418 |
idx2 := idx2 + 1 |
|
419 |
] ifFalse:[ |
|
420 |
(entry at:1) == $- ifTrue:[ |
|
421 |
] ifFalse:[ |
|
422 |
state := #initial. |
|
423 |
dIdx := dIdx - 1 |
|
424 |
] |
|
425 |
] |
|
426 |
] |
|
427 |
] ifFalse:[ |
|
428 |
state == #added ifTrue:[ |
|
429 |
(entry at:1) == $> ifTrue:[ |
|
430 |
useColors ifTrue:[ |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
431 |
l2 add:(Text string:(text2 at:idx2) foregroundColor:addedColor backgroundColor:addedBgColor ) |
183 | 432 |
] ifFalse:[ |
433 |
l2 add:(text2 at:idx2). |
|
434 |
]. |
|
435 |
idx2 := idx2 + 1. |
|
436 |
l1 add:nil |
|
437 |
] ifFalse:[ |
|
438 |
state := #initial. |
|
439 |
dIdx := dIdx - 1 |
|
440 |
] |
|
441 |
] ifFalse:[ |
|
442 |
state == #deleted ifTrue:[ |
|
443 |
(entry at:1) == $< ifTrue:[ |
|
444 |
useColors ifTrue:[ |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
445 |
l1 add:(Text string:(text1 at:idx1) foregroundColor:removedColor backgroundColor:removedBgColor ). |
183 | 446 |
] ifFalse:[ |
447 |
l1 add:(text1 at:idx1). |
|
448 |
]. |
|
449 |
idx1 := idx1 + 1. |
|
450 |
l2 add:nil |
|
451 |
] ifFalse:[ |
|
452 |
state := #initial. |
|
453 |
dIdx := dIdx - 1 |
|
454 |
] |
|
455 |
] |
|
456 |
"must be in finish otherwise" |
|
457 |
] |
|
458 |
] |
|
459 |
]. |
|
460 |
dIdx := dIdx + 1 |
|
461 |
]. |
|
462 |
[l1 size < l2 size] whileTrue:[ |
|
463 |
l1 add:''. |
|
464 |
]. |
|
465 |
[l2 size < l1 size] whileTrue:[ |
|
466 |
l2 add:''. |
|
467 |
]. |
|
468 |
textView1 list:l1. |
|
469 |
textView2 list:l2 |
|
470 |
||
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
471 |
"Modified: 16.5.1996 / 12:38:49 / cg" |
183 | 472 |
! ! |
473 |
||
242 | 474 |
!DiffTextView class methodsFor:'documentation'! |
475 |
||
476 |
version |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
477 |
^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.22 1998-01-30 11:24:57 cg Exp $'! ! |