author | Claus Gittinger <cg@exept.de> |
Fri, 17 Feb 2006 13:14:51 +0100 | |
changeset 6577 | 51b89422d7de |
parent 6413 | ee2f36cef562 |
child 6649 | e957a17f5b00 |
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 |
||
2716
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
13 |
"{ Package: 'stx:libtool' }" |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
14 |
|
36 | 15 |
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
|
16 |
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
|
17 |
removedBgColor changedColor changedBgColor changedSpacesOnlyColor |
507 | 18 |
changedSpacesOnlyBgColor diffLineNumbers' |
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
19 |
classVariableNames:'DiffCommandTemplate' |
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
20 |
poolDictionaries:'' |
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
21 |
category:'Views-Text' |
36 | 22 |
! |
23 |
||
24 |
!DiffTextView class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
45 | 29 |
All Rights Reserved |
36 | 30 |
|
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
507 | 42 |
a view showing diff output (see unix manual pages) |
43 |
in a user-friendly form. |
|
36 | 44 |
The view is created and opened with: |
45 |
||
507 | 46 |
d := DiffTextView openOn:text1 and:text2 |
47 |
||
48 |
or: |
|
49 |
d := DiffTextView openOn:text1 label:l1 |
|
50 |
and:text2 label:l2 |
|
36 | 51 |
|
507 | 52 |
and it will show the differences side-by-side. |
533 | 53 |
|
2240 | 54 |
The colors mean: |
55 |
red - removed |
|
56 |
green - added |
|
57 |
blue - changed |
|
58 |
light-blue changed, but not really (i.e. spaces only) |
|
59 |
||
60 |
For a real world application and use of this widget, |
|
61 |
see the ChangesBrowsers `compare', |
|
62 |
or the browsers 'compare with repository' functions. |
|
507 | 63 |
|
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
64 |
Notice: |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
65 |
A diff command must be available on your system and found |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
66 |
along the PATH (you will see a warning on stderr, if there is no diff). |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
67 |
We use gnu-diff. |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
68 |
|
507 | 69 |
[see also:] |
1276 | 70 |
TextView EditTextView Diff3TextView |
519 | 71 |
|
72 |
[author:] |
|
73 |
Claus Gittinger |
|
36 | 74 |
" |
1276 | 75 |
! |
76 |
||
77 |
examples |
|
78 |
" |
|
79 |
[exBegin] |
|
80 |
|text1 text2| |
|
81 |
||
82 |
text1 := 'hello world |
|
83 |
here is some difference |
|
84 |
more text |
|
85 |
this line has been removed |
|
86 |
more text |
|
87 |
more text |
|
88 |
'. |
|
89 |
||
90 |
text2 := 'hello world |
|
91 |
where is the difference ? |
|
92 |
more text |
|
93 |
more text |
|
94 |
more text |
|
95 |
this line has been added |
|
96 |
'. |
|
97 |
||
98 |
DiffTextView openOn:text1 label:'text1' |
|
99 |
and:text2 label:'text2' |
|
100 |
[exEnd] |
|
101 |
" |
|
242 | 102 |
! ! |
36 | 103 |
|
2716
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
104 |
!DiffTextView class methodsFor:'instance creation'! |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
105 |
|
2948
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
106 |
openOnClass:classA labelA:lblA andClass:classB labelB:lblB title:title ifSame:sameAction |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
107 |
"provided for protocol compatibility with the VersionDiffBrowser; |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
108 |
actually, the classes are ignored here" |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
109 |
|
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
110 |
|v aStream sourceA sourceB| |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
111 |
|
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
112 |
aStream := '' writeStream. |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
113 |
Method flushSourceStreamCache. |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
114 |
classA fileOutOn:aStream withTimeStamp:false. |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
115 |
sourceA := aStream contents asString. |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
116 |
|
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
117 |
aStream := '' writeStream. |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
118 |
Method flushSourceStreamCache. |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
119 |
classB fileOutOn:aStream withTimeStamp:false. |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
120 |
sourceB := aStream contents asString. |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
121 |
|
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
122 |
v := self |
3755 | 123 |
openOn:sourceA label:lblA |
124 |
and:sourceB label:lblB. |
|
2948
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
125 |
v label:title. |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
126 |
^ v |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
127 |
! |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
128 |
|
2716
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
129 |
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
130 |
"provided for protocol compatibility with the VersionDiffBrowser; |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
131 |
actually, the class is ignored here" |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
132 |
|
3755 | 133 |
^ self |
134 |
openOnClass:someClass |
|
135 |
labelA:lblA sourceA:sourceA |
|
136 |
labelB:lblB sourceB:sourceB |
|
137 |
title:'Comparing ' , someClass name. |
|
2716
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
138 |
! |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
139 |
|
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
140 |
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB title:title |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
141 |
"provided for protocol compatibility with the VersionDiffBrowser; |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
142 |
actually, the class is ignored here" |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
143 |
|
2848 | 144 |
^ self |
3755 | 145 |
openOnClass:someClass |
146 |
labelA:lblA sourceA:sourceA |
|
147 |
labelB:lblB sourceB:sourceB |
|
148 |
title:title ifSame:nil |
|
2848 | 149 |
! |
150 |
||
151 |
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB title:title ifSame:sameAction |
|
152 |
"provided for protocol compatibility with the VersionDiffBrowser; |
|
153 |
actually, the class is ignored here" |
|
154 |
||
2716
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
155 |
|v| |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
156 |
|
2750 | 157 |
v := self |
3755 | 158 |
openOn:sourceA label:lblA |
159 |
and:sourceB label:lblB. |
|
3050 | 160 |
v topView label:title. |
2716
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
161 |
^ v |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
162 |
! ! |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
163 |
|
45 | 164 |
!DiffTextView class methodsFor:'defaults'! |
165 |
||
166 |
diffCommand |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
167 |
"return the diff-command (with argument placeHolders)" |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
168 |
|
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
169 |
DiffCommandTemplate isNil ifTrue:[ |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
170 |
OperatingSystem isMSDOSlike ifTrue:[ |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
171 |
(OperatingSystem canExecuteCommand:'diff') ifFalse:[ |
6397 | 172 |
'DiffTextView [warning]: no diff command found (please download and unzip "UnxUtils.zip" from "unxutils.sourceforge.net")' infoPrintCR. |
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
173 |
^ nil |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
174 |
]. |
6231 | 175 |
^ 'diff %1 %2' |
176 |
]. |
|
177 |
^ 'diff -b %1 %2' |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
178 |
]. |
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
179 |
^ DiffCommandTemplate |
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
180 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
181 |
"Modified: / 30.1.1998 / 12:12:49 / cg" |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
182 |
! |
507 | 183 |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
184 |
diffCommandTemplate:aCommandTemplateString |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
185 |
"set the diff-command template" |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
186 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
187 |
OperatingSystem isMSDOSlike ifTrue:[ |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
188 |
^ DiffCommandTemplate ? 'diff %1 %2' |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
189 |
]. |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
190 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
191 |
^ DiffCommandTemplate ? 'diff -b %1 %2' |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
192 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
193 |
"Modified: / 30.1.1998 / 12:10:34 / cg" |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
194 |
"Created: / 30.1.1998 / 12:12:37 / cg" |
45 | 195 |
! ! |
196 |
||
36 | 197 |
!DiffTextView methodsFor:'accessing'! |
198 |
||
199 |
text1:t1 text2:t2 |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
200 |
"set the two texts which are to be diffed; |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
201 |
execute DiffCommand and update the two textViews." |
507 | 202 |
|
6577
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
203 |
|text1 text2 diffList| |
36 | 204 |
|
69 | 205 |
text1 := t1 asStringCollection. |
206 |
text2 := t2 asStringCollection. |
|
36 | 207 |
|
6577
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
208 |
Error handle:[:ex | |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
209 |
] do:[ |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
210 |
diffList := self diffListFor:text1 and:text2. |
2141 | 211 |
]. |
36 | 212 |
|
213 |
self updateListsFrom:text1 and:text2 diffs:diffList |
|
214 |
||
215 |
" |
|
216 |
|v| |
|
217 |
||
218 |
v := HVScrollableView for:DiffTextView. |
|
219 |
v scrolledView text1:('../libview/Color.st' asFilename readStream contents) |
|
507 | 220 |
text2:('../libview/Color.st.old' asFilename readStream contents). |
36 | 221 |
v open |
222 |
" |
|
223 |
||
224 |
" |
|
225 |
|v t1 t2| |
|
226 |
||
227 |
t1 := ' |
|
228 |
one |
|
229 |
two |
|
230 |
three |
|
231 |
four |
|
232 |
'. |
|
233 |
t2 := ' |
|
234 |
one |
|
235 |
two-a |
|
236 |
two-b |
|
237 |
three |
|
238 |
three-b |
|
239 |
four |
|
240 |
'. |
|
241 |
||
242 |
v := DiffTextView new. |
|
243 |
v text1:t1 text2:t2. |
|
69 | 244 |
v open |
36 | 245 |
" |
507 | 246 |
|
2141 | 247 |
"Modified: / 5.5.1999 / 16:07:13 / cg" |
36 | 248 |
! ! |
183 | 249 |
|
250 |
!DiffTextView methodsFor:'initialization'! |
|
251 |
||
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
252 |
addNextPreviousButtons |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
253 |
super addNextPreviousButtons. |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
254 |
nextPrevButtonPanel beVisible. |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
255 |
! |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
256 |
|
183 | 257 |
initStyle |
258 |
super initStyle. |
|
259 |
||
260 |
showSeparators := false. |
|
261 |
||
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
262 |
(useColors := device hasColors) ifTrue:[ |
2240 | 263 |
addedColor := Color white. |
264 |
addedBgColor := Color red. |
|
183 | 265 |
|
2240 | 266 |
removedColor := Color black. |
267 |
removedBgColor := Color green. |
|
183 | 268 |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
269 |
changedColor := Color white. |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
270 |
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
|
271 |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
272 |
changedSpacesOnlyColor := Color white. |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
273 |
changedSpacesOnlyBgColor := Color blue lightened. |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
274 |
] ifFalse:[ |
623 | 275 |
showSeparators := true. |
276 |
||
277 |
(useColors := device hasGreyscales) ifTrue:[ |
|
278 |
addedBgColor := removedBgColor := changedBgColor := Color grey:80. |
|
279 |
addedColor := removedColor := changedColor := Color black. |
|
280 |
] ifFalse:[ |
|
281 |
addedBgColor := removedBgColor := changedBgColor := Color black. |
|
282 |
addedColor := removedColor := changedColor := Color white. |
|
283 |
]. |
|
284 |
||
285 |
changedSpacesOnlyColor := Color white. |
|
286 |
changedSpacesOnlyBgColor := Color black. |
|
183 | 287 |
]. |
288 |
||
289 |
"Created: 16.11.1995 / 16:59:48 / cg" |
|
623 | 290 |
"Modified: 14.6.1996 / 16:14:39 / cg" |
183 | 291 |
! ! |
292 |
||
293 |
!DiffTextView methodsFor:'private'! |
|
294 |
||
6577
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
295 |
diffListFor:text1 and:text2 |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
296 |
"set the two texts which are to be diffed; |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
297 |
execute DiffCommand and update the two textViews." |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
298 |
|
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
299 |
|tmpFile1 tmpFile2 stream line |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
300 |
diffList diffTemplate diffCmd| |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
301 |
|
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
302 |
diffTemplate := self class diffCommand. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
303 |
diffTemplate isNil ifTrue:[ |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
304 |
"/ self warn:'no diff command available'. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
305 |
^ nil |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
306 |
]. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
307 |
|
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
308 |
" |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
309 |
save them texts in two temporary files ... |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
310 |
" |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
311 |
self save:text1 as:(tmpFile1 := Filename newTemporary). |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
312 |
self save:text2 as:(tmpFile2 := Filename newTemporary). |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
313 |
|
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
314 |
" |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
315 |
start diff on it ... |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
316 |
" |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
317 |
diffCmd := diffTemplate |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
318 |
bindWith:tmpFile1 asString |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
319 |
with:tmpFile2 asString. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
320 |
|
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
321 |
stream := PipeStream readingFrom:diffCmd. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
322 |
stream isNil ifTrue:[ |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
323 |
stream := PipeStream readingFrom:('support' , Filename separator , diffCmd). |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
324 |
]. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
325 |
stream isNil ifTrue:[ |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
326 |
tmpFile1 delete. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
327 |
tmpFile2 delete. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
328 |
self error:'cannot execute diff' mayProceed:true. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
329 |
^ nil. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
330 |
]. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
331 |
|
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
332 |
diffList := OrderedCollection new. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
333 |
[stream atEnd] whileFalse:[ |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
334 |
line := stream nextLine. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
335 |
line notNil ifTrue:[diffList add:line] |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
336 |
]. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
337 |
stream close. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
338 |
|
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
339 |
tmpFile1 delete. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
340 |
tmpFile2 delete. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
341 |
|
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
342 |
^ diffList |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
343 |
! |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
344 |
|
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
345 |
save:text as:filename |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
346 |
|stream| |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
347 |
|
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
348 |
stream := filename writeStream. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
349 |
text do:[:line | |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
350 |
line notNil ifTrue:[ |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
351 |
(line includes:Character return) ifTrue: [ |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
352 |
self error:'oops - funny line (includes returns) in text'. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
353 |
]. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
354 |
stream nextPutAll:line. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
355 |
]. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
356 |
stream cr |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
357 |
]. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
358 |
stream close. |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
359 |
! |
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
360 |
|
183 | 361 |
updateListsFrom:text1 and:text2 diffs:diffList |
362 |
"given the two texts in text1 and text2, and the diff-output in diffList, |
|
363 |
update my views contents" |
|
364 |
||
365 |
|idx1 idx2 dIdx dEnd state s nr1 nr2 nr3 op entry c l1 l2 any delta |
|
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
366 |
textView1 textView2 s1 s2 line1 line2| |
183 | 367 |
|
507 | 368 |
diffLineNumbers := OrderedCollection new. |
369 |
||
183 | 370 |
textView1 := textViews at:1. |
371 |
textView2 := textViews at:2. |
|
372 |
||
373 |
l1 := OrderedCollection new. |
|
374 |
l2 := OrderedCollection new. |
|
375 |
||
4413 | 376 |
diffList size == 1 ifTrue:[ |
377 |
textView1 list:diffList. |
|
378 |
textView2 list:diffList. |
|
379 |
^ self. |
|
380 |
]. |
|
381 |
||
183 | 382 |
idx1 := 1. |
383 |
idx2 := 1. |
|
384 |
||
385 |
dIdx := 1. |
|
386 |
dEnd := diffList size + 1. |
|
387 |
state := #initial. |
|
388 |
[dIdx <= dEnd] whileTrue:[ |
|
389 |
dIdx == dEnd ifTrue:[ |
|
390 |
"dummy cleanup entry" |
|
391 |
entry := nil. |
|
392 |
state := #initial. |
|
393 |
] ifFalse:[ |
|
394 |
entry := diffList at:dIdx. |
|
395 |
]. |
|
396 |
||
397 |
state == #initial ifTrue:[ |
|
398 |
"entry is of the form <nr> <op> <offs> [<offs2>]" |
|
399 |
||
400 |
" |
|
401 |
fill up to size difference from previous change |
|
402 |
" |
|
403 |
delta := l1 size - l2 size. |
|
404 |
delta > 0 ifTrue:[ |
|
405 |
delta timesRepeat:[l2 add:nil] |
|
406 |
] ifFalse:[ |
|
407 |
delta < 0 ifTrue:[ |
|
408 |
delta negated timesRepeat:[l1 add:nil] |
|
409 |
] |
|
410 |
]. |
|
411 |
||
412 |
" |
|
413 |
except for the first chunk, add a separating line |
|
414 |
" |
|
415 |
l1 size ~~ 0 ifTrue:[ |
|
416 |
showSeparators ifTrue:[ |
|
417 |
l1 add:'--------'. |
|
418 |
l2 add:'--------'. |
|
419 |
] |
|
420 |
]. |
|
421 |
" |
|
422 |
in cleanup ? |
|
423 |
" |
|
424 |
entry isNil ifTrue:[ |
|
425 |
nr1 := text1 size + 1. |
|
426 |
nr2 := text2 size + 1. |
|
427 |
state := #finish. |
|
428 |
] ifFalse:[ |
|
507 | 429 |
diffLineNumbers add:l1 size. |
430 |
||
183 | 431 |
s := ReadStream on:entry. |
432 |
nr1 := Integer readFrom:s. |
|
433 |
s peek == $, ifTrue:[ |
|
434 |
s next. |
|
435 |
Integer readFrom:s |
|
436 |
]. |
|
437 |
op := s next. |
|
438 |
nr2 := Integer readFrom:s. |
|
439 |
s peek == $, ifTrue:[ |
|
440 |
s next. |
|
441 |
nr3 := Integer readFrom:s |
|
442 |
] ifFalse:[ |
|
443 |
nr3 := nil |
|
444 |
]. |
|
445 |
||
446 |
op == $c ifTrue:[ |
|
447 |
state := #changed. |
|
448 |
] ifFalse:[ |
|
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
449 |
(op == $a) ifTrue:[ |
183 | 450 |
state := #added. |
451 |
] ifFalse:[ |
|
452 |
op == $d ifTrue:[ |
|
453 |
state := #deleted |
|
454 |
] ifFalse:[ |
|
455 |
self halt:'unexpected diff entry'. |
|
456 |
] |
|
457 |
] |
|
458 |
]. |
|
459 |
||
460 |
]. |
|
461 |
||
462 |
"/ nr1 print. ' ' print. op print. ' ' print. nr2 print. ' , ' print. nr3 printNL. |
|
463 |
||
464 |
" |
|
465 |
copy over unchanged lines |
|
466 |
" |
|
467 |
any := false. |
|
468 |
[idx1 < nr1] whileTrue:[ |
|
469 |
"/ '< add:' print. idx1 printNL. |
|
470 |
l1 add:(text1 at:idx1). |
|
471 |
idx1 := idx1 + 1. |
|
472 |
any := true. |
|
473 |
]. |
|
474 |
[idx2 < nr2] whileTrue:[ |
|
475 |
"/ '> add:' print. idx2 printNL. |
|
476 |
l2 add:(text2 at:idx2). |
|
477 |
idx2 := idx2 + 1. |
|
478 |
any := true. |
|
479 |
]. |
|
480 |
||
481 |
state == #added ifTrue:[ |
|
4489 | 482 |
l1 add:(text1 at:idx1 ifAbsent:''). |
183 | 483 |
idx1 := idx1 + 1. |
484 |
]. |
|
485 |
state == #deleted ifTrue:[ |
|
4489 | 486 |
l2 add:(text2 at:idx2 ifAbsent:''). |
183 | 487 |
idx2 := idx2 + 1. |
488 |
]. |
|
489 |
||
490 |
||
491 |
" |
|
492 |
add a separating line, except at end |
|
493 |
" |
|
494 |
any ifTrue:[ |
|
495 |
state ~~ #finish ifTrue:[ |
|
496 |
showSeparators ifTrue:[ |
|
497 |
l1 add:'--------'. |
|
498 |
l2 add:'--------'. |
|
499 |
] |
|
500 |
] |
|
501 |
]. |
|
502 |
||
503 |
] ifFalse:[ |
|
504 |
state == #changed ifTrue:[ |
|
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
505 |
line1 := line2 := nil. |
183 | 506 |
(entry at:1) == $< ifTrue:[ |
507 |
useColors ifTrue:[ |
|
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
508 |
(l2 size >= idx1 |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
509 |
and:[(s2 := line2 := l2 at:idx1) notNil |
2141 | 510 |
and:[(s2 asString withoutSeparators = (text1 at:idx1) withoutSeparators) |
511 |
"/ or:[(s2 asString withoutSeparators withTabsExpanded = (text1 at:idx1) withoutSeparators withTabsExpanded)] |
|
512 |
]]) ifTrue:[ |
|
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
513 |
line1 := Text string:(text1 at:idx1) |
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
514 |
foregroundColor:changedSpacesOnlyColor |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
515 |
backgroundColor:changedSpacesOnlyBgColor. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
516 |
line2 := Text string:line2 asString |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
517 |
foregroundColor:changedSpacesOnlyColor |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
518 |
backgroundColor:changedSpacesOnlyBgColor. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
519 |
|
2262
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
520 |
line1 string withoutTrailingSeparators = line2 string withoutTrailingSeparators ifTrue:[ |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
521 |
line1 := line1 string. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
522 |
line2 := line2 string. |
6413 | 523 |
] ifFalse:[ |
524 |
line1 withoutSeparators withTabsExpanded = line2 withoutSeparators withTabsExpanded |
|
525 |
ifTrue:[ |
|
526 |
line1 := line1 string. |
|
527 |
line2 := line2 string. |
|
528 |
] |
|
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
529 |
]. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
530 |
l1 add:line1. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
531 |
l2 at:idx1 put:line2. |
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
532 |
] ifFalse:[ |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
533 |
line1 := Text string:(text1 at:idx1) |
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
534 |
foregroundColor:changedColor |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
535 |
backgroundColor:changedBgColor. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
536 |
l1 add:line1. |
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
537 |
] |
183 | 538 |
] ifFalse:[ |
539 |
l1 add:(text1 at:idx1). |
|
540 |
]. |
|
541 |
idx1 := idx1 + 1 |
|
542 |
] ifFalse:[ |
|
543 |
(entry at:1) == $> ifTrue:[ |
|
544 |
useColors ifTrue:[ |
|
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
545 |
(l1 size >= idx2 |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
546 |
and:[(s1 := line1 := l1 at:idx2) notNil |
2141 | 547 |
and:[(s1 asString withoutSeparators = (text2 at:idx2) withoutSeparators) |
548 |
"/ or:[(s1 asString withoutSeparators withTabsExpanded = (text2 at:idx2) withoutSeparators withTabsExpanded)] |
|
549 |
]]) ifTrue:[ |
|
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
550 |
line2 := Text string:(text2 at:idx2) |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
551 |
foregroundColor:changedSpacesOnlyColor |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
552 |
backgroundColor:changedSpacesOnlyBgColor. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
553 |
line1 := Text string:line1 asString |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
554 |
foregroundColor:changedSpacesOnlyColor |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
555 |
backgroundColor:changedSpacesOnlyBgColor. |
2262
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
556 |
line1 string withoutTrailingSeparators = line2 string withoutTrailingSeparators ifTrue:[ |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
557 |
line1 := line1 string. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
558 |
line2 := line2 string. |
6413 | 559 |
] ifFalse:[ |
560 |
line1 withoutSeparators withTabsExpanded = line2 withoutSeparators withTabsExpanded |
|
561 |
ifTrue:[ |
|
562 |
line1 := line1 string. |
|
563 |
line2 := line2 string. |
|
564 |
] |
|
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
565 |
]. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
566 |
l2 add:line2. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
567 |
l1 at:idx2 put:line1. |
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
568 |
] ifFalse:[ |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
569 |
line2 := Text string:(text2 at:idx2) foregroundColor:changedColor backgroundColor:changedBgColor. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
570 |
l2 add:line2 |
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
571 |
] |
183 | 572 |
] ifFalse:[ |
573 |
l2 add:(text2 at:idx2). |
|
574 |
]. |
|
575 |
idx2 := idx2 + 1 |
|
576 |
] ifFalse:[ |
|
577 |
(entry at:1) == $- ifTrue:[ |
|
578 |
] ifFalse:[ |
|
579 |
state := #initial. |
|
580 |
dIdx := dIdx - 1 |
|
581 |
] |
|
582 |
] |
|
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
583 |
]. |
183 | 584 |
] ifFalse:[ |
585 |
state == #added ifTrue:[ |
|
586 |
(entry at:1) == $> ifTrue:[ |
|
587 |
useColors ifTrue:[ |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
588 |
l2 add:(Text string:(text2 at:idx2) foregroundColor:addedColor backgroundColor:addedBgColor ) |
183 | 589 |
] ifFalse:[ |
590 |
l2 add:(text2 at:idx2). |
|
591 |
]. |
|
592 |
idx2 := idx2 + 1. |
|
593 |
l1 add:nil |
|
594 |
] ifFalse:[ |
|
595 |
state := #initial. |
|
596 |
dIdx := dIdx - 1 |
|
597 |
] |
|
598 |
] ifFalse:[ |
|
599 |
state == #deleted ifTrue:[ |
|
600 |
(entry at:1) == $< ifTrue:[ |
|
601 |
useColors ifTrue:[ |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
602 |
l1 add:(Text string:(text1 at:idx1) foregroundColor:removedColor backgroundColor:removedBgColor ). |
183 | 603 |
] ifFalse:[ |
604 |
l1 add:(text1 at:idx1). |
|
605 |
]. |
|
606 |
idx1 := idx1 + 1. |
|
607 |
l2 add:nil |
|
608 |
] ifFalse:[ |
|
609 |
state := #initial. |
|
610 |
dIdx := dIdx - 1 |
|
611 |
] |
|
612 |
] |
|
613 |
"must be in finish otherwise" |
|
614 |
] |
|
615 |
] |
|
616 |
]. |
|
617 |
dIdx := dIdx + 1 |
|
618 |
]. |
|
619 |
[l1 size < l2 size] whileTrue:[ |
|
620 |
l1 add:''. |
|
621 |
]. |
|
622 |
[l2 size < l1 size] whileTrue:[ |
|
623 |
l2 add:''. |
|
624 |
]. |
|
2262
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
625 |
|
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
626 |
"/ fixup - diff -b is ignoring lines which differ in leading space only ... |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
627 |
1 to:l1 size do:[:idx | |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
628 |
|line1 line2| |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
629 |
|
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
630 |
line1 := l1 at:idx. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
631 |
line2 := l2 at:idx. |
2268 | 632 |
(line1 notNil and:[line1 hasChangeOfEmphasis not]) ifTrue:[ |
633 |
(line2 notNil and:[line2 hasChangeOfEmphasis not]) ifTrue:[ |
|
2262
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
634 |
line1 withTabsExpanded withoutTrailingSeparators |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
635 |
~= line2 withTabsExpanded withoutTrailingSeparators |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
636 |
ifTrue:[ |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
637 |
line1 := Text string:line1 |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
638 |
foregroundColor:changedSpacesOnlyColor |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
639 |
backgroundColor:changedSpacesOnlyBgColor. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
640 |
line2 := Text string:line2 |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
641 |
foregroundColor:changedSpacesOnlyColor |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
642 |
backgroundColor:changedSpacesOnlyBgColor. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
643 |
l1 at:idx put:line1. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
644 |
l2 at:idx put:line2. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
645 |
] |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
646 |
] |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
647 |
] |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
648 |
]. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
649 |
|
183 | 650 |
textView1 list:l1. |
651 |
textView2 list:l2 |
|
652 |
||
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
653 |
"Modified: / 13.7.1999 / 14:12:11 / cg" |
183 | 654 |
! ! |
655 |
||
242 | 656 |
!DiffTextView class methodsFor:'documentation'! |
657 |
||
658 |
version |
|
6577
51b89422d7de
be more robust w.r.t. errors while diffing
Claus Gittinger <cg@exept.de>
parents:
6413
diff
changeset
|
659 |
^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.43 2006-02-17 12:14:51 cg Exp $' |
2268 | 660 |
! ! |