author | Claus Gittinger <cg@exept.de> |
Thu, 17 Jan 2013 11:35:48 +0100 | |
changeset 12105 | 44e930e29b99 |
parent 11741 | 3b6f1c31139f |
child 12353 | 9d725076871b |
child 12401 | 4714b9640528 |
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 |
|
12105
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
246 |
<resource: #keyboard (#Control_L #Ctrl |
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
247 |
#CursorRight #CursorDown #CursorLeft #CursorUp)> |
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
248 |
|
10631 | 249 |
|ev p| |
250 |
||
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
251 |
(view == textView) ifTrue:[ |
9979 | 252 |
(key == #'Control_L' or:[ key == #Ctrl ]) ifTrue:[ |
10631 | 253 |
"/ because it is delegated, the position is not correct |
254 |
ev := WindowGroup lastEventQuerySignal query. |
|
255 |
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
|
256 |
view sensor pushUserEvent:#highlightElementAtX:y: for: self withArguments:{p x. p y.}. |
10588 | 257 |
^ true. |
9979 | 258 |
]. |
10661 | 259 |
|
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
260 |
"/ codeView reallyModified "textView modified" ifTrue:[ |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
261 |
"/ self highlightClear. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
262 |
"/ codeView syntaxElements: nil. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
263 |
"/ ^ false |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
264 |
"/ ]. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
265 |
(key == #CursorRight |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
266 |
or:[key == #CursorDown |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
267 |
or:[key == #CursorLeft |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
268 |
or:[key == #CursorUp]]]) ifTrue:[ |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
269 |
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
|
270 |
] ifFalse:[ |
10727 | 271 |
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
|
272 |
] |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
273 |
|
9979 | 274 |
]. |
275 |
^ false |
|
276 |
||
277 |
"Created: / 06-03-2010 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10661 | 278 |
"Modified: / 05-09-2011 / 05:17:30 / cg" |
10727 | 279 |
"Modified: / 27-09-2011 / 19:24:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 280 |
! |
281 |
||
282 |
keyRelease: key x:x y:y in: view |
|
283 |
"Handles an event in given view (a subview of codeView). |
|
10588 | 284 |
If the method returns true, it has eaten the event and it will not be processed |
9979 | 285 |
by the view." |
286 |
||
10631 | 287 |
|ev p| |
288 |
||
10588 | 289 |
(view == textView and:[key == #'Control_L' or:[key == #Ctrl]]) ifTrue:[ |
10631 | 290 |
"/ because it is delegated, the position is not correct |
291 |
ev := WindowGroup lastEventQuerySignal query. |
|
292 |
p := view device translatePoint:(ev x @ ev y) fromView:ev view toView:view. |
|
293 |
self highlightClear. |
|
294 |
"/ view sensor pushUserEvent:#highlightClear for:self. |
|
10588 | 295 |
^ true |
296 |
]. |
|
297 |
^ false |
|
9979 | 298 |
|
299 |
"Created: / 06-03-2010 / 21:03:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 300 |
"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
|
301 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
302 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
303 |
linesDeletedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
304 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
305 |
self highlightClear |
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 |
"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
|
308 |
"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
|
309 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
310 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
311 |
linesInsertedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
312 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
313 |
self highlightClear |
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 |
"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
|
316 |
"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
|
317 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
318 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
319 |
linesModifiedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
320 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
321 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
322 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
323 |
"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
|
324 |
"Created: / 16-09-2011 / 15:19:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 325 |
! ! |
326 |
||
327 |
!CodeNavigationService methodsFor:'initialization'! |
|
328 |
||
329 |
initialize |
|
330 |
||
331 |
super initialize. |
|
332 |
selectorEmphasis := self class defaultSelectorEmphasis. |
|
333 |
variableEmphasis := self class defaultVariableEmphasis. |
|
10361 | 334 |
linesToRedraw := OrderedCollection new. |
9979 | 335 |
|
336 |
"Created: / 25-06-2010 / 14:05:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
337 |
! ! |
|
338 |
||
339 |
!CodeNavigationService methodsFor:'private'! |
|
340 |
||
341 |
elementAtCursor |
|
342 |
^self elementAtLine: textView cursorLine col: textView cursorCol - 1 |
|
343 |
||
344 |
"Created: / 25-06-2010 / 14:39:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
345 |
! |
|
346 |
||
10631 | 347 |
elementAtLine:line col:colArg |
11740 | 348 |
|characterPosition syntaxElements index element col| |
10631 | 349 |
|
350 |
"/ if beyond end of line, do not advance into next line |
|
351 |
col := colArg min:(textView listAt:line) size. |
|
9979 | 352 |
|
353 |
characterPosition := textView characterPositionOfLine:line col:col. |
|
11740 | 354 |
syntaxElements := codeView syntaxElements. |
11741 | 355 |
syntaxElements isEmptyOrNil ifTrue:[ |
356 |
^ nil. |
|
357 |
]. |
|
11740 | 358 |
index := syntaxElements indexForInserting:characterPosition. |
359 |
index > syntaxElements size ifTrue:[^nil]. |
|
360 |
element := syntaxElements at:index ifAbsent:nil. |
|
10631 | 361 |
element notNil ifTrue:[ |
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
362 |
(characterPosition between: element start - 1 and: element stop) ifTrue:[^element]. |
10631 | 363 |
]. |
364 |
^nil |
|
9979 | 365 |
|
366 |
"Created: / 25-06-2010 / 14:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 367 |
"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
|
368 |
"Modified: / 16-09-2011 / 17:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 369 |
! |
370 |
||
371 |
elementAtX:x y:y |
|
372 |
|visibleLine line col| |
|
373 |
||
10631 | 374 |
codeView syntaxElements isNil ifTrue:[^nil]. |
375 |
||
9979 | 376 |
visibleLine := textView visibleLineOfY:y. |
377 |
col := textView colOfX:x inVisibleLine:visibleLine. |
|
378 |
line := textView visibleLineToAbsoluteLine:visibleLine. |
|
379 |
^self elementAtLine:line col:col |
|
380 |
||
381 |
"Created: / 25-06-2010 / 14:52:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
382 |
"Modified: / 01-08-2010 / 08:50:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 383 |
"Modified: / 21-08-2011 / 10:26:08 / cg" |
384 |
! |
|
385 |
||
386 |
foo |
|
387 |
|characterPosition index element | |
|
388 |
||
389 |
characterPosition := 1 |
|
390 |
||
391 |
"Created: / 21-08-2011 / 10:48:05 / cg" |
|
9979 | 392 |
! |
393 |
||
394 |
highlighEmphasisFor: element |
|
395 |
||
10878 | 396 |
element isNil ifTrue:[^nil]. |
9979 | 397 |
|
10631 | 398 |
element isSelector ifTrue:[^selectorEmphasis]. |
399 |
element isVariable ifTrue:[^variableEmphasis]. |
|
400 |
element isSelf ifTrue:[^variableEmphasis]. |
|
9979 | 401 |
|
402 |
^nil |
|
403 |
||
404 |
"Created: / 25-06-2010 / 13:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 405 |
"Modified: / 18-11-2011 / 14:58:05 / cg" |
9979 | 406 |
! |
407 |
||
408 |
highlightClear |
|
409 |
||
10361 | 410 |
^self highlightClear: true. |
9979 | 411 |
|
412 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
|
413 |
"Created: / 25-06-2010 / 14:15:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10276 | 414 |
"Modified: / 08-07-2011 / 08:50:45 / cg" |
10361 | 415 |
"Modified: / 20-07-2011 / 18:52:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 416 |
! |
417 |
||
10361 | 418 |
highlightClear: redraw |
419 |
||
420 |
codeView syntaxElementSelection == nil ifTrue:[ ^ self ]. |
|
10878 | 421 |
textView list isNil ifTrue:[ ^ self ]. |
10361 | 422 |
textView list withIndexDo:[:line :lineNo | |
423 |
line isText ifTrue:[ |
|
424 |
(line hasEmphasis: currentEmphasis) ifTrue:[ |
|
425 |
line emphasisAllRemove:currentEmphasis. |
|
426 |
linesToRedraw add: lineNo. |
|
427 |
] |
|
428 |
] |
|
429 |
]. |
|
430 |
codeView syntaxElementSelection:nil. |
|
431 |
||
432 |
redraw ifTrue:[self redrawLines]. |
|
9979 | 433 |
|
10361 | 434 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
435 |
"Created: / 20-07-2011 / 18:52:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 436 |
"Modified: / 18-11-2011 / 14:58:08 / cg" |
10361 | 437 |
! |
438 |
||
439 |
highlightElement:element |
|
10631 | 440 |
|e| |
441 |
||
442 |
codeView syntaxElementSelection == element ifTrue:[ ^ self ]. "/ no change |
|
443 |
codeView syntaxElementSelection notNil ifTrue:[ |
|
444 |
self highlightClear: false. |
|
445 |
]. |
|
10361 | 446 |
|
10631 | 447 |
currentEmphasis := self highlighEmphasisFor:element. |
448 |
element notNil ifTrue:[ |
|
449 |
codeView syntaxElementSelection:element. |
|
450 |
e := element firstElementInChain. |
|
451 |
[ e notNil ] whileTrue:[ |
|
452 |
self highlightWithoutClearFrom:e start to:e stop. |
|
453 |
e := e nextElement |
|
454 |
]. |
|
455 |
]. |
|
10361 | 456 |
self redrawLines. |
9979 | 457 |
|
458 |
"Created: / 14-02-2010 / 16:18:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10361 | 459 |
"Modified: / 20-07-2011 / 18:52:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10631 | 460 |
"Modified: / 21-08-2011 / 10:22:58 / cg" |
9979 | 461 |
! |
462 |
||
463 |
highlightElementAtCursor |
|
464 |
self highlightElementAtLine: textView cursorLine col: textView cursorCol |
|
465 |
||
466 |
"Created: / 14-02-2010 / 16:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
467 |
"Modified: / 06-03-2010 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
468 |
! |
|
469 |
||
470 |
highlightElementAtLine:line col:col |
|
11740 | 471 |
|characterPosition syntaxElements index element| |
9979 | 472 |
|
473 |
characterPosition := textView characterPositionOfLine:line col:col. |
|
11740 | 474 |
syntaxElements := codeView syntaxElements. |
11741 | 475 |
syntaxElements isEmptyOrNil ifTrue:[self highlightElement:nil. ^ self]. |
11740 | 476 |
index := syntaxElements indexForInserting:characterPosition. |
477 |
index > syntaxElements size ifTrue:[self highlightElement:nil. ^ self]. |
|
478 |
element := syntaxElements at:index. |
|
479 |
(characterPosition between: element start and: element stop) ifFalse:[element := nil]. |
|
9979 | 480 |
self highlightElement:element |
481 |
||
482 |
"Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
483 |
"Modified: / 01-08-2010 / 08:50:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
484 |
! |
|
485 |
||
486 |
highlightElementAtX:x y:y |
|
487 |
|visibleLine line col| |
|
488 |
||
10631 | 489 |
codeView syntaxElements isNil ifTrue:[^self]. |
9979 | 490 |
visibleLine := textView visibleLineOfY:y. |
491 |
col := textView colOfX:x inVisibleLine:visibleLine. |
|
492 |
line := textView visibleLineToAbsoluteLine:visibleLine. |
|
493 |
self highlightElementAtLine:line col:col |
|
494 |
||
495 |
"Created: / 14-02-2010 / 16:12:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
496 |
"Modified: / 06-03-2010 / 20:06:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 497 |
"Modified: / 21-08-2011 / 10:22:10 / cg" |
498 |
! |
|
499 |
||
500 |
highlightElementOrNil:e |
|
501 |
e notNil ifTrue:[ |
|
502 |
"/ cg: only if selected !! |
|
503 |
"/ self halt. |
|
504 |
self highlightElement:e. |
|
505 |
] ifFalse:[ |
|
506 |
self highlightClear |
|
507 |
]. |
|
508 |
||
509 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
510 |
"Created: / 21-08-2011 / 09:56:39 / cg" |
|
9979 | 511 |
! |
512 |
||
513 |
highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol |
|
514 |
|line start end| |
|
515 |
||
516 |
(lineNo between:startLine and:endLine) ifFalse:[ |
|
517 |
^ self |
|
518 |
]. |
|
519 |
line := textView listAt:lineNo. |
|
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
520 |
line isEmpty ifTrue:[^self]. |
9979 | 521 |
start := lineNo = startLine ifTrue:[ |
522 |
startCol |
|
523 |
] ifFalse:[ |
|
524 |
line indexOfNonSeparator |
|
525 |
]. |
|
526 |
end := lineNo = endLine ifTrue:[ |
|
527 |
endCol |
|
528 |
] ifFalse:[ line size ]. |
|
529 |
line |
|
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
530 |
emphasisFrom:(start max: 1) |
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
531 |
to:(end min: line size) |
10361 | 532 |
add: currentEmphasis. |
533 |
linesToRedraw add: lineNo. |
|
9979 | 534 |
|
535 |
"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
|
536 |
"Modified: / 08-07-2011 / 13:02:51 / cg" |
10361 | 537 |
"Modified: / 20-07-2011 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 538 |
! |
539 |
||
540 |
highlightVariable:e |
|
10631 | 541 |
(e notNil and:[ e isVariableOrSelf ]) ifTrue:[ |
9979 | 542 |
self highlightElement:e. |
543 |
] ifFalse:[ |
|
544 |
self highlightClear. |
|
10361 | 545 |
]. |
546 |
||
547 |
"Modified: / 20-07-2011 / 18:54:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 548 |
"Modified: / 21-08-2011 / 09:39:42 / cg" |
9979 | 549 |
! |
550 |
||
551 |
highlightVariableAtCursor |
|
10631 | 552 |
self highlightElementOrNil:(self elementAtCursor) |
9979 | 553 |
|
554 |
"Modified: / 25-06-2010 / 14:53:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 555 |
"Modified: / 21-08-2011 / 09:56:56 / cg" |
9979 | 556 |
! |
557 |
||
558 |
highlightVariableAtX:x y:y |
|
10631 | 559 |
self highlightElementOrNil:(self elementAtX:x y:y). |
9979 | 560 |
|
561 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 562 |
"Modified: / 21-08-2011 / 10:24:50 / cg" |
9979 | 563 |
! |
564 |
||
565 |
highlightWithoutClearFrom: start to: end |
|
566 |
"Remove underlined emphasis" |
|
567 |
||
568 |
|startLine startCol endLine endCol| |
|
569 |
||
570 |
startLine := textView lineOfCharacterPosition:start. |
|
571 |
startCol := start - (textView characterPositionOfLine:startLine col:1) + 1. |
|
572 |
endLine := textView lineOfCharacterPosition:end. |
|
573 |
endCol := end - (textView characterPositionOfLine:endLine col:1) + 1. |
|
574 |
self highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
575 |
||
576 |
"Created: / 25-06-2010 / 14:15:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
577 |
! |
|
578 |
||
579 |
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
580 |
||
581 |
textView list keysAndValuesDo: |
|
582 |
[:lineNo :line| |
|
583 |
|start end| |
|
584 |
line isText ifTrue: |
|
585 |
[self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol]]. |
|
586 |
||
587 |
"Created: / 25-06-2010 / 14:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
588 |
! ! |
|
589 |
||
10361 | 590 |
!CodeNavigationService methodsFor:'redrawing'! |
591 |
||
592 |
redrawLines |
|
593 |
linesToRedraw do:[:lineNo| |
|
10588 | 594 |
textView invalidateLine: lineNo. |
10361 | 595 |
]. |
596 |
linesToRedraw := OrderedCollection new: 1 |
|
597 |
||
598 |
"Created: / 20-07-2011 / 18:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10588 | 599 |
"Modified (format): / 18-08-2011 / 16:01:34 / cg" |
10361 | 600 |
! ! |
601 |
||
9979 | 602 |
!CodeNavigationService class methodsFor:'documentation'! |
603 |
||
604 |
version_CVS |
|
12105
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
605 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.19 2013-01-17 10:35:48 cg Exp $' |
9979 | 606 |
! |
607 |
||
608 |
version_SVN |
|
609 |
^ '§Id: Tools__CodeNavigationService.st 7788 2011-06-17 07:57:48Z vranyj1 §' |
|
610 |
! ! |
|
12105
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
611 |