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:[
|
|
188 |
state := 3. skip := true.
|
|
189 |
] ifFalse:[
|
|
190 |
(entry startsWith:'>>>>>>>') ifTrue:[
|
|
191 |
state := #initial.
|
|
192 |
skip := true.
|
|
193 |
]
|
|
194 |
]
|
|
195 |
]
|
|
196 |
].
|
|
197 |
|
|
198 |
skip ifFalse:[
|
|
199 |
(state == #initial or:[state == 1]) ifTrue:[
|
|
200 |
(useColors and:[state == 1]) ifTrue:[
|
|
201 |
l1 add:(ColoredListEntry string:entry foregroundColor:changedColor backgroundColor:changedBgColor).
|
|
202 |
] ifFalse:[
|
|
203 |
l1 add:entry
|
|
204 |
]
|
|
205 |
].
|
|
206 |
(state == #initial or:[state == 2]) ifTrue:[
|
|
207 |
(useColors and:[state == 2]) ifTrue:[
|
|
208 |
l2 add:(ColoredListEntry string:entry foregroundColor:changedColor backgroundColor:changedBgColor).
|
|
209 |
] ifFalse:[
|
|
210 |
l2 add:entry
|
|
211 |
]
|
|
212 |
].
|
|
213 |
(state == #initial or:[state == 3]) ifTrue:[
|
|
214 |
(useColors and:[state == 3]) ifTrue:[
|
|
215 |
l3 add:(ColoredListEntry string:entry foregroundColor:changedColor backgroundColor:changedBgColor).
|
|
216 |
] ifFalse:[
|
|
217 |
l3 add:entry
|
|
218 |
]
|
|
219 |
].
|
|
220 |
].
|
|
221 |
].
|
|
222 |
].
|
|
223 |
|
|
224 |
textView1 list:l1.
|
|
225 |
textView2 list:l2.
|
|
226 |
textView3 list:l3.
|
|
227 |
|
|
228 |
"Modified: 12.12.1995 / 13:16:08 / cg"
|
|
229 |
! !
|
|
230 |
|
|
231 |
!Diff3TextView class methodsFor:'documentation'!
|
|
232 |
|
|
233 |
version
|
277
|
234 |
^ '$Header: /cvs/stx/stx/libtool/Diff3TextView.st,v 1.2 1995-12-12 13:47:12 cg Exp $'
|
271
|
235 |
! !
|