author | Claus Gittinger <cg@exept.de> |
Tue, 14 Mar 2017 20:30:21 +0100 | |
changeset 17465 | 27a2e4012a0a |
parent 17040 | 84e03a037118 |
child 17136 | cb908d2ba02e |
child 18327 | e2046aa4fdfd |
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 |
|
13533
827c4bb6abbe
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13463
diff
changeset
|
31 |
instanceVariableNames:'lastHighlightedElement selectorEmphasis variableEmphasis |
827c4bb6abbe
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13463
diff
changeset
|
32 |
currentEmphasis currentEmphasisForAssign linesToRedraw menuShown |
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
33 |
assignmentEmphasis' |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
34 |
classVariableNames:'DefaultVariableEmphasis DefaultSelectorEmphasis |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
35 |
DefaultAssignmentEmphasis' |
9979 | 36 |
poolDictionaries:'' |
37 |
category:'Interface-CodeView' |
|
38 |
! |
|
39 |
||
40 |
!CodeNavigationService class methodsFor:'documentation'! |
|
41 |
||
42 |
copyright |
|
43 |
" |
|
10076 | 44 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
45 |
All Rights Reserved |
|
46 |
||
47 |
Permission is hereby granted, free of charge, to any person |
|
48 |
obtaining a copy of this software and associated documentation |
|
49 |
files (the 'Software'), to deal in the Software without |
|
50 |
restriction, including without limitation the rights to use, |
|
51 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
52 |
copies of the Software, and to permit persons to whom the |
|
53 |
Software is furnished to do so, subject to the following |
|
54 |
conditions: |
|
9979 | 55 |
|
10076 | 56 |
The above copyright notice and this permission notice shall be |
57 |
included in all copies or substantial portions of the Software. |
|
58 |
||
59 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
60 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
61 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
62 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
63 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
64 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
65 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
66 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9979 | 67 |
" |
68 |
! ! |
|
69 |
||
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
70 |
|
9979 | 71 |
!CodeNavigationService class methodsFor:'accessing'! |
72 |
||
73 |
label |
|
13103 | 74 |
"Answers a short label - for UI" |
9979 | 75 |
|
76 |
^'Semi-modal Code Navigation' |
|
77 |
||
78 |
"Created: / 07-03-2010 / 14:00:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10412 | 79 |
! |
80 |
||
81 |
requiredServices |
|
82 |
||
83 |
^#(#'Tools::CodeHighlightingService') |
|
84 |
||
85 |
"Created: / 27-07-2011 / 11:40:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9979 | 86 |
! ! |
87 |
||
88 |
!CodeNavigationService class methodsFor:'accessing - defaults'! |
|
89 |
||
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
90 |
defaultAssignmentEmphasis |
13109 | 91 |
"must only define a background - otherwise, syntax highlight fg is lost" |
92 |
||
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
93 |
DefaultAssignmentEmphasis isNil ifTrue:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
94 |
^ Array with:(#backgroundColor -> (UserPreferences current assignmentBackgroundColorForNavigationService)) |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
95 |
]. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
96 |
^ DefaultAssignmentEmphasis |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
97 |
! |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
98 |
|
9979 | 99 |
defaultSelectorEmphasis |
13109 | 100 |
"must only define a background - otherwise, syntax highlight fg is lost" |
101 |
||
10631 | 102 |
DefaultSelectorEmphasis isNil ifTrue:[ |
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
103 |
^ Array with:(#backgroundColor -> (UserPreferences current selectorBackgroundColorForNavigationService)) |
10631 | 104 |
]. |
105 |
^ DefaultSelectorEmphasis |
|
106 |
||
107 |
"Modified: / 21-08-2011 / 09:58:18 / cg" |
|
9979 | 108 |
! |
109 |
||
110 |
defaultVariableEmphasis |
|
13109 | 111 |
"must only define a background - otherwise, syntax highlight fg is lost" |
112 |
||
10631 | 113 |
DefaultVariableEmphasis isNil ifTrue:[ |
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
114 |
^ Array with:(#backgroundColor -> (UserPreferences current variableBackgroundColorForNavigationService)) |
10631 | 115 |
]. |
116 |
^ DefaultVariableEmphasis |
|
9979 | 117 |
|
118 |
"Created: / 25-06-2010 / 13:56:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 119 |
"Modified: / 21-08-2011 / 11:04:20 / cg" |
9979 | 120 |
! ! |
121 |
||
13203 | 122 |
!CodeNavigationService class methodsFor:'testing'! |
123 |
||
124 |
isUsefulFor:aCodeView |
|
125 |
"this filters useful services. |
|
126 |
Redefined to return true for myself - not for subclasses" |
|
127 |
||
128 |
^ self == Tools::CodeNavigationService |
|
129 |
||
130 |
"Created: / 22-07-2013 / 13:59:20 / cg" |
|
131 |
! ! |
|
132 |
||
10651 | 133 |
!CodeNavigationService methodsFor:'change & update'! |
134 |
||
135 |
update: aspect with: param from: sender |
|
10661 | 136 |
sender == textView modifiedChannel ifTrue:[ |
137 |
codeView reallyModified ifTrue:[ |
|
138 |
"/ no longer highlight - the info is wrong anyway !! |
|
139 |
self highlightClear. |
|
140 |
]. |
|
141 |
]. |
|
142 |
||
10653 | 143 |
"JV: I changed 'halt' to 'breakPoint: #cg'" |
10651 | 144 |
|
145 |
"Created: / 22-08-2011 / 16:22:19 / cg" |
|
10653 | 146 |
"Modified: / 25-08-2011 / 15:10:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10661 | 147 |
"Modified: / 05-09-2011 / 05:15:42 / cg" |
10651 | 148 |
! ! |
149 |
||
9979 | 150 |
!CodeNavigationService methodsFor:'code services'! |
151 |
||
10631 | 152 |
browseClass:class |
153 |
self browser isNil ifTrue:[ ^ NewSystemBrowser browseClass:class ]. |
|
9979 | 154 |
(UserPreferences current alwaysOpenNewTabWhenCtrlClick |
10631 | 155 |
or:[ self browser navigationState modified ]) |
156 |
ifTrue:[ |
|
157 |
self browser |
|
158 |
spawnFullBrowserInClass:class |
|
159 |
selector:nil |
|
160 |
in:#newBuffer |
|
161 |
] |
|
162 |
ifFalse:[ self browser switchToClass:class ] |
|
9979 | 163 |
|
164 |
"Created: / 15-02-2010 / 09:36:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
165 |
"Modified: / 25-07-2010 / 11:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 166 |
"Modified: / 21-08-2011 / 10:07:30 / cg" |
9979 | 167 |
! |
168 |
||
169 |
browser |
|
170 |
||
171 |
^codeView browserHolder value |
|
172 |
||
173 |
"Created: / 06-03-2010 / 21:14:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
174 |
! ! |
|
175 |
||
176 |
!CodeNavigationService methodsFor:'event handling'! |
|
177 |
||
178 |
button1Press |
|
13866 | 179 |
| node | |
9979 | 180 |
|
13866 | 181 |
node := codeView currentParseNode. |
182 |
node isNil ifTrue:[ |
|
183 |
^ self |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
184 |
]. |
13866 | 185 |
node isSelector ifTrue:[ |
186 |
self button1PressForMessageNode: node. |
|
187 |
^self. |
|
188 |
]. |
|
189 |
node isVariable ifTrue:[ |
|
190 |
self button1PressForVariableNode: node. |
|
191 |
^self. |
|
192 |
]. |
|
193 |
||
194 |
^self. |
|
9979 | 195 |
|
196 |
"Created: / 14-02-2010 / 18:43:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13866 | 197 |
"Modified: / 18-11-2011 / 14:58:02 / cg" |
198 |
"Modified: / 21-02-2012 / 14:30:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
199 |
! |
|
200 |
||
201 |
button1PressForMessageNode: node |
|
202 |
||
14058
6018db6ddc02
Fixes in CodeNavigationService - semi-modal navigation should work again.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14004
diff
changeset
|
203 |
^self button1PressForSelector: node selector. |
13866 | 204 |
|
205 |
"Created: / 21-02-2012 / 14:30:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14058
6018db6ddc02
Fixes in CodeNavigationService - semi-modal navigation should work again.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14004
diff
changeset
|
206 |
"Modified: / 25-02-2014 / 22:11:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 207 |
! |
208 |
||
209 |
button1PressForSelector: selector |
|
12867 | 210 |
| impls | |
9979 | 211 |
|
10254 | 212 |
impls := codeView implementorsOf: selector. |
10631 | 213 |
"/ impls size = 1 ifTrue:[^codeView browseMethod: impls anyOne]. |
12867 | 214 |
[ |
215 |
menuShown := codeView implementorsMenu: impls selector: selector. |
|
13405
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
216 |
"/ cg: why is this done? |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
217 |
"/ self highlightClear. |
12867 | 218 |
menuShown showAtPointer. |
219 |
] ensure:[ |
|
220 |
menuShown := nil |
|
221 |
]. |
|
9979 | 222 |
|
223 |
"Created: / 14-02-2010 / 18:50:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10254 | 224 |
"Modified: / 30-06-2011 / 19:34:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10271 | 225 |
"Modified: / 07-07-2011 / 17:16:23 / jv" |
13405
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
226 |
"Modified (comment): / 29-08-2013 / 16:27:58 / cg" |
9979 | 227 |
! |
228 |
||
13866 | 229 |
button1PressForVariableNode: node |
14128
9be54971efa0
FIxed semi-model navigation for classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14058
diff
changeset
|
230 |
| name value | |
9979 | 231 |
|
13866 | 232 |
node isGlobalVariable ifTrue:[ |
14128
9be54971efa0
FIxed semi-model navigation for classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14058
diff
changeset
|
233 |
value := nil. |
9be54971efa0
FIxed semi-model navigation for classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14058
diff
changeset
|
234 |
name := node name asSymbolIfInterned. |
9be54971efa0
FIxed semi-model navigation for classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14058
diff
changeset
|
235 |
name notNil ifTrue:[ |
9be54971efa0
FIxed semi-model navigation for classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14058
diff
changeset
|
236 |
value := Smalltalk at: name. |
9be54971efa0
FIxed semi-model navigation for classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14058
diff
changeset
|
237 |
]. |
13866 | 238 |
value notNil ifTrue:[ |
239 |
value isBehavior ifTrue:[ |
|
240 |
self browseClass: value. |
|
241 |
] ifFalse:[ |
|
242 |
value inspect. |
|
243 |
] |
|
244 |
] |
|
245 |
] |
|
246 |
||
247 |
"Created: / 21-02-2012 / 14:30:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14128
9be54971efa0
FIxed semi-model navigation for classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14058
diff
changeset
|
248 |
"Modified: / 07-03-2014 / 22:17:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13866 | 249 |
! |
250 |
||
251 |
button2Press |
|
252 |
||
14448
e1cfd3e4826b
fixed ALT-right click (senders of selector under cursor)
az
parents:
14204
diff
changeset
|
253 |
| sel node| |
e1cfd3e4826b
fixed ALT-right click (senders of selector under cursor)
az
parents:
14204
diff
changeset
|
254 |
|
13866 | 255 |
sel := codeView syntaxElementSelection. |
14448
e1cfd3e4826b
fixed ALT-right click (senders of selector under cursor)
az
parents:
14204
diff
changeset
|
256 |
(sel notNil |
e1cfd3e4826b
fixed ALT-right click (senders of selector under cursor)
az
parents:
14204
diff
changeset
|
257 |
and:[(node := sel node) isMessage |
e1cfd3e4826b
fixed ALT-right click (senders of selector under cursor)
az
parents:
14204
diff
changeset
|
258 |
or:[node isSelector]] |
e1cfd3e4826b
fixed ALT-right click (senders of selector under cursor)
az
parents:
14204
diff
changeset
|
259 |
) ifTrue:[ |
e1cfd3e4826b
fixed ALT-right click (senders of selector under cursor)
az
parents:
14204
diff
changeset
|
260 |
^self button2PressForSelector: node selector |
e1cfd3e4826b
fixed ALT-right click (senders of selector under cursor)
az
parents:
14204
diff
changeset
|
261 |
]. |
9979 | 262 |
|
263 |
"Created: / 14-02-2010 / 18:43:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13866 | 264 |
"Modified: / 08-03-2012 / 16:49:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
14448
e1cfd3e4826b
fixed ALT-right click (senders of selector under cursor)
az
parents:
14204
diff
changeset
|
265 |
"Modified (format): / 04-06-2014 / 11:09:33 / az" |
9979 | 266 |
! |
267 |
||
268 |
button2PressForSelector: selector |
|
12867 | 269 |
| senders | |
9979 | 270 |
|
13422
86835045a828
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13405
diff
changeset
|
271 |
[ |
86835045a828
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13405
diff
changeset
|
272 |
senders := codeView sendersOf: selector. |
86835045a828
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13405
diff
changeset
|
273 |
] valueWithTimeout:(500 milliseconds). |
86835045a828
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13405
diff
changeset
|
274 |
senders isNil ifTrue:[^ self]. |
86835045a828
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13405
diff
changeset
|
275 |
|
10631 | 276 |
"/ senders size = 1 ifTrue:[ codeView browseMethod: senders anyOne. ^ self]. |
12867 | 277 |
[ |
278 |
menuShown := codeView sendersMenu: senders selector: selector. |
|
13405
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
279 |
"/ cg: why is this done? |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
280 |
"/ self highlightClear. |
12867 | 281 |
menuShown showAtPointer. |
282 |
] ensure:[ |
|
283 |
menuShown := nil. |
|
284 |
]. |
|
9979 | 285 |
|
286 |
"Created: / 14-02-2010 / 18:50:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10254 | 287 |
"Modified: / 30-06-2011 / 19:34:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13405
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
288 |
"Modified: / 28-08-2013 / 21:59:26 / cg" |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
289 |
"Modified (comment): / 29-08-2013 / 16:28:03 / cg" |
9979 | 290 |
! |
291 |
||
10631 | 292 |
buttonMotion:button x:x y:y in:view |
9979 | 293 |
"Handles an event in given view (a subview of codeView). |
294 |
If the method returns true, the event will not be processed |
|
295 |
by the view." |
|
10631 | 296 |
|
14004
ee41e156d189
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
13946
diff
changeset
|
297 |
(view == textView and:[ textView isQuickMenuModifierPressed ]) ifTrue:[ |
10631 | 298 |
self highlightElementAtX:x y:y. |
299 |
^ true |
|
300 |
]. |
|
301 |
^ false |
|
9979 | 302 |
|
303 |
"Created: / 06-03-2010 / 20:40:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 304 |
"Modified (format): / 21-08-2011 / 10:07:15 / cg" |
9979 | 305 |
! |
306 |
||
307 |
buttonPress: button x:x y:y in: view |
|
308 |
"Handles an event in given view (a subview of codeView). |
|
309 |
If the method returns true, the event will not be processed |
|
310 |
by the view." |
|
311 |
||
10631 | 312 |
(view == textView) ifTrue:[ |
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
313 |
textView isQuickMenuModifierPressed ifTrue:[ |
13699
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
314 |
button == 1 ifTrue: [ |
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
315 |
codeView sensor shiftDown ifTrue:[ |
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
316 |
^self button2Press |
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
317 |
]. |
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
318 |
^self button1Press |
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
319 |
]. |
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
320 |
button == #paste ifTrue: [^self button2Press]. |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
321 |
button == 2 ifTrue: [^self button2Press] |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
322 |
] ifFalse:[ |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
323 |
button == 1 ifTrue:[ |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
324 |
self highlightVariableAtX:x y:y. |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
325 |
] |
9979 | 326 |
] |
10631 | 327 |
]. |
9979 | 328 |
^false |
329 |
||
330 |
"Created: / 06-03-2010 / 21:12:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
331 |
"Modified: / 25-06-2010 / 14:53:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13699
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
332 |
"Modified: / 01-12-2013 / 23:42:02 / cg" |
9979 | 333 |
! |
334 |
||
12867 | 335 |
buttonRelease: button x:x y:y in: view |
336 |
"Handles an event in given view (a subview of codeView). |
|
337 |
If the method returns true, the event will not be processed |
|
338 |
by the view." |
|
339 |
||
340 |
"/ if I show a quick senders/implementors menu, eat this event |
|
341 |
^ menuShown notNil |
|
342 |
! |
|
343 |
||
13561
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
344 |
findNextVariableFromCursor |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
345 |
| currentElement nextElement | |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
346 |
|
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
347 |
codeView hasSelection ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
348 |
currentElement := self elementAtLine: textView selectionStartLine col: textView selectionStartCol. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
349 |
] ifFalse:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
350 |
currentElement := codeView syntaxElementSelection. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
351 |
]. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
352 |
currentElement isVariable ifTrue:[ |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
353 |
nextElement := currentElement nextElement. |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
354 |
nextElement notNil ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
355 |
textView selectFrom: nextElement start to: nextElement stop. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
356 |
] |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
357 |
] |
13561
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
358 |
|
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
359 |
"Created: / 18-09-2013 / 13:15:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
360 |
! |
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
361 |
|
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
362 |
findPreviousVariableFromCursor |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
363 |
| currentElement prevElement | |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
364 |
|
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
365 |
codeView hasSelection ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
366 |
currentElement := self elementAtLine: textView selectionStartLine col: textView selectionStartCol. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
367 |
] ifFalse:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
368 |
currentElement := codeView syntaxElementSelection. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
369 |
]. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
370 |
currentElement isVariable ifTrue:[ |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
371 |
prevElement := currentElement previousElement. |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
372 |
prevElement notNil ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
373 |
textView selectFrom: prevElement start to: prevElement stop. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
374 |
] |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
375 |
] |
13561
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
376 |
|
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
377 |
"Created: / 18-09-2013 / 13:15:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
378 |
! |
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
379 |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
380 |
isQuickMenuModifierPressed |
13405
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
381 |
^ textView isQuickMenuModifierPressed |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
382 |
"/ |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
383 |
"/ sensor := textView sensor. |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
384 |
"/ UserPreferences current codeView2QuickSendersAndImplementorsOnControl ifTrue:[ |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
385 |
"/ ^ sensor ctrlDown |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
386 |
"/ ]. |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
387 |
"/ ^ sensor metaDown |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
388 |
|
13405
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
389 |
"Modified: / 28-08-2013 / 22:13:18 / cg" |
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
390 |
! |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
391 |
|
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
392 |
isQuickMenuModifierReleased |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
393 |
|sensor| |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
394 |
|
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
395 |
sensor := textView sensor. |
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
396 |
UserPreferences current codeView2QuickSendersAndImplementorsOnControl ifTrue:[ |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
397 |
^ sensor ctrlDown not |
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
398 |
]. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
399 |
^ sensor metaDown not |
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
400 |
! |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
401 |
|
9979 | 402 |
keyPress:key x:x y:y in:view |
403 |
"Handles an event in given view (a subview of codeView). |
|
10588 | 404 |
If the method returns true, it has eaten the event and it will not be processed |
9979 | 405 |
by the view." |
10588 | 406 |
|
12105
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
407 |
<resource: #keyboard (#Control_L #Ctrl |
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
408 |
#CursorRight #CursorDown #CursorLeft #CursorUp)> |
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
409 |
|
13463
3b75183ce219
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13422
diff
changeset
|
410 |
|ev p sensor| |
10631 | 411 |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
412 |
(view == textView) ifTrue:[ |
13463
3b75183ce219
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13422
diff
changeset
|
413 |
sensor := view sensor. |
3b75183ce219
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13422
diff
changeset
|
414 |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
415 |
"/ ("ctrlDown" "key == #'Control_L' or:[ key == #Ctrl ]") ifTrue:[ |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
416 |
(textView isQuickMenuModifierPressed) ifTrue:[ |
10631 | 417 |
"/ because it is delegated, the position is not correct |
418 |
ev := WindowGroup lastEventQuerySignal query. |
|
419 |
p := view device translatePoint:(ev x @ ev y) fromView:ev view toView:view. |
|
13463
3b75183ce219
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13422
diff
changeset
|
420 |
sensor |
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
421 |
pushUserEvent:#highlightElementAtX:y: |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
422 |
for: self |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
423 |
withArguments:{p x. p y.}. |
17040 | 424 |
^ false "/ true. -- no, don't eat the key |
9979 | 425 |
]. |
10661 | 426 |
|
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
427 |
"/ codeView reallyModified "textView modified" ifTrue:[ |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
428 |
"/ self highlightClear. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
429 |
"/ codeView syntaxElements: nil. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
430 |
"/ ^ false |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
431 |
"/ ]. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
432 |
|
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
433 |
|
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
434 |
(key == #FocusNext) ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
435 |
sensor pushUserEvent:#findNextVariableFromCursor for:self. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
436 |
^ true. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
437 |
]. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
438 |
(key == #FocusPrevious) ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
439 |
sensor pushUserEvent:#findPreviousVariableFromCursor for:self. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
440 |
^ true. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
441 |
]. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
442 |
|
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
443 |
(key == #CursorRight |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
444 |
or:[key == #CursorDown |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
445 |
or:[key == #CursorLeft |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
446 |
or:[key == #CursorUp]]] |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
447 |
) ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
448 |
sensor pushUserEvent:#highlightVariableAtCursor for:self . |
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
449 |
] ifFalse:[ |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
450 |
"/ 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
|
451 |
] |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
452 |
|
9979 | 453 |
]. |
454 |
^ false |
|
455 |
||
456 |
"Created: / 06-03-2010 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10661 | 457 |
"Modified: / 05-09-2011 / 05:17:30 / cg" |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
458 |
"Modified: / 18-09-2013 / 15:20:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 459 |
! |
460 |
||
461 |
keyRelease: key x:x y:y in: view |
|
462 |
"Handles an event in given view (a subview of codeView). |
|
10588 | 463 |
If the method returns true, it has eaten the event and it will not be processed |
9979 | 464 |
by the view." |
465 |
||
10631 | 466 |
|ev p| |
467 |
||
14204
bee53f8e01ca
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14128
diff
changeset
|
468 |
"/ (view == textView and:[textView isQuickMenuModifierReleased]) ifTrue:[ |
bee53f8e01ca
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14128
diff
changeset
|
469 |
"/ "/ (view == textView and:[key == #'Control_L' or:[key == #Ctrl]]) ifTrue:[ |
bee53f8e01ca
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14128
diff
changeset
|
470 |
"/ "/ because it is delegated, the position is not correct |
bee53f8e01ca
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14128
diff
changeset
|
471 |
"/ ev := WindowGroup lastEventQuerySignal query. |
bee53f8e01ca
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14128
diff
changeset
|
472 |
"/ p := view device translatePoint:(ev x @ ev y) fromView:ev view toView:view. |
bee53f8e01ca
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14128
diff
changeset
|
473 |
"/ "/ self highlightClear. |
bee53f8e01ca
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14128
diff
changeset
|
474 |
"/ "/ view sensor pushUserEvent:#highlightClear for:self. |
bee53f8e01ca
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14128
diff
changeset
|
475 |
"/ ^ false "/ true -- do not eat the event |
bee53f8e01ca
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14128
diff
changeset
|
476 |
"/ ]. |
10588 | 477 |
^ false |
9979 | 478 |
|
479 |
"Created: / 06-03-2010 / 21:03:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 480 |
"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
|
481 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
482 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
483 |
linesDeletedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
484 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
485 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
486 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
487 |
"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
|
488 |
"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
|
489 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
490 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
491 |
linesInsertedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
492 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
493 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
494 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
495 |
"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
|
496 |
"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
|
497 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
498 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
499 |
linesModifiedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
500 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
501 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
502 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
503 |
"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
|
504 |
"Created: / 16-09-2011 / 15:19:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 505 |
! ! |
506 |
||
507 |
!CodeNavigationService methodsFor:'initialization'! |
|
508 |
||
509 |
initialize |
|
510 |
||
511 |
super initialize. |
|
13109 | 512 |
|
513 |
"the following must only define a background - otherwise, syntax highlight fg is lost" |
|
9979 | 514 |
selectorEmphasis := self class defaultSelectorEmphasis. |
515 |
variableEmphasis := self class defaultVariableEmphasis. |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
516 |
assignmentEmphasis := self class defaultAssignmentEmphasis. |
10361 | 517 |
linesToRedraw := OrderedCollection new. |
9979 | 518 |
|
519 |
"Created: / 25-06-2010 / 14:05:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
520 |
! ! |
|
521 |
||
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
522 |
!CodeNavigationService methodsFor:'misc'! |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
523 |
|
15172
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
524 |
highlightClassVariable:name |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
525 |
"interface from browser (when a class var is selected)" |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
526 |
|
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
527 |
self highlightVariable:name isClassVariable:true |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
528 |
! |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
529 |
|
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
530 |
highlightInstanceVariable:name |
15172
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
531 |
"interface from browser (when an inst var is selected)" |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
532 |
|
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
533 |
self highlightVariable:name isClassVariable:false |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
534 |
! |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
535 |
|
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
536 |
highlightVariable:name isClassVariable:isClassVariable |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
537 |
"interface from browser (when an inst or class var is selected)" |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
538 |
|
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
539 |
|element| |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
540 |
|
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
541 |
element := (codeView syntaxElements ? #()) |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
542 |
detect:[:e | |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
543 |
e isVariable |
15172
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
544 |
and:[ (isClassVariable |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
545 |
ifTrue:[e isClassVariable ] |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
546 |
ifFalse:[e isInstanceVariable ]) |
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
547 |
and:[ e name = name ]] |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
548 |
] ifNone:nil. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
549 |
|
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
550 |
self highlightClear. |
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
551 |
codeView syntaxElementSelection:nil. |
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
552 |
self highlightVariable:element. |
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
553 |
! ! |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
554 |
|
9979 | 555 |
!CodeNavigationService methodsFor:'private'! |
556 |
||
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
557 |
elementAtCharacterPosition: pos |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
558 |
| treeIndex low high mid midEl | |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
559 |
|
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
560 |
treeIndex := codeView syntaxElements. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
561 |
treeIndex isNil ifTrue:[ ^ nil ]. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
562 |
low := 1. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
563 |
high := treeIndex size. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
564 |
|
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
565 |
[ low <= high ] whileTrue:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
566 |
mid := (low + high) >> 1. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
567 |
midEl := treeIndex at: mid. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
568 |
pos < midEl start ifTrue:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
569 |
high := mid - 1. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
570 |
] ifFalse:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
571 |
midEl stop < pos ifTrue:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
572 |
low := mid + 1. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
573 |
] ifFalse:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
574 |
^ midEl |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
575 |
]. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
576 |
]. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
577 |
]. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
578 |
^ nil. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
579 |
|
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
580 |
"Created: / 15-02-2014 / 10:14:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
581 |
! |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
582 |
|
9979 | 583 |
elementAtCursor |
16294 | 584 |
^self elementAtLine: textView cursorLine col: textView cursorCol "- 1" |
9979 | 585 |
|
586 |
"Created: / 25-06-2010 / 14:39:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
587 |
! |
|
588 |
||
10631 | 589 |
elementAtLine:line col:colArg |
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
590 |
|col| |
10631 | 591 |
|
592 |
"/ if beyond end of line, do not advance into next line |
|
593 |
col := colArg min:(textView listAt:line) size. |
|
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
594 |
^ self elementAtCharacterPosition: (textView characterPositionOfLine:line col:col) |
9979 | 595 |
|
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
596 |
"Created: / 15-02-2014 / 10:15:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 597 |
! |
598 |
||
599 |
elementAtX:x y:y |
|
600 |
|visibleLine line col| |
|
601 |
||
10631 | 602 |
codeView syntaxElements isNil ifTrue:[^nil]. |
603 |
||
9979 | 604 |
visibleLine := textView visibleLineOfY:y. |
605 |
col := textView colOfX:x inVisibleLine:visibleLine. |
|
606 |
line := textView visibleLineToAbsoluteLine:visibleLine. |
|
607 |
^self elementAtLine:line col:col |
|
608 |
||
609 |
"Created: / 25-06-2010 / 14:52:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
610 |
"Modified: / 01-08-2010 / 08:50:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 611 |
"Modified: / 21-08-2011 / 10:26:08 / cg" |
612 |
! |
|
613 |
||
9979 | 614 |
highlighEmphasisFor: element |
615 |
||
10878 | 616 |
element isNil ifTrue:[^nil]. |
9979 | 617 |
|
10631 | 618 |
element isSelector ifTrue:[^selectorEmphasis]. |
619 |
element isVariable ifTrue:[^variableEmphasis]. |
|
620 |
element isSelf ifTrue:[^variableEmphasis]. |
|
9979 | 621 |
|
622 |
^nil |
|
623 |
||
624 |
"Created: / 25-06-2010 / 13:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 625 |
"Modified: / 18-11-2011 / 14:58:05 / cg" |
9979 | 626 |
! |
627 |
||
628 |
highlightClear |
|
629 |
||
10361 | 630 |
^self highlightClear: true. |
9979 | 631 |
|
632 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
|
633 |
"Created: / 25-06-2010 / 14:15:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10276 | 634 |
"Modified: / 08-07-2011 / 08:50:45 / cg" |
10361 | 635 |
"Modified: / 20-07-2011 / 18:52:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 636 |
! |
637 |
||
10361 | 638 |
highlightClear: redraw |
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
639 |
lastHighlightedElement := nil. |
10361 | 640 |
codeView syntaxElementSelection == nil ifTrue:[ ^ self ]. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
641 |
|
10878 | 642 |
textView list isNil ifTrue:[ ^ self ]. |
10361 | 643 |
textView list withIndexDo:[:line :lineNo | |
644 |
line isText ifTrue:[ |
|
645 |
(line hasEmphasis: currentEmphasis) ifTrue:[ |
|
646 |
line emphasisAllRemove:currentEmphasis. |
|
647 |
linesToRedraw add: lineNo. |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
648 |
] ifFalse:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
649 |
(currentEmphasisForAssign notNil and:[line hasEmphasis: currentEmphasisForAssign]) ifTrue:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
650 |
line emphasisAllRemove:currentEmphasisForAssign. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
651 |
linesToRedraw add: lineNo. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
652 |
] |
10361 | 653 |
] |
654 |
] |
|
655 |
]. |
|
656 |
codeView syntaxElementSelection:nil. |
|
657 |
||
658 |
redraw ifTrue:[self redrawLines]. |
|
9979 | 659 |
|
10361 | 660 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
661 |
"Created: / 20-07-2011 / 18:52:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 662 |
"Modified: / 18-11-2011 / 14:58:08 / cg" |
10361 | 663 |
! |
664 |
||
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
665 |
highlightElement:element |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
666 |
"walk through the chain of elements and highlight each |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
667 |
Notice, that the chain links elements for the same-variable |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
668 |
(and lists for same-named-but-in-different-scope variables have |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
669 |
already been separated)" |
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
670 |
|
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
671 |
|e firstElement savedEmphasis currentSelection highlightSingle| |
10631 | 672 |
|
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
673 |
(currentSelection := codeView syntaxElementSelection) == element ifTrue:[ ^ self ]. "/ no change |
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
674 |
currentSelection notNil ifTrue:[ |
10631 | 675 |
self highlightClear: false. |
676 |
]. |
|
10361 | 677 |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
678 |
currentEmphasis := savedEmphasis := self highlighEmphasisFor:element. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
679 |
currentEmphasisForAssign := nil. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
680 |
|
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
681 |
highlightSingle := |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
682 |
[:element | |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
683 |
|start stop| |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
684 |
|
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
685 |
start := element start. |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
686 |
stop := element stop. |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
687 |
|
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
688 |
element assigned ifTrue:[ |
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
689 |
[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
690 |
currentEmphasis := currentEmphasisForAssign := assignmentEmphasis. |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
691 |
self highlightWithoutClearFrom:start to:stop. |
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
692 |
] ensure:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
693 |
currentEmphasis := savedEmphasis. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
694 |
]. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
695 |
] ifFalse:[ |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
696 |
self highlightWithoutClearFrom:start to:stop. |
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
697 |
]. |
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
698 |
]. |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
699 |
|
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
700 |
element notNil ifTrue:[ |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
701 |
codeView syntaxElementSelection:element. |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
702 |
e := firstElement := element firstElementInChain. |
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
703 |
|
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
704 |
"/ cg: I thought that this would work, to speedup up the case, where the same |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
705 |
"/ element is to be highlighted again (it does, but now, it does not correctly |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
706 |
"/ redraw in some situations) |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
707 |
"/ can someone check this? |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
708 |
false ifTrue:[ |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
709 |
e == lastHighlightedElement ifTrue:[ |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
710 |
"/ same chain |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
711 |
highlightSingle value:element. |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
712 |
^ self |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
713 |
]. |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
714 |
lastHighlightedElement := e. "/ remember |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
715 |
]. |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
716 |
|
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
717 |
[ e notNil ] whileTrue:[ |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
718 |
"/ cg: suppress variables with same name, but in different blocks |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
719 |
"/ (e isVariable not or:[ e isInSameBlockScopeAs:firstElement]) ifTrue:[ |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
720 |
highlightSingle value:e. |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
721 |
"/ ]. |
10631 | 722 |
e := e nextElement |
723 |
]. |
|
724 |
]. |
|
10361 | 725 |
self redrawLines. |
9979 | 726 |
|
727 |
"Created: / 14-02-2010 / 16:18:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10361 | 728 |
"Modified: / 20-07-2011 / 18:52:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10631 | 729 |
"Modified: / 21-08-2011 / 10:22:58 / cg" |
9979 | 730 |
! |
731 |
||
732 |
highlightElementAtCursor |
|
733 |
self highlightElementAtLine: textView cursorLine col: textView cursorCol |
|
734 |
||
735 |
"Created: / 14-02-2010 / 16:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
736 |
"Modified: / 06-03-2010 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
737 |
! |
|
738 |
||
739 |
highlightElementAtLine:line col:col |
|
13866 | 740 |
|elementOrNil| |
9979 | 741 |
|
13866 | 742 |
elementOrNil := self elementAtLine: line col: col. |
13536
c7a7ca8afcdd
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13534
diff
changeset
|
743 |
self highlightElement:elementOrNil |
9979 | 744 |
|
745 |
"Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13866 | 746 |
"Modified: / 02-10-2013 / 01:29:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 747 |
! |
748 |
||
749 |
highlightElementAtX:x y:y |
|
14004
ee41e156d189
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
13946
diff
changeset
|
750 |
|elementOrNil| |
9979 | 751 |
|
14004
ee41e156d189
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
13946
diff
changeset
|
752 |
elementOrNil := self elementAtX:x y:y. |
ee41e156d189
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
13946
diff
changeset
|
753 |
self highlightElement:elementOrNil |
9979 | 754 |
|
755 |
"Created: / 14-02-2010 / 16:12:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
756 |
"Modified: / 06-03-2010 / 20:06:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 757 |
"Modified: / 21-08-2011 / 10:22:10 / cg" |
758 |
! |
|
759 |
||
760 |
highlightElementOrNil:e |
|
761 |
e notNil ifTrue:[ |
|
762 |
"/ cg: only if selected !! |
|
763 |
"/ self halt. |
|
764 |
self highlightElement:e. |
|
765 |
] ifFalse:[ |
|
766 |
self highlightClear |
|
767 |
]. |
|
768 |
||
769 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
770 |
"Created: / 21-08-2011 / 09:56:39 / cg" |
|
9979 | 771 |
! |
772 |
||
773 |
highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol |
|
774 |
|line start end| |
|
775 |
||
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
776 |
(lineNo between:startLine and:endLine) ifFalse:[ ^ self ]. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
777 |
|
9979 | 778 |
line := textView listAt:lineNo. |
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
779 |
line isEmpty ifTrue:[^self]. |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
780 |
|
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
781 |
start := (lineNo = startLine) |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
782 |
ifTrue:[ startCol ] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
783 |
ifFalse:[ line indexOfNonSeparator ]. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
784 |
end := (lineNo = endLine) |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
785 |
ifTrue:[ endCol ] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
786 |
ifFalse:[ line size ]. |
13866 | 787 |
line setRuns:(line runs asArray). |
788 |
"/ JV: CG commented following and added the commtent code below. |
|
789 |
"/ however, this clear all other emphasis like bold, color and so on!! |
|
790 |
line |
|
13109 | 791 |
emphasisFrom:(start max: 1) |
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
792 |
to:(end min: line size) |
13109 | 793 |
add: currentEmphasis. |
13866 | 794 |
"/ line |
795 |
"/ emphasizeFrom:(start max: 1) |
|
796 |
"/ to:(end min: line size) |
|
797 |
"/ with: currentEmphasis. |
|
798 |
line setRuns:(line runs asRunArray). |
|
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
799 |
|
10361 | 800 |
linesToRedraw add: lineNo. |
9979 | 801 |
|
802 |
"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
|
803 |
"Modified: / 08-07-2011 / 13:02:51 / cg" |
14058
6018db6ddc02
Fixes in CodeNavigationService - semi-modal navigation should work again.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14004
diff
changeset
|
804 |
"Modified: / 25-02-2014 / 21:01:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 805 |
! |
806 |
||
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
807 |
highlightVariable:element |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
808 |
(element notNil and:[ element isVariableOrSelf ]) ifTrue:[ |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
809 |
self highlightElement:element. |
9979 | 810 |
] ifFalse:[ |
811 |
self highlightClear. |
|
10361 | 812 |
]. |
813 |
||
814 |
"Modified: / 20-07-2011 / 18:54:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 815 |
"Modified: / 21-08-2011 / 09:39:42 / cg" |
9979 | 816 |
! |
817 |
||
818 |
highlightVariableAtCursor |
|
10631 | 819 |
self highlightElementOrNil:(self elementAtCursor) |
9979 | 820 |
|
821 |
"Modified: / 25-06-2010 / 14:53:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 822 |
"Modified: / 21-08-2011 / 09:56:56 / cg" |
9979 | 823 |
! |
824 |
||
825 |
highlightVariableAtX:x y:y |
|
10631 | 826 |
self highlightElementOrNil:(self elementAtX:x y:y). |
9979 | 827 |
|
828 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 829 |
"Modified: / 21-08-2011 / 10:24:50 / cg" |
9979 | 830 |
! |
831 |
||
832 |
highlightWithoutClearFrom: start to: end |
|
833 |
"Remove underlined emphasis" |
|
834 |
||
835 |
|startLine startCol endLine endCol| |
|
836 |
||
837 |
startLine := textView lineOfCharacterPosition:start. |
|
838 |
startCol := start - (textView characterPositionOfLine:startLine col:1) + 1. |
|
839 |
endLine := textView lineOfCharacterPosition:end. |
|
840 |
endCol := end - (textView characterPositionOfLine:endLine col:1) + 1. |
|
841 |
self highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
842 |
||
843 |
"Created: / 25-06-2010 / 14:15:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
844 |
! |
|
845 |
||
846 |
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
847 |
||
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
848 |
textView list keysAndValuesDo: [:lineNo :line| |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
849 |
line isText ifTrue: [ |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
850 |
self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
851 |
] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
852 |
]. |
9979 | 853 |
|
854 |
"Created: / 25-06-2010 / 14:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
855 |
! ! |
|
856 |
||
10361 | 857 |
!CodeNavigationService methodsFor:'redrawing'! |
858 |
||
859 |
redrawLines |
|
860 |
linesToRedraw do:[:lineNo| |
|
10588 | 861 |
textView invalidateLine: lineNo. |
10361 | 862 |
]. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
863 |
linesToRedraw := OrderedCollection new |
10361 | 864 |
|
865 |
"Created: / 20-07-2011 / 18:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10588 | 866 |
"Modified (format): / 18-08-2011 / 16:01:34 / cg" |
10361 | 867 |
! ! |
868 |
||
9979 | 869 |
!CodeNavigationService class methodsFor:'documentation'! |
870 |
||
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
871 |
version |
16294 | 872 |
^ '$Header$' |
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
873 |
! |
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
874 |
|
9979 | 875 |
version_CVS |
16294 | 876 |
^ '$Header$' |
9979 | 877 |
! |
878 |
||
879 |
version_SVN |
|
16294 | 880 |
^ '$Id$' |
9979 | 881 |
! ! |
12105
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
882 |