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