9983
|
1 |
"
|
10070
|
2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
|
|
3 |
All Rights Reserved
|
9983
|
4 |
|
10070
|
5 |
Permission is hereby granted, free of charge, to any person
|
|
6 |
obtaining a copy of this software and associated documentation
|
|
7 |
files (the 'Software'), to deal in the Software without
|
|
8 |
restriction, including without limitation the rights to use,
|
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10 |
copies of the Software, and to permit persons to whom the
|
|
11 |
Software is furnished to do so, subject to the following
|
|
12 |
conditions:
|
|
13 |
|
|
14 |
The above copyright notice and this permission notice shall be
|
|
15 |
included in all copies or substantial portions of the Software.
|
|
16 |
|
|
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24 |
OTHER DEALINGS IN THE SOFTWARE.
|
9983
|
25 |
"
|
|
26 |
"{ Package: 'stx:libtool' }"
|
|
27 |
|
|
28 |
"{ NameSpace: Tools }"
|
|
29 |
|
|
30 |
Object subclass:#CodeViewService
|
|
31 |
instanceVariableNames:'enabled codeView textView gutterView'
|
|
32 |
classVariableNames:''
|
|
33 |
poolDictionaries:''
|
|
34 |
category:'Interface-CodeView'
|
|
35 |
!
|
|
36 |
|
|
37 |
!CodeViewService class methodsFor:'documentation'!
|
|
38 |
|
|
39 |
copyright
|
|
40 |
"
|
10070
|
41 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
|
|
42 |
All Rights Reserved
|
|
43 |
|
|
44 |
Permission is hereby granted, free of charge, to any person
|
|
45 |
obtaining a copy of this software and associated documentation
|
|
46 |
files (the 'Software'), to deal in the Software without
|
|
47 |
restriction, including without limitation the rights to use,
|
|
48 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
49 |
copies of the Software, and to permit persons to whom the
|
|
50 |
Software is furnished to do so, subject to the following
|
|
51 |
conditions:
|
9983
|
52 |
|
10070
|
53 |
The above copyright notice and this permission notice shall be
|
|
54 |
included in all copies or substantial portions of the Software.
|
|
55 |
|
|
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
59 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
60 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
61 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
62 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
63 |
OTHER DEALINGS IN THE SOFTWARE.
|
9983
|
64 |
"
|
|
65 |
! !
|
|
66 |
|
|
67 |
!CodeViewService class methodsFor:'instance creation'!
|
|
68 |
|
|
69 |
new
|
|
70 |
"return an initialized instance"
|
|
71 |
|
|
72 |
^ self basicNew initialize.
|
|
73 |
! !
|
|
74 |
|
|
75 |
!CodeViewService class methodsFor:'accessing'!
|
|
76 |
|
|
77 |
availableServices
|
|
78 |
|
|
79 |
^self allSubclasses select:
|
10414
|
80 |
[:cls|cls isAbstract not and:[cls allRequiredServicesAvailable and:[cls isAvailable]]].
|
9983
|
81 |
|
|
82 |
"
|
|
83 |
Tools::CodeViewService availableServices
|
|
84 |
"
|
|
85 |
|
|
86 |
"Created: / 07-03-2010 / 13:42:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10414
|
87 |
"Modified: / 27-07-2011 / 11:49:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
9983
|
88 |
!
|
|
89 |
|
|
90 |
label
|
|
91 |
|
|
92 |
"Answers short label - for UI"
|
|
93 |
|
|
94 |
^self class name
|
|
95 |
|
|
96 |
"Created: / 07-03-2010 / 13:58:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10414
|
97 |
!
|
|
98 |
|
|
99 |
requiredServices
|
|
100 |
|
|
101 |
"Returns a list of services required for myself to work
|
|
102 |
correctly. A list should contain class names of the services
|
|
103 |
(as not all services may be loaded in)"
|
|
104 |
|
|
105 |
^#()
|
|
106 |
|
|
107 |
"Created: / 27-07-2011 / 11:39:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
108 |
! !
|
|
109 |
|
|
110 |
!CodeViewService class methodsFor:'queries'!
|
|
111 |
|
|
112 |
allRequiredServicesAvailable
|
|
113 |
|
|
114 |
| cls |
|
|
115 |
|
|
116 |
^self requiredServices allSatisfy:[:clsName|
|
|
117 |
cls := Smalltalk at: clsName.
|
|
118 |
cls notNil and:[cls allRequiredServicesAvailable and:[cls isAvailable]]
|
|
119 |
].
|
|
120 |
|
|
121 |
"Created: / 27-07-2011 / 11:49:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
9983
|
122 |
! !
|
|
123 |
|
|
124 |
!CodeViewService class methodsFor:'registering'!
|
|
125 |
|
|
126 |
registerIn: aCodeView
|
|
127 |
|
|
128 |
^self new
|
|
129 |
registerIn: aCodeView;
|
|
130 |
yourself.
|
|
131 |
|
|
132 |
"Created: / 07-03-2010 / 13:50:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
133 |
! !
|
|
134 |
|
|
135 |
!CodeViewService class methodsFor:'testing'!
|
|
136 |
|
|
137 |
isAbstract
|
|
138 |
|
|
139 |
^self == Tools::CodeViewService
|
|
140 |
|
|
141 |
"Created: / 07-03-2010 / 13:41:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
142 |
!
|
|
143 |
|
|
144 |
isAvailable
|
|
145 |
|
|
146 |
^true
|
|
147 |
|
|
148 |
"Created: / 03-04-2011 / 23:07:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10414
|
149 |
!
|
|
150 |
|
|
151 |
isAvailableFor: applicationClass
|
|
152 |
|
|
153 |
"Returns true if given service may be used in
|
|
154 |
given application class."
|
|
155 |
|
|
156 |
^true
|
|
157 |
|
|
158 |
"Created: / 27-07-2011 / 11:45:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
9983
|
159 |
! !
|
|
160 |
|
|
161 |
!CodeViewService methodsFor:'accessing'!
|
|
162 |
|
10414
|
163 |
application
|
|
164 |
|
|
165 |
^codeView application
|
|
166 |
|
|
167 |
"Created: / 27-07-2011 / 12:11:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
168 |
!
|
|
169 |
|
9983
|
170 |
enabled
|
|
171 |
^ enabled
|
|
172 |
!
|
|
173 |
|
|
174 |
enabled:aBoolean
|
|
175 |
enabled := aBoolean.
|
|
176 |
!
|
|
177 |
|
|
178 |
label
|
|
179 |
|
|
180 |
^self class label
|
|
181 |
|
|
182 |
"Created: / 07-03-2010 / 14:03:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10498
|
183 |
!
|
|
184 |
|
|
185 |
service: serviceClassName
|
|
186 |
|
|
187 |
^codeView services detect:[:service|service class name == serviceClassName] ifNone:[nil]
|
|
188 |
|
|
189 |
"Created: / 05-08-2011 / 11:48:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
190 |
!
|
|
191 |
|
|
192 |
syntaxHighlighter
|
|
193 |
|
|
194 |
"Returns a syntax highligter class or nil. The highlighting
|
|
195 |
process gather all syntaxHighlighterClasses from all services
|
|
196 |
and then use them one by one to highlight the text. Individual
|
|
197 |
services may override this method to provide additional
|
|
198 |
highliging of the source code"
|
|
199 |
|
|
200 |
^nil
|
|
201 |
|
|
202 |
"Created: / 05-08-2011 / 10:49:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
9983
|
203 |
! !
|
|
204 |
|
|
205 |
!CodeViewService methodsFor:'change & update'!
|
|
206 |
|
|
207 |
update: aspect with: param from: sender
|
|
208 |
|
|
209 |
"Get updated whenever something changes in the code view.
|
|
210 |
Subclasses may override this"
|
|
211 |
|
|
212 |
"Intentionally left blank here"
|
|
213 |
|
|
214 |
"Created: / 06-03-2010 / 19:23:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
215 |
! !
|
|
216 |
|
|
217 |
!CodeViewService methodsFor:'event handling'!
|
|
218 |
|
|
219 |
buttonMotion: button x:x y:y in: view
|
|
220 |
|
|
221 |
"Handles an event in given view (a subview of codeView).
|
10589
|
222 |
If the method returns true, it has eaten the event and it will not be processed
|
9983
|
223 |
by the view."
|
|
224 |
|
|
225 |
^false
|
|
226 |
|
|
227 |
"Created: / 06-03-2010 / 20:17:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
228 |
"Modified: / 17-06-2011 / 13:05:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10589
|
229 |
"Modified (comment): / 18-08-2011 / 15:57:40 / cg"
|
9983
|
230 |
!
|
|
231 |
|
|
232 |
buttonPress: button x:x y:y in: view
|
|
233 |
|
|
234 |
"Handles an event in given view (a subview of codeView).
|
10589
|
235 |
If the method returns true, it has eaten the event and it will not be processed
|
9983
|
236 |
by the view."
|
|
237 |
|
|
238 |
^false
|
|
239 |
|
|
240 |
"Created: / 06-03-2010 / 20:36:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
241 |
"Modified: / 17-06-2011 / 13:06:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10589
|
242 |
"Modified (comment): / 18-08-2011 / 15:57:36 / cg"
|
9983
|
243 |
!
|
|
244 |
|
|
245 |
keyPress:key x:x y:y in: view
|
|
246 |
|
|
247 |
"Handles an event in given view (a subview of codeView).
|
10589
|
248 |
If the method returns true, it has eaten the event and it will not be processed
|
9983
|
249 |
by the view."
|
|
250 |
|
|
251 |
^false
|
|
252 |
|
|
253 |
"Created: / 06-03-2010 / 20:34:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
254 |
"Modified: / 17-06-2011 / 13:06:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10589
|
255 |
"Modified (comment): / 18-08-2011 / 15:57:28 / cg"
|
9983
|
256 |
!
|
|
257 |
|
|
258 |
keyRelease: key x: x y: y in: view
|
|
259 |
|
|
260 |
"Handles an event in given view (a subview of codeView).
|
10589
|
261 |
If the method returns true, it has eaten the event and it will not be processed
|
9983
|
262 |
by the view."
|
|
263 |
|
|
264 |
^false
|
|
265 |
|
|
266 |
"Created: / 06-03-2010 / 20:35:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
267 |
"Modified: / 17-06-2011 / 13:06:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
10589
|
268 |
"Modified (comment): / 18-08-2011 / 15:57:33 / cg"
|
10227
|
269 |
!
|
|
270 |
|
|
271 |
linesDeletedFrom: start to: end
|
|
272 |
|
|
273 |
"Created: / 06-07-2011 / 17:14:23 / jv"
|
|
274 |
!
|
|
275 |
|
|
276 |
linesInsertedFrom: start to: end
|
|
277 |
|
|
278 |
"Created: / 06-07-2011 / 17:14:31 / jv"
|
|
279 |
!
|
|
280 |
|
|
281 |
linesModifiedFrom: start to: end
|
|
282 |
|
|
283 |
"Created: / 06-07-2011 / 17:14:36 / jv"
|
9983
|
284 |
! !
|
|
285 |
|
|
286 |
!CodeViewService methodsFor:'initialization'!
|
|
287 |
|
|
288 |
initialize
|
|
289 |
"Invoked when a new instance is created."
|
|
290 |
|
|
291 |
|
|
292 |
"/ please change as required (and remove this comment)
|
|
293 |
"/ enabled := nil.
|
|
294 |
"/ codeView := nil.
|
|
295 |
"/ textView := nil.
|
|
296 |
|
|
297 |
super initialize.
|
|
298 |
|
|
299 |
"Modified: / 03-09-2010 / 22:29:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
300 |
! !
|
|
301 |
|
11172
|
302 |
!CodeViewService methodsFor:'misc'!
|
|
303 |
|
|
304 |
showInfo: aString
|
|
305 |
|
|
306 |
codeView showInfo: aString
|
|
307 |
|
|
308 |
"Created: / 06-03-2010 / 19:34:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
309 |
"Created: / 21-01-2012 / 12:44:22 / cg"
|
|
310 |
! !
|
|
311 |
|
9983
|
312 |
!CodeViewService methodsFor:'redrawing'!
|
|
313 |
|
|
314 |
drawLine:lineNo in: view atX:x y:y width: w height:h from:startCol to:endColOrNil with:fg and:bg
|
|
315 |
|
|
316 |
"Called by both gutterView and textView (well, not yet) to
|
|
317 |
allow services to draw custom things on text view.
|
|
318 |
Ask JV what the args means if unsure (I'm lazy to document
|
|
319 |
them, now it is just an experiment...)"
|
|
320 |
|
|
321 |
"Intentionally left blank, to be overriden by subclasses"
|
|
322 |
|
|
323 |
"Created: / 17-06-2011 / 13:49:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
324 |
! !
|
|
325 |
|
|
326 |
!CodeViewService methodsFor:'registering'!
|
|
327 |
|
|
328 |
registerIn: aCodeView
|
|
329 |
|
|
330 |
"Installs myself in aCodeView"
|
|
331 |
|
|
332 |
codeView := aCodeView.
|
|
333 |
codeView addDependent: self.
|
|
334 |
textView := aCodeView textView.
|
|
335 |
gutterView := aCodeView gutterView.
|
|
336 |
enabled := true.
|
|
337 |
|
|
338 |
"Created: / 06-03-2010 / 19:21:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
339 |
"Modified: / 17-06-2011 / 13:07:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
340 |
!
|
|
341 |
|
|
342 |
unregister
|
|
343 |
|
|
344 |
"Uninstall myself from my codeView"
|
|
345 |
|
|
346 |
codeView removeDependent: self.
|
|
347 |
codeView := nil.
|
|
348 |
textView := nil.
|
|
349 |
|
|
350 |
"Created: / 06-03-2010 / 19:21:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
351 |
"Modified: / 17-06-2011 / 12:57:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
352 |
! !
|
|
353 |
|
|
354 |
!CodeViewService methodsFor:'testing'!
|
|
355 |
|
|
356 |
isEnabled
|
|
357 |
|
|
358 |
^enabled == true
|
|
359 |
|
|
360 |
"Created: / 07-03-2010 / 13:47:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
361 |
! !
|
|
362 |
|
|
363 |
!CodeViewService class methodsFor:'documentation'!
|
|
364 |
|
|
365 |
version_CVS
|
11172
|
366 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeViewService.st,v 1.7 2012-01-22 10:11:39 cg Exp $'
|
9983
|
367 |
!
|
|
368 |
|
|
369 |
version_SVN
|
|
370 |
^ '§Id: Tools__CodeViewService.st 7790 2011-06-17 13:33:22Z vranyj1 §'
|
|
371 |
! !
|