author | Claus Gittinger <cg@exept.de> |
Wed, 13 Dec 1995 20:03:36 +0100 | |
changeset 290 | 5b9361cfa7b8 |
parent 277 | b4b2782bc733 |
child 713 | bbed5ec2fbeb |
permissions | -rw-r--r-- |
271 | 1 |
" |
277 | 2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
3 |
All Rights Reserved |
|
271 | 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 |
||
13 |
ThreeColumnTextView subclass:#Diff3TextView |
|
14 |
instanceVariableNames:'useColors showSeparators addedColor addedBgColor removedColor |
|
15 |
removedBgColor changedColor changedBgColor' |
|
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Views-Text' |
|
19 |
! |
|
20 |
||
21 |
!Diff3TextView class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
277 | 25 |
COPYRIGHT (c) 1995 by Claus Gittinger |
26 |
All Rights Reserved |
|
271 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
277 | 39 |
a view showing merged diff3 (see rcsmerge / merge unix manual pages) output in a |
271 | 40 |
user-friendly form. |
41 |
The view is created and opened with: |
|
42 |
||
277 | 43 |
d := Diff3TextView openOn:text label:l1 label:l2 label:l3. |
271 | 44 |
|
277 | 45 |
and it will show the 3 versions side-by-side |
46 |
Its main use is for the SourceCodeManager, to show merged sources after |
|
47 |
a failed checkin. |
|
271 | 48 |
" |
49 |
! ! |
|
50 |
||
51 |
!Diff3TextView class methodsFor:'instance creation'! |
|
52 |
||
53 |
openOnMergedText:text label:firstLabel label:secondLabel label:thirdLabel |
|
54 |
"open up a view showing firstText, secondText and thirdText side-by-side, |
|
55 |
and labels for all views." |
|
56 |
||
57 |
|top v l1 l2 l3| |
|
58 |
||
59 |
top := StandardSystemView label:'three texts'. |
|
60 |
||
61 |
l1 := Label label:firstLabel in:top. |
|
62 |
l1 origin:0.0@0.0 corner:0.33@(l1 height). |
|
63 |
l2 := Label label:secondLabel in:top. |
|
64 |
l2 origin:0.33@0.0 corner:0.67@(l1 height). |
|
65 |
l3 := Label label:thirdLabel in:top. |
|
66 |
l3 origin:0.67@0.0 corner:1.0@(l1 height). |
|
67 |
||
68 |
v := HVScrollableView |
|
69 |
for:self |
|
70 |
miniScrollerH:true miniScrollerV:false |
|
71 |
in:top. |
|
72 |
v origin:0.0 @ (l1 height + ViewSpacing) corner:1.0 @ 1.0. |
|
73 |
v scrolledView updateListsFromMergedText:text. |
|
74 |
^ top open |
|
75 |
||
76 |
" |
|
77 |
ThreeColumnTextView |
|
78 |
openOn:('smalltalk.rc' asFilename contentsOfEntireFile) |
|
79 |
label:'smalltalk.rc' |
|
80 |
and:('display.rc' asFilename contentsOfEntireFile) |
|
81 |
label:'display.rc' |
|
82 |
and:('private.rc' asFilename contentsOfEntireFile) |
|
83 |
label:'private.rc' |
|
84 |
" |
|
85 |
||
86 |
"Modified: 12.12.1995 / 13:09:13 / cg" |
|
87 |
! ! |
|
88 |
||
89 |
!Diff3TextView methodsFor:'initialization'! |
|
90 |
||
91 |
initStyle |
|
92 |
super initStyle. |
|
93 |
||
94 |
showSeparators := false. |
|
95 |
||
96 |
useColors := ColoredListEntry notNil. |
|
97 |
useColors ifTrue:[ |
|
98 |
device hasColors ifTrue:[ |
|
99 |
addedColor := Color black. |
|
100 |
addedBgColor := Color green. |
|
101 |
||
102 |
removedColor := Color white. |
|
103 |
removedBgColor := Color red. |
|
104 |
||
105 |
changedColor := Color white. |
|
106 |
changedBgColor := Color blue. |
|
107 |
] ifFalse:[ |
|
108 |
addedBgColor := removedBgColor := changedBgColor := Color black. |
|
109 |
addedColor := removedColor := changedColor := Color white. |
|
110 |
] |
|
111 |
]. |
|
112 |
||
113 |
"Created: 16.11.1995 / 16:59:48 / cg" |
|
114 |
"Modified: 12.12.1995 / 12:25:55 / cg" |
|
115 |
! ! |
|
116 |
||
117 |
!Diff3TextView methodsFor:'private'! |
|
118 |
||
119 |
updateListsFromMergedText:mergedText |
|
120 |
"given the merge()/rcsmerge() merged output (as created by 'cvs update'), |
|
121 |
update my views contents" |
|
122 |
||
123 |
|idx1 idx2 idx3 dIdx dEnd state s nr1 nr2 nr3 entry c l1 l2 l3 |
|
124 |
textView1 textView2 textView3 skip max| |
|
125 |
||
126 |
textView1 := textViews at:1. |
|
127 |
textView2 := textViews at:2. |
|
128 |
textView3 := textViews at:3. |
|
129 |
||
130 |
l1 := OrderedCollection new. |
|
131 |
l2 := OrderedCollection new. |
|
132 |
l3 := OrderedCollection new. |
|
133 |
||
134 |
idx1 := 1. |
|
135 |
idx2 := 1. |
|
136 |
idx3 := 1. |
|
137 |
||
138 |
dIdx := 1. |
|
139 |
dEnd := mergedText size + 1. |
|
140 |
state := #initial. |
|
141 |
[dIdx < dEnd] whileTrue:[ |
|
142 |
dIdx == dEnd ifTrue:[ |
|
143 |
"dummy cleanup entry" |
|
144 |
entry := nil. |
|
145 |
state := #initial. |
|
146 |
] ifFalse:[ |
|
147 |
entry := mergedText at:dIdx. |
|
148 |
dIdx := dIdx + 1. |
|
149 |
]. |
|
150 |
||
151 |
state == #initial ifTrue:[ |
|
152 |
" |
|
153 |
fill up to size difference from previous change |
|
154 |
" |
|
155 |
max := (l1 size max:l2 size) max:l3 size. |
|
156 |
[l1 size < max] whileTrue:[ |
|
157 |
l1 add:nil |
|
158 |
]. |
|
159 |
[l2 size < max] whileTrue:[ |
|
160 |
l2 add:nil |
|
161 |
]. |
|
162 |
[l3 size < max] whileTrue:[ |
|
163 |
l3 add:nil |
|
164 |
]. |
|
165 |
||
166 |
" |
|
167 |
except for the first chunk, add a separating line |
|
168 |
" |
|
169 |
l1 size ~~ 0 ifTrue:[ |
|
170 |
showSeparators ifTrue:[ |
|
171 |
l1 add:'--------'. |
|
172 |
l2 add:'--------'. |
|
173 |
l3 add:'--------'. |
|
174 |
] |
|
175 |
]. |
|
176 |
]. |
|
177 |
||
178 |
skip := false. |
|
179 |
||
180 |
entry notNil ifTrue:[ |
|
181 |
(entry startsWith:'<<<<<<<') ifTrue:[ |
|
182 |
state := 1. skip := true. |
|
183 |
] ifFalse:[ |
|
184 |
(entry startsWith:'|||||||') ifTrue:[ |
|
185 |
state := 2. skip := true. |
|
186 |
] ifFalse:[ |
|
187 |
(entry startsWith:'=======') ifTrue:[ |
|
290
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
188 |
state == 2 ifFalse:[ |
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
189 |
state := 23 "/ on both 2 and 3 |
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
190 |
] ifTrue:[ |
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
191 |
state := 3 "/ only in 3 |
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
192 |
]. |
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
193 |
skip := true. |
271 | 194 |
] ifFalse:[ |
195 |
(entry startsWith:'>>>>>>>') ifTrue:[ |
|
196 |
state := #initial. |
|
197 |
skip := true. |
|
198 |
] |
|
199 |
] |
|
200 |
] |
|
201 |
]. |
|
202 |
||
203 |
skip ifFalse:[ |
|
204 |
(state == #initial or:[state == 1]) ifTrue:[ |
|
205 |
(useColors and:[state == 1]) ifTrue:[ |
|
206 |
l1 add:(ColoredListEntry string:entry foregroundColor:changedColor backgroundColor:changedBgColor). |
|
207 |
] ifFalse:[ |
|
208 |
l1 add:entry |
|
209 |
] |
|
210 |
]. |
|
290
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
211 |
(state == #initial or:[state == 2 or:[state == 23]]) ifTrue:[ |
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
212 |
(useColors and:[state == 2 or:[state == 23]]) ifTrue:[ |
271 | 213 |
l2 add:(ColoredListEntry string:entry foregroundColor:changedColor backgroundColor:changedBgColor). |
214 |
] ifFalse:[ |
|
215 |
l2 add:entry |
|
216 |
] |
|
217 |
]. |
|
290
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
218 |
(state == #initial or:[state == 3 or:[state == 23]]) ifTrue:[ |
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
219 |
(useColors and:[state == 3 or:[state == 23]]) ifTrue:[ |
271 | 220 |
l3 add:(ColoredListEntry string:entry foregroundColor:changedColor backgroundColor:changedBgColor). |
221 |
] ifFalse:[ |
|
222 |
l3 add:entry |
|
223 |
] |
|
224 |
]. |
|
225 |
]. |
|
226 |
]. |
|
227 |
]. |
|
228 |
||
229 |
textView1 list:l1. |
|
230 |
textView2 list:l2. |
|
231 |
textView3 list:l3. |
|
232 |
||
290
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
233 |
"Modified: 13.12.1995 / 19:56:32 / cg" |
271 | 234 |
! ! |
235 |
||
236 |
!Diff3TextView class methodsFor:'documentation'! |
|
237 |
||
238 |
version |
|
290
5b9361cfa7b8
oops - merge output is different than expected sometimes
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
239 |
^ '$Header: /cvs/stx/stx/libtool/Diff3TextView.st,v 1.3 1995-12-13 19:03:36 cg Exp $' |
271 | 240 |
! ! |