author | Stefan Vogel <sv@exept.de> |
Fri, 10 Aug 2012 20:34:12 +0200 | |
changeset 11740 | fa674978dc41 |
parent 10878 | 3424d00f9155 |
child 11741 | 3b6f1c31139f |
permissions | -rw-r--r-- |
9979 | 1 |
" |
10076 | 2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
3 |
All Rights Reserved |
|
9979 | 4 |
|
10076 | 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. |
|
9979 | 25 |
" |
26 |
"{ Package: 'stx:libtool' }" |
|
27 |
||
28 |
"{ NameSpace: Tools }" |
|
29 |
||
30 |
CodeViewService subclass:#CodeNavigationService |
|
10361 | 31 |
instanceVariableNames:'selectorEmphasis variableEmphasis currentEmphasis linesToRedraw' |
10631 | 32 |
classVariableNames:'DefaultVariableEmphasis DefaultSelectorEmphasis' |
9979 | 33 |
poolDictionaries:'' |
34 |
category:'Interface-CodeView' |
|
35 |
! |
|
36 |
||
37 |
!CodeNavigationService class methodsFor:'documentation'! |
|
38 |
||
39 |
copyright |
|
40 |
" |
|
10076 | 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: |
|
9979 | 52 |
|
10076 | 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. |
|
9979 | 64 |
" |
65 |
! ! |
|
66 |
||
67 |
!CodeNavigationService class methodsFor:'accessing'! |
|
68 |
||
69 |
label |
|
70 |
||
71 |
"Answers short label - for UI" |
|
72 |
||
73 |
^'Semi-modal Code Navigation' |
|
74 |
||
75 |
"Created: / 07-03-2010 / 14:00:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10412 | 76 |
! |
77 |
||
78 |
requiredServices |
|
79 |
||
80 |
^#(#'Tools::CodeHighlightingService') |
|
81 |
||
82 |
"Created: / 27-07-2011 / 11:40:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9979 | 83 |
! ! |
84 |
||
85 |
!CodeNavigationService class methodsFor:'accessing - defaults'! |
|
86 |
||
87 |
defaultSelectorEmphasis |
|
10631 | 88 |
DefaultSelectorEmphasis isNil ifTrue:[ |
89 |
DefaultSelectorEmphasis := |
|
90 |
Array with:(#backgroundColor -> (Color rgbValue:16rDBEEFF)) |
|
91 |
]. |
|
92 |
^ DefaultSelectorEmphasis |
|
93 |
||
94 |
"Modified: / 21-08-2011 / 09:58:18 / cg" |
|
9979 | 95 |
! |
96 |
||
97 |
defaultVariableEmphasis |
|
10631 | 98 |
DefaultVariableEmphasis isNil ifTrue:[ |
99 |
DefaultVariableEmphasis := Array with:(#backgroundColor -> (Color gray: 90)) |
|
100 |
]. |
|
101 |
^ DefaultVariableEmphasis |
|
9979 | 102 |
|
103 |
"Created: / 25-06-2010 / 13:56:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 104 |
"Modified: / 21-08-2011 / 11:04:20 / cg" |
9979 | 105 |
! ! |
106 |
||
10651 | 107 |
!CodeNavigationService methodsFor:'change & update'! |
108 |
||
109 |
update: aspect with: param from: sender |
|
10661 | 110 |
sender == textView modifiedChannel ifTrue:[ |
111 |
codeView reallyModified ifTrue:[ |
|
112 |
"/ no longer highlight - the info is wrong anyway !! |
|
113 |
self highlightClear. |
|
114 |
]. |
|
115 |
]. |
|
116 |
||
10653 | 117 |
"JV: I changed 'halt' to 'breakPoint: #cg'" |
10651 | 118 |
|
119 |
"Created: / 22-08-2011 / 16:22:19 / cg" |
|
10653 | 120 |
"Modified: / 25-08-2011 / 15:10:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10661 | 121 |
"Modified: / 05-09-2011 / 05:15:42 / cg" |
10651 | 122 |
! ! |
123 |
||
9979 | 124 |
!CodeNavigationService methodsFor:'code services'! |
125 |
||
10631 | 126 |
browseClass:class |
127 |
self browser isNil ifTrue:[ ^ NewSystemBrowser browseClass:class ]. |
|
9979 | 128 |
(UserPreferences current alwaysOpenNewTabWhenCtrlClick |
10631 | 129 |
or:[ self browser navigationState modified ]) |
130 |
ifTrue:[ |
|
131 |
self browser |
|
132 |
spawnFullBrowserInClass:class |
|
133 |
selector:nil |
|
134 |
in:#newBuffer |
|
135 |
] |
|
136 |
ifFalse:[ self browser switchToClass:class ] |
|
9979 | 137 |
|
138 |
"Created: / 15-02-2010 / 09:36:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
139 |
"Modified: / 25-07-2010 / 11:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 140 |
"Modified: / 21-08-2011 / 10:07:30 / cg" |
9979 | 141 |
! |
142 |
||
143 |
browser |
|
144 |
||
145 |
^codeView browserHolder value |
|
146 |
||
147 |
"Created: / 06-03-2010 / 21:14:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
148 |
! ! |
|
149 |
||
150 |
!CodeNavigationService methodsFor:'event handling'! |
|
151 |
||
152 |
button1Press |
|
153 |
||
10878 | 154 |
codeView syntaxElementSelection isNil ifTrue:[^self]. |
9979 | 155 |
|
156 |
codeView syntaxElementSelection type == #selector ifTrue:[^self button1PressForSelector: codeView syntaxElementSelection value]. |
|
157 |
codeView syntaxElementSelection type == #class ifTrue:[^self browseClass:codeView syntaxElementSelection value]. |
|
158 |
||
159 |
"Created: / 14-02-2010 / 18:43:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
160 |
"Modified: / 06-03-2010 / 21:11:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 161 |
"Modified: / 18-11-2011 / 14:58:02 / cg" |
9979 | 162 |
! |
163 |
||
164 |
button1PressForSelector: selector |
|
165 |
||
166 |
| impls menu | |
|
10254 | 167 |
impls := codeView implementorsOf: selector. |
10631 | 168 |
"/ impls size = 1 ifTrue:[^codeView browseMethod: impls anyOne]. |
10254 | 169 |
menu := codeView implementorsMenu: impls selector: selector. |
9979 | 170 |
self highlightClear. |
171 |
menu showAtPointer. |
|
172 |
||
173 |
"Created: / 14-02-2010 / 18:50:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10254 | 174 |
"Modified: / 30-06-2011 / 19:34:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10271 | 175 |
"Modified: / 07-07-2011 / 17:16:23 / jv" |
10631 | 176 |
"Modified: / 21-08-2011 / 11:06:08 / cg" |
9979 | 177 |
! |
178 |
||
179 |
button2Press |
|
180 |
||
181 |
| sel | |
|
182 |
sel := codeView syntaxElementSelection. |
|
183 |
(sel notNil and:[sel type == #selector]) ifTrue:[^self button2PressForSelector: sel value]. |
|
184 |
||
185 |
"Created: / 14-02-2010 / 18:43:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
186 |
"Modified: / 17-06-2011 / 08:58:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
187 |
! |
|
188 |
||
189 |
button2PressForSelector: selector |
|
190 |
||
191 |
| senders menu | |
|
10631 | 192 |
senders := codeView sendersOf: selector. |
193 |
"/ senders size = 1 ifTrue:[ codeView browseMethod: senders anyOne. ^ self]. |
|
10254 | 194 |
menu := codeView sendersMenu: senders selector: selector. |
9979 | 195 |
self highlightClear. |
196 |
menu showAtPointer. |
|
197 |
||
198 |
"Created: / 14-02-2010 / 18:50:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10254 | 199 |
"Modified: / 30-06-2011 / 19:34:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10631 | 200 |
"Modified: / 21-08-2011 / 11:34:49 / cg" |
9979 | 201 |
! |
202 |
||
10631 | 203 |
buttonMotion:button x:x y:y in:view |
9979 | 204 |
"Handles an event in given view (a subview of codeView). |
205 |
If the method returns true, the event will not be processed |
|
206 |
by the view." |
|
10631 | 207 |
|
208 |
(view == textView and:[ textView sensor ctrlDown ]) ifTrue:[ |
|
209 |
self highlightElementAtX:x y:y. |
|
210 |
^ true |
|
211 |
]. |
|
212 |
^ false |
|
9979 | 213 |
|
214 |
"Created: / 06-03-2010 / 20:40:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 215 |
"Modified (format): / 21-08-2011 / 10:07:15 / cg" |
9979 | 216 |
! |
217 |
||
218 |
buttonPress: button x:x y:y in: view |
|
219 |
||
220 |
"Handles an event in given view (a subview of codeView). |
|
221 |
If the method returns true, the event will not be processed |
|
222 |
by the view." |
|
223 |
||
10631 | 224 |
(view == textView) ifTrue:[ |
225 |
codeView sensor ctrlDown ifTrue:[ |
|
226 |
button == 1 ifTrue: [self button1Press.^true]. |
|
9979 | 227 |
button == #paste ifTrue: [self button2Press.^true]. |
10631 | 228 |
button == 2 ifTrue: [self button2Press.^true] |
229 |
]. |
|
9979 | 230 |
button == 1 ifTrue:[ |
231 |
self highlightVariableAtX:x y:y. |
|
232 |
] |
|
10631 | 233 |
]. |
9979 | 234 |
^false |
235 |
||
236 |
"Created: / 06-03-2010 / 21:12:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
237 |
"Modified: / 25-06-2010 / 14:53:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 238 |
"Modified (format): / 21-08-2011 / 10:06:54 / cg" |
9979 | 239 |
! |
240 |
||
241 |
keyPress:key x:x y:y in:view |
|
242 |
"Handles an event in given view (a subview of codeView). |
|
10588 | 243 |
If the method returns true, it has eaten the event and it will not be processed |
9979 | 244 |
by the view." |
10588 | 245 |
|
10631 | 246 |
|ev p| |
247 |
||
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
248 |
(view == textView) ifTrue:[ |
9979 | 249 |
(key == #'Control_L' or:[ key == #Ctrl ]) ifTrue:[ |
10631 | 250 |
"/ because it is delegated, the position is not correct |
251 |
ev := WindowGroup lastEventQuerySignal query. |
|
252 |
p := view device translatePoint:(ev x @ ev y) fromView:ev view toView:view. |
|
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
253 |
view sensor pushUserEvent:#highlightElementAtX:y: for: self withArguments:{p x. p y.}. |
10588 | 254 |
^ true. |
9979 | 255 |
]. |
10661 | 256 |
|
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
257 |
"/ codeView reallyModified "textView modified" ifTrue:[ |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
258 |
"/ self highlightClear. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
259 |
"/ codeView syntaxElements: nil. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
260 |
"/ ^ false |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
261 |
"/ ]. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
262 |
(key == #CursorRight |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
263 |
or:[key == #CursorDown |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
264 |
or:[key == #CursorLeft |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
265 |
or:[key == #CursorUp]]]) ifTrue:[ |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
266 |
view sensor pushUserEvent:#highlightVariableAtCursor for:self . |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
267 |
] ifFalse:[ |
10727 | 268 |
view sensor pushUserEvent:#highlightClear for:self . |
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
269 |
] |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
270 |
|
9979 | 271 |
]. |
272 |
^ false |
|
273 |
||
274 |
"Created: / 06-03-2010 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10661 | 275 |
"Modified: / 05-09-2011 / 05:17:30 / cg" |
10727 | 276 |
"Modified: / 27-09-2011 / 19:24:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 277 |
! |
278 |
||
279 |
keyRelease: key x:x y:y in: view |
|
280 |
"Handles an event in given view (a subview of codeView). |
|
10588 | 281 |
If the method returns true, it has eaten the event and it will not be processed |
9979 | 282 |
by the view." |
283 |
||
10631 | 284 |
|ev p| |
285 |
||
10588 | 286 |
(view == textView and:[key == #'Control_L' or:[key == #Ctrl]]) ifTrue:[ |
10631 | 287 |
"/ because it is delegated, the position is not correct |
288 |
ev := WindowGroup lastEventQuerySignal query. |
|
289 |
p := view device translatePoint:(ev x @ ev y) fromView:ev view toView:view. |
|
290 |
self highlightClear. |
|
291 |
"/ view sensor pushUserEvent:#highlightClear for:self. |
|
10588 | 292 |
^ true |
293 |
]. |
|
294 |
^ false |
|
9979 | 295 |
|
296 |
"Created: / 06-03-2010 / 21:03:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 297 |
"Modified: / 21-08-2011 / 11:32:40 / cg" |
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
298 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
299 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
300 |
linesDeletedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
301 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
302 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
303 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
304 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
305 |
"Created: / 16-09-2011 / 15:39:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
306 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
307 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
308 |
linesInsertedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
309 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
310 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
311 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
312 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
313 |
"Created: / 16-09-2011 / 15:39:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
314 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
315 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
316 |
linesModifiedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
317 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
318 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
319 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
320 |
"Created: / 06-07-2011 / 17:14:36 / jv" |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
321 |
"Created: / 16-09-2011 / 15:19:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 322 |
! ! |
323 |
||
324 |
!CodeNavigationService methodsFor:'initialization'! |
|
325 |
||
326 |
initialize |
|
327 |
||
328 |
super initialize. |
|
329 |
selectorEmphasis := self class defaultSelectorEmphasis. |
|
330 |
variableEmphasis := self class defaultVariableEmphasis. |
|
10361 | 331 |
linesToRedraw := OrderedCollection new. |
9979 | 332 |
|
333 |
"Created: / 25-06-2010 / 14:05:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
334 |
! ! |
|
335 |
||
336 |
!CodeNavigationService methodsFor:'private'! |
|
337 |
||
338 |
elementAtCursor |
|
339 |
^self elementAtLine: textView cursorLine col: textView cursorCol - 1 |
|
340 |
||
341 |
"Created: / 25-06-2010 / 14:39:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
342 |
! |
|
343 |
||
10631 | 344 |
elementAtLine:line col:colArg |
11740 | 345 |
|characterPosition syntaxElements index element col| |
10631 | 346 |
|
347 |
"/ if beyond end of line, do not advance into next line |
|
348 |
col := colArg min:(textView listAt:line) size. |
|
9979 | 349 |
|
350 |
characterPosition := textView characterPositionOfLine:line col:col. |
|
11740 | 351 |
syntaxElements := codeView syntaxElements. |
352 |
index := syntaxElements indexForInserting:characterPosition. |
|
353 |
index > syntaxElements size ifTrue:[^nil]. |
|
354 |
element := syntaxElements at:index ifAbsent:nil. |
|
10631 | 355 |
element notNil ifTrue:[ |
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
356 |
(characterPosition between: element start - 1 and: element stop) ifTrue:[^element]. |
10631 | 357 |
]. |
358 |
^nil |
|
9979 | 359 |
|
360 |
"Created: / 25-06-2010 / 14:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 361 |
"Modified: / 21-08-2011 / 11:03:29 / cg" |
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
362 |
"Modified: / 16-09-2011 / 17:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 363 |
! |
364 |
||
365 |
elementAtX:x y:y |
|
366 |
|visibleLine line col| |
|
367 |
||
10631 | 368 |
codeView syntaxElements isNil ifTrue:[^nil]. |
369 |
||
9979 | 370 |
visibleLine := textView visibleLineOfY:y. |
371 |
col := textView colOfX:x inVisibleLine:visibleLine. |
|
372 |
line := textView visibleLineToAbsoluteLine:visibleLine. |
|
373 |
^self elementAtLine:line col:col |
|
374 |
||
375 |
"Created: / 25-06-2010 / 14:52:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
376 |
"Modified: / 01-08-2010 / 08:50:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 377 |
"Modified: / 21-08-2011 / 10:26:08 / cg" |
378 |
! |
|
379 |
||
380 |
foo |
|
381 |
|characterPosition index element | |
|
382 |
||
383 |
characterPosition := 1 |
|
384 |
||
385 |
"Created: / 21-08-2011 / 10:48:05 / cg" |
|
9979 | 386 |
! |
387 |
||
388 |
highlighEmphasisFor: element |
|
389 |
||
10878 | 390 |
element isNil ifTrue:[^nil]. |
9979 | 391 |
|
10631 | 392 |
element isSelector ifTrue:[^selectorEmphasis]. |
393 |
element isVariable ifTrue:[^variableEmphasis]. |
|
394 |
element isSelf ifTrue:[^variableEmphasis]. |
|
9979 | 395 |
|
396 |
^nil |
|
397 |
||
398 |
"Created: / 25-06-2010 / 13:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 399 |
"Modified: / 18-11-2011 / 14:58:05 / cg" |
9979 | 400 |
! |
401 |
||
402 |
highlightClear |
|
403 |
||
10361 | 404 |
^self highlightClear: true. |
9979 | 405 |
|
406 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
|
407 |
"Created: / 25-06-2010 / 14:15:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10276 | 408 |
"Modified: / 08-07-2011 / 08:50:45 / cg" |
10361 | 409 |
"Modified: / 20-07-2011 / 18:52:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 410 |
! |
411 |
||
10361 | 412 |
highlightClear: redraw |
413 |
||
414 |
codeView syntaxElementSelection == nil ifTrue:[ ^ self ]. |
|
10878 | 415 |
textView list isNil ifTrue:[ ^ self ]. |
10361 | 416 |
textView list withIndexDo:[:line :lineNo | |
417 |
line isText ifTrue:[ |
|
418 |
(line hasEmphasis: currentEmphasis) ifTrue:[ |
|
419 |
line emphasisAllRemove:currentEmphasis. |
|
420 |
linesToRedraw add: lineNo. |
|
421 |
] |
|
422 |
] |
|
423 |
]. |
|
424 |
codeView syntaxElementSelection:nil. |
|
425 |
||
426 |
redraw ifTrue:[self redrawLines]. |
|
9979 | 427 |
|
10361 | 428 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
429 |
"Created: / 20-07-2011 / 18:52:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 430 |
"Modified: / 18-11-2011 / 14:58:08 / cg" |
10361 | 431 |
! |
432 |
||
433 |
highlightElement:element |
|
10631 | 434 |
|e| |
435 |
||
436 |
codeView syntaxElementSelection == element ifTrue:[ ^ self ]. "/ no change |
|
437 |
codeView syntaxElementSelection notNil ifTrue:[ |
|
438 |
self highlightClear: false. |
|
439 |
]. |
|
10361 | 440 |
|
10631 | 441 |
currentEmphasis := self highlighEmphasisFor:element. |
442 |
element notNil ifTrue:[ |
|
443 |
codeView syntaxElementSelection:element. |
|
444 |
e := element firstElementInChain. |
|
445 |
[ e notNil ] whileTrue:[ |
|
446 |
self highlightWithoutClearFrom:e start to:e stop. |
|
447 |
e := e nextElement |
|
448 |
]. |
|
449 |
]. |
|
10361 | 450 |
self redrawLines. |
9979 | 451 |
|
452 |
"Created: / 14-02-2010 / 16:18:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10361 | 453 |
"Modified: / 20-07-2011 / 18:52:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10631 | 454 |
"Modified: / 21-08-2011 / 10:22:58 / cg" |
9979 | 455 |
! |
456 |
||
457 |
highlightElementAtCursor |
|
458 |
self highlightElementAtLine: textView cursorLine col: textView cursorCol |
|
459 |
||
460 |
"Created: / 14-02-2010 / 16:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
461 |
"Modified: / 06-03-2010 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
462 |
! |
|
463 |
||
464 |
highlightElementAtLine:line col:col |
|
11740 | 465 |
|characterPosition syntaxElements index element| |
9979 | 466 |
|
467 |
characterPosition := textView characterPositionOfLine:line col:col. |
|
11740 | 468 |
syntaxElements := codeView syntaxElements. |
469 |
index := syntaxElements indexForInserting:characterPosition. |
|
470 |
index > syntaxElements size ifTrue:[self highlightElement:nil. ^ self]. |
|
471 |
element := syntaxElements at:index. |
|
472 |
(characterPosition between: element start and: element stop) ifFalse:[element := nil]. |
|
9979 | 473 |
self highlightElement:element |
474 |
||
475 |
"Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
476 |
"Modified: / 01-08-2010 / 08:50:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
477 |
! |
|
478 |
||
479 |
highlightElementAtX:x y:y |
|
480 |
|visibleLine line col| |
|
481 |
||
10631 | 482 |
codeView syntaxElements isNil ifTrue:[^self]. |
9979 | 483 |
visibleLine := textView visibleLineOfY:y. |
484 |
col := textView colOfX:x inVisibleLine:visibleLine. |
|
485 |
line := textView visibleLineToAbsoluteLine:visibleLine. |
|
486 |
self highlightElementAtLine:line col:col |
|
487 |
||
488 |
"Created: / 14-02-2010 / 16:12:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
489 |
"Modified: / 06-03-2010 / 20:06:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 490 |
"Modified: / 21-08-2011 / 10:22:10 / cg" |
491 |
! |
|
492 |
||
493 |
highlightElementOrNil:e |
|
494 |
e notNil ifTrue:[ |
|
495 |
"/ cg: only if selected !! |
|
496 |
"/ self halt. |
|
497 |
self highlightElement:e. |
|
498 |
] ifFalse:[ |
|
499 |
self highlightClear |
|
500 |
]. |
|
501 |
||
502 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
503 |
"Created: / 21-08-2011 / 09:56:39 / cg" |
|
9979 | 504 |
! |
505 |
||
506 |
highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol |
|
507 |
|line start end| |
|
508 |
||
509 |
(lineNo between:startLine and:endLine) ifFalse:[ |
|
510 |
^ self |
|
511 |
]. |
|
512 |
line := textView listAt:lineNo. |
|
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
513 |
line isEmpty ifTrue:[^self]. |
9979 | 514 |
start := lineNo = startLine ifTrue:[ |
515 |
startCol |
|
516 |
] ifFalse:[ |
|
517 |
line indexOfNonSeparator |
|
518 |
]. |
|
519 |
end := lineNo = endLine ifTrue:[ |
|
520 |
endCol |
|
521 |
] ifFalse:[ line size ]. |
|
522 |
line |
|
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
523 |
emphasisFrom:(start max: 1) |
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
524 |
to:(end min: line size) |
10361 | 525 |
add: currentEmphasis. |
526 |
linesToRedraw add: lineNo. |
|
9979 | 527 |
|
528 |
"Created: / 25-06-2010 / 14:15:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
529 |
"Modified: / 08-07-2011 / 13:02:51 / cg" |
10361 | 530 |
"Modified: / 20-07-2011 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 531 |
! |
532 |
||
533 |
highlightVariable:e |
|
10631 | 534 |
(e notNil and:[ e isVariableOrSelf ]) ifTrue:[ |
9979 | 535 |
self highlightElement:e. |
536 |
] ifFalse:[ |
|
537 |
self highlightClear. |
|
10361 | 538 |
]. |
539 |
||
540 |
"Modified: / 20-07-2011 / 18:54:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 541 |
"Modified: / 21-08-2011 / 09:39:42 / cg" |
9979 | 542 |
! |
543 |
||
544 |
highlightVariableAtCursor |
|
10631 | 545 |
self highlightElementOrNil:(self elementAtCursor) |
9979 | 546 |
|
547 |
"Modified: / 25-06-2010 / 14:53:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 548 |
"Modified: / 21-08-2011 / 09:56:56 / cg" |
9979 | 549 |
! |
550 |
||
551 |
highlightVariableAtX:x y:y |
|
10631 | 552 |
self highlightElementOrNil:(self elementAtX:x y:y). |
9979 | 553 |
|
554 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 555 |
"Modified: / 21-08-2011 / 10:24:50 / cg" |
9979 | 556 |
! |
557 |
||
558 |
highlightWithoutClearFrom: start to: end |
|
559 |
"Remove underlined emphasis" |
|
560 |
||
561 |
|startLine startCol endLine endCol| |
|
562 |
||
563 |
startLine := textView lineOfCharacterPosition:start. |
|
564 |
startCol := start - (textView characterPositionOfLine:startLine col:1) + 1. |
|
565 |
endLine := textView lineOfCharacterPosition:end. |
|
566 |
endCol := end - (textView characterPositionOfLine:endLine col:1) + 1. |
|
567 |
self highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
568 |
||
569 |
"Created: / 25-06-2010 / 14:15:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
570 |
! |
|
571 |
||
572 |
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
573 |
||
574 |
textView list keysAndValuesDo: |
|
575 |
[:lineNo :line| |
|
576 |
|start end| |
|
577 |
line isText ifTrue: |
|
578 |
[self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol]]. |
|
579 |
||
580 |
"Created: / 25-06-2010 / 14:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
581 |
! ! |
|
582 |
||
10361 | 583 |
!CodeNavigationService methodsFor:'redrawing'! |
584 |
||
585 |
redrawLines |
|
586 |
linesToRedraw do:[:lineNo| |
|
10588 | 587 |
textView invalidateLine: lineNo. |
10361 | 588 |
]. |
589 |
linesToRedraw := OrderedCollection new: 1 |
|
590 |
||
591 |
"Created: / 20-07-2011 / 18:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10588 | 592 |
"Modified (format): / 18-08-2011 / 16:01:34 / cg" |
10361 | 593 |
! ! |
594 |
||
9979 | 595 |
!CodeNavigationService class methodsFor:'documentation'! |
596 |
||
597 |
version_CVS |
|
11740 | 598 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.17 2012-08-10 18:34:12 stefan Exp $' |
9979 | 599 |
! |
600 |
||
601 |
version_SVN |
|
602 |
^ '§Id: Tools__CodeNavigationService.st 7788 2011-06-17 07:57:48Z vranyj1 §' |
|
603 |
! ! |