author | penk |
Thu, 19 Jul 2001 16:12:01 +0200 | |
changeset 3050 | 56e5cc9afece |
parent 2948 | cf5b7f232536 |
child 3678 | 7a54c5f8c9fe |
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 |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
123 |
openOn:sourceA label:lblA |
cf5b7f232536
VersionDIffBrowser compatibility
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
124 |
and:sourceB label:lblB. |
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 |
|
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
133 |
^ self 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
|
134 |
title:'comparing ' , someClass name. |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
135 |
! |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
136 |
|
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
137 |
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB title:title |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
138 |
"provided for protocol compatibility with the VersionDiffBrowser; |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
139 |
actually, the class is ignored here" |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
140 |
|
2848 | 141 |
^ self |
142 |
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB title:title ifSame:nil |
|
143 |
! |
|
144 |
||
145 |
openOnClass:someClass labelA:lblA sourceA:sourceA labelB:lblB sourceB:sourceB title:title ifSame:sameAction |
|
146 |
"provided for protocol compatibility with the VersionDiffBrowser; |
|
147 |
actually, the class is ignored here" |
|
148 |
||
2716
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
149 |
|v| |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
150 |
|
2750 | 151 |
v := self |
2716
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
152 |
openOn:sourceA label:lblA |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
153 |
and:sourceB label:lblB. |
3050 | 154 |
v topView label:title. |
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 |
! ! |
8451e7057f00
some common startup protocol between DiffViewer and VersionDiffBrowser
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
157 |
|
45 | 158 |
!DiffTextView class methodsFor:'defaults'! |
159 |
||
160 |
diffCommand |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
161 |
"return the diff-command (with argument placeHolders)" |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
162 |
|
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
163 |
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
|
164 |
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
|
165 |
(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
|
166 |
'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
|
167 |
^ nil |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
168 |
]. |
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 := '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
|
170 |
] ifFalse:[ |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
171 |
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
|
172 |
] |
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
173 |
]. |
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
174 |
^ DiffCommandTemplate |
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
175 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
176 |
"Modified: / 30.1.1998 / 12:12:49 / cg" |
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 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
182 |
OperatingSystem isMSDOSlike ifTrue:[ |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
183 |
^ DiffCommandTemplate ? 'diff %1 %2' |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
184 |
]. |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
185 |
|
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
186 |
^ DiffCommandTemplate ? 'diff -b %1 %2' |
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 |
"Modified: / 30.1.1998 / 12:10:34 / cg" |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
189 |
"Created: / 30.1.1998 / 12:12:37 / cg" |
45 | 190 |
! ! |
191 |
||
36 | 192 |
!DiffTextView methodsFor:'accessing'! |
193 |
||
194 |
text1:t1 text2:t2 |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
195 |
"set the two texts which are to be diffed; |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
196 |
execute DiffCommand and update the two textViews." |
507 | 197 |
|
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
198 |
|tmpFile1 tmpFile2 name1 tmpName2 stream line |
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
199 |
text1 text2 diffList pidString diffTemplate diffCmd| |
36 | 200 |
|
69 | 201 |
text1 := t1 asStringCollection. |
202 |
text2 := t2 asStringCollection. |
|
36 | 203 |
|
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
204 |
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
|
205 |
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
|
206 |
"/ 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
|
207 |
] ifFalse:[ |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
208 |
" |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
209 |
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
|
210 |
" |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
211 |
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
|
212 |
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
|
213 |
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
|
214 |
line notNil ifTrue:[ |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
215 |
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
|
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 |
stream cr |
2141 | 218 |
]. |
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
219 |
stream close. |
36 | 220 |
|
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
221 |
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
|
222 |
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
|
223 |
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
|
224 |
line notNil ifTrue:[ |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
225 |
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
|
226 |
]. |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
227 |
stream cr |
2141 | 228 |
]. |
2246
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 close. |
36 | 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 |
" |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
232 |
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
|
233 |
" |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
234 |
diffCmd := diffTemplate |
1440
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
235 |
bindWith:tmpFile1 asString |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
236 |
with:tmpFile2 asString. |
6a68adba9c33
allow configuration of diff command;
Claus Gittinger <cg@exept.de>
parents:
1276
diff
changeset
|
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 |
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
|
239 |
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
|
240 |
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
|
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 |
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
|
243 |
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
|
244 |
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
|
245 |
] ifFalse:[ |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
246 |
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
|
247 |
[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
|
248 |
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
|
249 |
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
|
250 |
]. |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
251 |
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
|
252 |
]. |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
253 |
|
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
254 |
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
|
255 |
tmpFile2 delete. |
2141 | 256 |
]. |
36 | 257 |
|
258 |
self updateListsFrom:text1 and:text2 diffs:diffList |
|
259 |
||
260 |
" |
|
261 |
|v| |
|
262 |
||
263 |
v := HVScrollableView for:DiffTextView. |
|
264 |
v scrolledView text1:('../libview/Color.st' asFilename readStream contents) |
|
507 | 265 |
text2:('../libview/Color.st.old' asFilename readStream contents). |
36 | 266 |
v open |
267 |
" |
|
268 |
||
269 |
" |
|
270 |
|v t1 t2| |
|
271 |
||
272 |
t1 := ' |
|
273 |
one |
|
274 |
two |
|
275 |
three |
|
276 |
four |
|
277 |
'. |
|
278 |
t2 := ' |
|
279 |
one |
|
280 |
two-a |
|
281 |
two-b |
|
282 |
three |
|
283 |
three-b |
|
284 |
four |
|
285 |
'. |
|
286 |
||
287 |
v := DiffTextView new. |
|
288 |
v text1:t1 text2:t2. |
|
69 | 289 |
v open |
36 | 290 |
" |
507 | 291 |
|
2141 | 292 |
"Modified: / 5.5.1999 / 16:07:13 / cg" |
36 | 293 |
! ! |
183 | 294 |
|
295 |
!DiffTextView methodsFor:'initialization'! |
|
296 |
||
2246
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
297 |
addNextPreviousButtons |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
298 |
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
|
299 |
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
|
300 |
! |
34262ef77055
comment; look if diff is present and handle the bad case gracious (win32)
Claus Gittinger <cg@exept.de>
parents:
2240
diff
changeset
|
301 |
|
183 | 302 |
initStyle |
303 |
super initStyle. |
|
304 |
||
305 |
showSeparators := false. |
|
306 |
||
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
307 |
(useColors := device hasColors) ifTrue:[ |
2240 | 308 |
addedColor := Color white. |
309 |
addedBgColor := Color red. |
|
183 | 310 |
|
2240 | 311 |
removedColor := Color black. |
312 |
removedBgColor := Color green. |
|
183 | 313 |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
314 |
changedColor := Color white. |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
315 |
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
|
316 |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
317 |
changedSpacesOnlyColor := Color white. |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
318 |
changedSpacesOnlyBgColor := Color blue lightened. |
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
319 |
] ifFalse:[ |
623 | 320 |
showSeparators := true. |
321 |
||
322 |
(useColors := device hasGreyscales) ifTrue:[ |
|
323 |
addedBgColor := removedBgColor := changedBgColor := Color grey:80. |
|
324 |
addedColor := removedColor := changedColor := Color black. |
|
325 |
] ifFalse:[ |
|
326 |
addedBgColor := removedBgColor := changedBgColor := Color black. |
|
327 |
addedColor := removedColor := changedColor := Color white. |
|
328 |
]. |
|
329 |
||
330 |
changedSpacesOnlyColor := Color white. |
|
331 |
changedSpacesOnlyBgColor := Color black. |
|
183 | 332 |
]. |
333 |
||
334 |
"Created: 16.11.1995 / 16:59:48 / cg" |
|
623 | 335 |
"Modified: 14.6.1996 / 16:14:39 / cg" |
183 | 336 |
! ! |
337 |
||
338 |
!DiffTextView methodsFor:'private'! |
|
339 |
||
340 |
updateListsFrom:text1 and:text2 diffs:diffList |
|
341 |
"given the two texts in text1 and text2, and the diff-output in diffList, |
|
342 |
update my views contents" |
|
343 |
||
344 |
|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
|
345 |
textView1 textView2 s1 s2 line1 line2| |
183 | 346 |
|
507 | 347 |
diffLineNumbers := OrderedCollection new. |
348 |
||
183 | 349 |
textView1 := textViews at:1. |
350 |
textView2 := textViews at:2. |
|
351 |
||
352 |
l1 := OrderedCollection new. |
|
353 |
l2 := OrderedCollection new. |
|
354 |
||
355 |
idx1 := 1. |
|
356 |
idx2 := 1. |
|
357 |
||
358 |
dIdx := 1. |
|
359 |
dEnd := diffList size + 1. |
|
360 |
state := #initial. |
|
361 |
[dIdx <= dEnd] whileTrue:[ |
|
362 |
dIdx == dEnd ifTrue:[ |
|
363 |
"dummy cleanup entry" |
|
364 |
entry := nil. |
|
365 |
state := #initial. |
|
366 |
] ifFalse:[ |
|
367 |
entry := diffList at:dIdx. |
|
368 |
]. |
|
369 |
||
370 |
state == #initial ifTrue:[ |
|
371 |
"entry is of the form <nr> <op> <offs> [<offs2>]" |
|
372 |
||
373 |
" |
|
374 |
fill up to size difference from previous change |
|
375 |
" |
|
376 |
delta := l1 size - l2 size. |
|
377 |
delta > 0 ifTrue:[ |
|
378 |
delta timesRepeat:[l2 add:nil] |
|
379 |
] ifFalse:[ |
|
380 |
delta < 0 ifTrue:[ |
|
381 |
delta negated timesRepeat:[l1 add:nil] |
|
382 |
] |
|
383 |
]. |
|
384 |
||
385 |
" |
|
386 |
except for the first chunk, add a separating line |
|
387 |
" |
|
388 |
l1 size ~~ 0 ifTrue:[ |
|
389 |
showSeparators ifTrue:[ |
|
390 |
l1 add:'--------'. |
|
391 |
l2 add:'--------'. |
|
392 |
] |
|
393 |
]. |
|
394 |
" |
|
395 |
in cleanup ? |
|
396 |
" |
|
397 |
entry isNil ifTrue:[ |
|
398 |
nr1 := text1 size + 1. |
|
399 |
nr2 := text2 size + 1. |
|
400 |
state := #finish. |
|
401 |
] ifFalse:[ |
|
507 | 402 |
diffLineNumbers add:l1 size. |
403 |
||
183 | 404 |
s := ReadStream on:entry. |
405 |
nr1 := Integer readFrom:s. |
|
406 |
s peek == $, ifTrue:[ |
|
407 |
s next. |
|
408 |
Integer readFrom:s |
|
409 |
]. |
|
410 |
op := s next. |
|
411 |
nr2 := Integer readFrom:s. |
|
412 |
s peek == $, ifTrue:[ |
|
413 |
s next. |
|
414 |
nr3 := Integer readFrom:s |
|
415 |
] ifFalse:[ |
|
416 |
nr3 := nil |
|
417 |
]. |
|
418 |
||
419 |
op == $c ifTrue:[ |
|
420 |
state := #changed. |
|
421 |
] 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
|
422 |
(op == $a) ifTrue:[ |
183 | 423 |
state := #added. |
424 |
] ifFalse:[ |
|
425 |
op == $d ifTrue:[ |
|
426 |
state := #deleted |
|
427 |
] ifFalse:[ |
|
428 |
self halt:'unexpected diff entry'. |
|
429 |
] |
|
430 |
] |
|
431 |
]. |
|
432 |
||
433 |
]. |
|
434 |
||
435 |
"/ nr1 print. ' ' print. op print. ' ' print. nr2 print. ' , ' print. nr3 printNL. |
|
436 |
||
437 |
" |
|
438 |
copy over unchanged lines |
|
439 |
" |
|
440 |
any := false. |
|
441 |
[idx1 < nr1] whileTrue:[ |
|
442 |
"/ '< add:' print. idx1 printNL. |
|
443 |
l1 add:(text1 at:idx1). |
|
444 |
idx1 := idx1 + 1. |
|
445 |
any := true. |
|
446 |
]. |
|
447 |
[idx2 < nr2] whileTrue:[ |
|
448 |
"/ '> add:' print. idx2 printNL. |
|
449 |
l2 add:(text2 at:idx2). |
|
450 |
idx2 := idx2 + 1. |
|
451 |
any := true. |
|
452 |
]. |
|
453 |
||
454 |
state == #added ifTrue:[ |
|
455 |
l1 add:(text1 at:idx1). |
|
456 |
idx1 := idx1 + 1. |
|
457 |
]. |
|
458 |
state == #deleted ifTrue:[ |
|
459 |
l2 add:(text2 at:idx2). |
|
460 |
idx2 := idx2 + 1. |
|
461 |
]. |
|
462 |
||
463 |
||
464 |
" |
|
465 |
add a separating line, except at end |
|
466 |
" |
|
467 |
any ifTrue:[ |
|
468 |
state ~~ #finish ifTrue:[ |
|
469 |
showSeparators ifTrue:[ |
|
470 |
l1 add:'--------'. |
|
471 |
l2 add:'--------'. |
|
472 |
] |
|
473 |
] |
|
474 |
]. |
|
475 |
||
476 |
] ifFalse:[ |
|
477 |
state == #changed ifTrue:[ |
|
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
478 |
line1 := line2 := nil. |
183 | 479 |
(entry at:1) == $< ifTrue:[ |
480 |
useColors ifTrue:[ |
|
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
481 |
(l2 size >= idx1 |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
482 |
and:[(s2 := line2 := l2 at:idx1) notNil |
2141 | 483 |
and:[(s2 asString withoutSeparators = (text1 at:idx1) withoutSeparators) |
484 |
"/ or:[(s2 asString withoutSeparators withTabsExpanded = (text1 at:idx1) withoutSeparators withTabsExpanded)] |
|
485 |
]]) ifTrue:[ |
|
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
486 |
line1 := Text string:(text1 at:idx1) |
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
487 |
foregroundColor:changedSpacesOnlyColor |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
488 |
backgroundColor:changedSpacesOnlyBgColor. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
489 |
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
|
490 |
foregroundColor:changedSpacesOnlyColor |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
491 |
backgroundColor:changedSpacesOnlyBgColor. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
492 |
|
2262
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
493 |
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
|
494 |
line1 := line1 string. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
495 |
line2 := line2 string. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
496 |
]. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
497 |
|
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
498 |
l1 add:line1. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
499 |
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
|
500 |
] ifFalse:[ |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
501 |
line1 := Text string:(text1 at:idx1) |
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
502 |
foregroundColor:changedColor |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
503 |
backgroundColor:changedBgColor. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
504 |
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
|
505 |
] |
183 | 506 |
] ifFalse:[ |
507 |
l1 add:(text1 at:idx1). |
|
508 |
]. |
|
509 |
idx1 := idx1 + 1 |
|
510 |
] ifFalse:[ |
|
511 |
(entry at:1) == $> ifTrue:[ |
|
512 |
useColors ifTrue:[ |
|
313
c143d37be2e9
lines which differ only in blanks (indent) are shown light-blue
Claus Gittinger <cg@exept.de>
parents:
242
diff
changeset
|
513 |
(l1 size >= idx2 |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
514 |
and:[(s1 := line1 := l1 at:idx2) notNil |
2141 | 515 |
and:[(s1 asString withoutSeparators = (text2 at:idx2) withoutSeparators) |
516 |
"/ or:[(s1 asString withoutSeparators withTabsExpanded = (text2 at:idx2) withoutSeparators withTabsExpanded)] |
|
517 |
]]) ifTrue:[ |
|
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
518 |
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
|
519 |
foregroundColor:changedSpacesOnlyColor |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
520 |
backgroundColor:changedSpacesOnlyBgColor. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
521 |
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
|
522 |
foregroundColor:changedSpacesOnlyColor |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
523 |
backgroundColor:changedSpacesOnlyBgColor. |
2262
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
524 |
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
|
525 |
line1 := line1 string. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
526 |
line2 := line2 string. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
527 |
]. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
528 |
l2 add:line2. |
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
529 |
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
|
530 |
] ifFalse:[ |
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
531 |
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
|
532 |
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
|
533 |
] |
183 | 534 |
] ifFalse:[ |
535 |
l2 add:(text2 at:idx2). |
|
536 |
]. |
|
537 |
idx2 := idx2 + 1 |
|
538 |
] ifFalse:[ |
|
539 |
(entry at:1) == $- ifTrue:[ |
|
540 |
] ifFalse:[ |
|
541 |
state := #initial. |
|
542 |
dIdx := dIdx - 1 |
|
543 |
] |
|
544 |
] |
|
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
545 |
]. |
183 | 546 |
] ifFalse:[ |
547 |
state == #added ifTrue:[ |
|
548 |
(entry at:1) == $> ifTrue:[ |
|
549 |
useColors ifTrue:[ |
|
544
dea45065e7f1
use Text instead of ColoredListEntry
Claus Gittinger <cg@exept.de>
parents:
533
diff
changeset
|
550 |
l2 add:(Text string:(text2 at:idx2) foregroundColor:addedColor backgroundColor:addedBgColor ) |
183 | 551 |
] ifFalse:[ |
552 |
l2 add:(text2 at:idx2). |
|
553 |
]. |
|
554 |
idx2 := idx2 + 1. |
|
555 |
l1 add:nil |
|
556 |
] ifFalse:[ |
|
557 |
state := #initial. |
|
558 |
dIdx := dIdx - 1 |
|
559 |
] |
|
560 |
] ifFalse:[ |
|
561 |
state == #deleted 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 |
l1 add:(Text string:(text1 at:idx1) foregroundColor:removedColor backgroundColor:removedBgColor ). |
183 | 565 |
] ifFalse:[ |
566 |
l1 add:(text1 at:idx1). |
|
567 |
]. |
|
568 |
idx1 := idx1 + 1. |
|
569 |
l2 add:nil |
|
570 |
] ifFalse:[ |
|
571 |
state := #initial. |
|
572 |
dIdx := dIdx - 1 |
|
573 |
] |
|
574 |
] |
|
575 |
"must be in finish otherwise" |
|
576 |
] |
|
577 |
] |
|
578 |
]. |
|
579 |
dIdx := dIdx + 1 |
|
580 |
]. |
|
581 |
[l1 size < l2 size] whileTrue:[ |
|
582 |
l1 add:''. |
|
583 |
]. |
|
584 |
[l2 size < l1 size] whileTrue:[ |
|
585 |
l2 add:''. |
|
586 |
]. |
|
2262
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
587 |
|
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
588 |
"/ 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
|
589 |
1 to:l1 size do:[:idx | |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
590 |
|line1 line2| |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
591 |
|
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
592 |
line1 := l1 at:idx. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
593 |
line2 := l2 at:idx. |
2268 | 594 |
(line1 notNil and:[line1 hasChangeOfEmphasis not]) ifTrue:[ |
595 |
(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
|
596 |
line1 withTabsExpanded withoutTrailingSeparators |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
597 |
~= line2 withTabsExpanded withoutTrailingSeparators |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
598 |
ifTrue:[ |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
599 |
line1 := Text string:line1 |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
600 |
foregroundColor:changedSpacesOnlyColor |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
601 |
backgroundColor:changedSpacesOnlyBgColor. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
602 |
line2 := Text string:line2 |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
603 |
foregroundColor:changedSpacesOnlyColor |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
604 |
backgroundColor:changedSpacesOnlyBgColor. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
605 |
l1 at:idx put:line1. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
606 |
l2 at:idx put:line2. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
607 |
] |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
608 |
] |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
609 |
] |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
610 |
]. |
75d490e87d95
oops - care for diff -b space differences
Claus Gittinger <cg@exept.de>
parents:
2260
diff
changeset
|
611 |
|
183 | 612 |
textView1 list:l1. |
613 |
textView2 list:l2 |
|
614 |
||
2260
2c093fe9ddb1
fix for win32 diff (which does not support -b option)
Claus Gittinger <cg@exept.de>
parents:
2246
diff
changeset
|
615 |
"Modified: / 13.7.1999 / 14:12:11 / cg" |
183 | 616 |
! ! |
617 |
||
242 | 618 |
!DiffTextView class methodsFor:'documentation'! |
619 |
||
620 |
version |
|
3050 | 621 |
^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.33 2001-07-19 14:12:01 penk Exp $' |
2268 | 622 |
! ! |