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:
|
|
80 |
[:cls|cls isAbstract not and:[cls isAvailable]].
|
|
81 |
|
|
82 |
"
|
|
83 |
Tools::CodeViewService availableServices
|
|
84 |
"
|
|
85 |
|
|
86 |
"Created: / 07-03-2010 / 13:42:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
87 |
"Modified: / 03-04-2011 / 23:07:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
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>"
|
|
97 |
! !
|
|
98 |
|
|
99 |
!CodeViewService class methodsFor:'registering'!
|
|
100 |
|
|
101 |
registerIn: aCodeView
|
|
102 |
|
|
103 |
^self new
|
|
104 |
registerIn: aCodeView;
|
|
105 |
yourself.
|
|
106 |
|
|
107 |
"Created: / 07-03-2010 / 13:50:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
108 |
! !
|
|
109 |
|
|
110 |
!CodeViewService class methodsFor:'testing'!
|
|
111 |
|
|
112 |
isAbstract
|
|
113 |
|
|
114 |
^self == Tools::CodeViewService
|
|
115 |
|
|
116 |
"Created: / 07-03-2010 / 13:41:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
117 |
!
|
|
118 |
|
|
119 |
isAvailable
|
|
120 |
|
|
121 |
^true
|
|
122 |
|
|
123 |
"Created: / 03-04-2011 / 23:07:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
124 |
! !
|
|
125 |
|
|
126 |
!CodeViewService methodsFor:'accessing'!
|
|
127 |
|
|
128 |
enabled
|
|
129 |
^ enabled
|
|
130 |
!
|
|
131 |
|
|
132 |
enabled:aBoolean
|
|
133 |
enabled := aBoolean.
|
|
134 |
!
|
|
135 |
|
|
136 |
label
|
|
137 |
|
|
138 |
^self class label
|
|
139 |
|
|
140 |
"Created: / 07-03-2010 / 14:03:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
141 |
! !
|
|
142 |
|
|
143 |
!CodeViewService methodsFor:'change & update'!
|
|
144 |
|
|
145 |
update: aspect with: param from: sender
|
|
146 |
|
|
147 |
"Get updated whenever something changes in the code view.
|
|
148 |
Subclasses may override this"
|
|
149 |
|
|
150 |
"Intentionally left blank here"
|
|
151 |
|
|
152 |
"Created: / 06-03-2010 / 19:23:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
153 |
! !
|
|
154 |
|
|
155 |
!CodeViewService methodsFor:'event handling'!
|
|
156 |
|
|
157 |
buttonMotion: button x:x y:y in: view
|
|
158 |
|
|
159 |
"Handles an event in given view (a subview of codeView).
|
|
160 |
If the method returns true, the event will not be processed
|
|
161 |
by the view."
|
|
162 |
|
|
163 |
^false
|
|
164 |
|
|
165 |
"Created: / 06-03-2010 / 20:17:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
166 |
"Modified: / 17-06-2011 / 13:05:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
167 |
!
|
|
168 |
|
|
169 |
buttonPress: button x:x y:y in: view
|
|
170 |
|
|
171 |
"Handles an event in given view (a subview of codeView).
|
|
172 |
If the method returns true, the event will not be processed
|
|
173 |
by the view."
|
|
174 |
|
|
175 |
^false
|
|
176 |
|
|
177 |
"Created: / 06-03-2010 / 20:36:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
178 |
"Modified: / 17-06-2011 / 13:06:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
179 |
!
|
|
180 |
|
|
181 |
keyPress:key x:x y:y in: view
|
|
182 |
|
|
183 |
"Handles an event in given view (a subview of codeView).
|
|
184 |
If the method returns true, the event will not be processed
|
|
185 |
by the view."
|
|
186 |
|
|
187 |
^false
|
|
188 |
|
|
189 |
"Created: / 06-03-2010 / 20:34:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
190 |
"Modified: / 17-06-2011 / 13:06:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
191 |
!
|
|
192 |
|
|
193 |
keyRelease: key x: x y: y in: view
|
|
194 |
|
|
195 |
"Handles an event in given view (a subview of codeView).
|
|
196 |
If the method returns true, the event will not be processed
|
|
197 |
by the view."
|
|
198 |
|
|
199 |
^false
|
|
200 |
|
|
201 |
"Created: / 06-03-2010 / 20:35:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
202 |
"Modified: / 17-06-2011 / 13:06:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
203 |
! !
|
|
204 |
|
|
205 |
!CodeViewService methodsFor:'initialization'!
|
|
206 |
|
|
207 |
initialize
|
|
208 |
"Invoked when a new instance is created."
|
|
209 |
|
|
210 |
|
|
211 |
"/ please change as required (and remove this comment)
|
|
212 |
"/ enabled := nil.
|
|
213 |
"/ codeView := nil.
|
|
214 |
"/ textView := nil.
|
|
215 |
|
|
216 |
super initialize.
|
|
217 |
|
|
218 |
"Modified: / 03-09-2010 / 22:29:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
219 |
! !
|
|
220 |
|
|
221 |
!CodeViewService methodsFor:'redrawing'!
|
|
222 |
|
|
223 |
drawLine:lineNo in: view atX:x y:y width: w height:h from:startCol to:endColOrNil with:fg and:bg
|
|
224 |
|
|
225 |
"Called by both gutterView and textView (well, not yet) to
|
|
226 |
allow services to draw custom things on text view.
|
|
227 |
Ask JV what the args means if unsure (I'm lazy to document
|
|
228 |
them, now it is just an experiment...)"
|
|
229 |
|
|
230 |
"Intentionally left blank, to be overriden by subclasses"
|
|
231 |
|
|
232 |
"Created: / 17-06-2011 / 13:49:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
233 |
! !
|
|
234 |
|
|
235 |
!CodeViewService methodsFor:'registering'!
|
|
236 |
|
|
237 |
registerIn: aCodeView
|
|
238 |
|
|
239 |
"Installs myself in aCodeView"
|
|
240 |
|
|
241 |
codeView := aCodeView.
|
|
242 |
codeView addDependent: self.
|
|
243 |
textView := aCodeView textView.
|
|
244 |
gutterView := aCodeView gutterView.
|
|
245 |
enabled := true.
|
|
246 |
|
|
247 |
"Created: / 06-03-2010 / 19:21:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
248 |
"Modified: / 17-06-2011 / 13:07:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
249 |
!
|
|
250 |
|
|
251 |
unregister
|
|
252 |
|
|
253 |
"Uninstall myself from my codeView"
|
|
254 |
|
|
255 |
codeView removeDependent: self.
|
|
256 |
codeView := nil.
|
|
257 |
textView := nil.
|
|
258 |
|
|
259 |
"Created: / 06-03-2010 / 19:21:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
260 |
"Modified: / 17-06-2011 / 12:57:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
261 |
! !
|
|
262 |
|
|
263 |
!CodeViewService methodsFor:'testing'!
|
|
264 |
|
|
265 |
isEnabled
|
|
266 |
|
|
267 |
^enabled == true
|
|
268 |
|
|
269 |
"Created: / 07-03-2010 / 13:47:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
270 |
! !
|
|
271 |
|
|
272 |
!CodeViewService class methodsFor:'documentation'!
|
|
273 |
|
|
274 |
version_CVS
|
10070
|
275 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeViewService.st,v 1.2 2011-07-03 17:50:03 cg Exp $'
|
9983
|
276 |
!
|
|
277 |
|
|
278 |
version_SVN
|
|
279 |
^ '§Id: Tools__CodeViewService.st 7790 2011-06-17 13:33:22Z vranyj1 §'
|
|
280 |
! !
|