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