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