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