author | Stefan Vogel <sv@exept.de> |
Fri, 17 May 2019 17:09:44 +0200 | |
changeset 18766 | e0a9a93a8edc |
parent 18410 | dd06b3f7684f |
child 19081 | 105f3e3f2783 |
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 |
18409 | 418 |
p := view device translatePoint:(view device pointerPosition) fromView:nil toView:view. |
419 |
"/ ev := WindowGroup lastEvent. |
|
420 |
"/ 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
|
421 |
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
|
422 |
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
|
423 |
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
|
424 |
withArguments:{p x. p y.}. |
17040 | 425 |
^ false "/ true. -- no, don't eat the key |
9979 | 426 |
]. |
10661 | 427 |
|
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
428 |
"/ codeView reallyModified "textView modified" ifTrue:[ |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
429 |
"/ self highlightClear. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
430 |
"/ codeView syntaxElements: nil. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
431 |
"/ ^ false |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
432 |
"/ ]. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
433 |
|
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
434 |
|
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
435 |
(key == #FocusNext) ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
436 |
sensor pushUserEvent:#findNextVariableFromCursor for:self. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
437 |
^ true. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
438 |
]. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
439 |
(key == #FocusPrevious) ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
440 |
sensor pushUserEvent:#findPreviousVariableFromCursor for:self. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
441 |
^ true. |
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 |
|
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
444 |
(key == #CursorRight |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
445 |
or:[key == #CursorDown |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
446 |
or:[key == #CursorLeft |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
447 |
or:[key == #CursorUp]]] |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
448 |
) ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
449 |
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
|
450 |
] ifFalse:[ |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
451 |
"/ 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
|
452 |
] |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
453 |
|
9979 | 454 |
]. |
455 |
^ false |
|
456 |
||
457 |
"Created: / 06-03-2010 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10661 | 458 |
"Modified: / 05-09-2011 / 05:17:30 / cg" |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
459 |
"Modified: / 18-09-2013 / 15:20:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18327 | 460 |
"Modified: / 09-08-2018 / 10:32:11 / Claus Gittinger" |
18409 | 461 |
"Modified: / 21-09-2018 / 15:09:57 / sr" |
9979 | 462 |
! |
463 |
||
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
464 |
linesDeletedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
465 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
466 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
467 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
468 |
"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
|
469 |
"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
|
470 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
471 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
472 |
linesInsertedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
473 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
474 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
475 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
476 |
"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
|
477 |
"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
|
478 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
479 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
480 |
linesModifiedFrom: start to: end |
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 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
483 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
484 |
"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
|
485 |
"Created: / 16-09-2011 / 15:19:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 486 |
! ! |
487 |
||
488 |
!CodeNavigationService methodsFor:'initialization'! |
|
489 |
||
490 |
initialize |
|
491 |
||
492 |
super initialize. |
|
13109 | 493 |
|
494 |
"the following must only define a background - otherwise, syntax highlight fg is lost" |
|
9979 | 495 |
selectorEmphasis := self class defaultSelectorEmphasis. |
496 |
variableEmphasis := self class defaultVariableEmphasis. |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
497 |
assignmentEmphasis := self class defaultAssignmentEmphasis. |
10361 | 498 |
linesToRedraw := OrderedCollection new. |
9979 | 499 |
|
500 |
"Created: / 25-06-2010 / 14:05:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
501 |
! ! |
|
502 |
||
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
503 |
!CodeNavigationService methodsFor:'misc'! |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
504 |
|
15172
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
505 |
highlightClassVariable:name |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
506 |
"interface from browser (when a class var is selected)" |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
507 |
|
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
508 |
self highlightVariable:name isClassVariable:true |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
509 |
! |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
510 |
|
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
511 |
highlightInstanceVariable:name |
15172
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
512 |
"interface from browser (when an inst var is selected)" |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
513 |
|
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
514 |
self highlightVariable:name isClassVariable:false |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
515 |
! |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
516 |
|
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
517 |
highlightVariable:name isClassVariable:isClassVariable |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
518 |
"interface from browser (when an inst or class var is selected)" |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
519 |
|
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
520 |
|element| |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
521 |
|
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
522 |
element := (codeView syntaxElements ? #()) |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
523 |
detect:[:e | |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
524 |
e isVariable |
15172
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
525 |
and:[ (isClassVariable |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
526 |
ifTrue:[e isClassVariable ] |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
527 |
ifFalse:[e isInstanceVariable ]) |
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
528 |
and:[ e name = name ]] |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
529 |
] ifNone:nil. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
530 |
|
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
531 |
self highlightClear. |
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
532 |
codeView syntaxElementSelection:nil. |
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
533 |
self highlightVariable:element. |
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
534 |
! ! |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
535 |
|
9979 | 536 |
!CodeNavigationService methodsFor:'private'! |
537 |
||
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
538 |
elementAtCharacterPosition: pos |
18343 | 539 |
| elements low high mid midEl | |
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
540 |
|
18343 | 541 |
(elements := codeView syntaxElements) isEmptyOrNil ifTrue:[ ^ nil ]. |
542 |
||
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
543 |
low := 1. |
18343 | 544 |
high := elements size. |
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
545 |
|
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
546 |
[ low <= high ] whileTrue:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
547 |
mid := (low + high) >> 1. |
18343 | 548 |
midEl := elements at: mid. |
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
549 |
pos < midEl start ifTrue:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
550 |
high := mid - 1. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
551 |
] ifFalse:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
552 |
midEl stop < pos ifTrue:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
553 |
low := mid + 1. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
554 |
] ifFalse:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
555 |
^ midEl |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
556 |
]. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
557 |
]. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
558 |
]. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
559 |
^ nil. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
560 |
|
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
561 |
"Created: / 15-02-2014 / 10:14:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18343 | 562 |
"Modified: / 22-08-2018 / 08:13:33 / Claus Gittinger" |
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
563 |
! |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
564 |
|
9979 | 565 |
elementAtCursor |
16294 | 566 |
^self elementAtLine: textView cursorLine col: textView cursorCol "- 1" |
9979 | 567 |
|
568 |
"Created: / 25-06-2010 / 14:39:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
569 |
! |
|
570 |
||
10631 | 571 |
elementAtLine:line col:colArg |
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
572 |
|col| |
10631 | 573 |
|
574 |
"/ if beyond end of line, do not advance into next line |
|
575 |
col := colArg min:(textView listAt:line) size. |
|
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
576 |
^ self elementAtCharacterPosition: (textView characterPositionOfLine:line col:col) |
9979 | 577 |
|
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
578 |
"Created: / 15-02-2014 / 10:15:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 579 |
! |
580 |
||
581 |
elementAtX:x y:y |
|
582 |
|visibleLine line col| |
|
583 |
||
18343 | 584 |
codeView syntaxElements isEmptyOrNil ifTrue:[^nil]. |
10631 | 585 |
|
9979 | 586 |
visibleLine := textView visibleLineOfY:y. |
587 |
col := textView colOfX:x inVisibleLine:visibleLine. |
|
588 |
line := textView visibleLineToAbsoluteLine:visibleLine. |
|
589 |
^self elementAtLine:line col:col |
|
590 |
||
591 |
"Created: / 25-06-2010 / 14:52:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
592 |
"Modified: / 01-08-2010 / 08:50:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 593 |
"Modified: / 21-08-2011 / 10:26:08 / cg" |
18343 | 594 |
"Modified: / 22-08-2018 / 08:15:46 / Claus Gittinger" |
10631 | 595 |
! |
596 |
||
9979 | 597 |
highlighEmphasisFor: element |
598 |
||
10878 | 599 |
element isNil ifTrue:[^nil]. |
9979 | 600 |
|
10631 | 601 |
element isSelector ifTrue:[^selectorEmphasis]. |
602 |
element isVariable ifTrue:[^variableEmphasis]. |
|
603 |
element isSelf ifTrue:[^variableEmphasis]. |
|
9979 | 604 |
|
605 |
^nil |
|
606 |
||
607 |
"Created: / 25-06-2010 / 13:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 608 |
"Modified: / 18-11-2011 / 14:58:05 / cg" |
9979 | 609 |
! |
610 |
||
611 |
highlightClear |
|
612 |
||
10361 | 613 |
^self highlightClear: true. |
9979 | 614 |
|
615 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
|
616 |
"Created: / 25-06-2010 / 14:15:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10276 | 617 |
"Modified: / 08-07-2011 / 08:50:45 / cg" |
10361 | 618 |
"Modified: / 20-07-2011 / 18:52:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 619 |
! |
620 |
||
10361 | 621 |
highlightClear: redraw |
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
622 |
lastHighlightedElement := nil. |
10361 | 623 |
codeView syntaxElementSelection == nil ifTrue:[ ^ self ]. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
624 |
|
10878 | 625 |
textView list isNil ifTrue:[ ^ self ]. |
10361 | 626 |
textView list withIndexDo:[:line :lineNo | |
627 |
line isText ifTrue:[ |
|
628 |
(line hasEmphasis: currentEmphasis) ifTrue:[ |
|
629 |
line emphasisAllRemove:currentEmphasis. |
|
630 |
linesToRedraw add: lineNo. |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
631 |
] ifFalse:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
632 |
(currentEmphasisForAssign notNil and:[line hasEmphasis: currentEmphasisForAssign]) ifTrue:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
633 |
line emphasisAllRemove:currentEmphasisForAssign. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
634 |
linesToRedraw add: lineNo. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
635 |
] |
10361 | 636 |
] |
637 |
] |
|
638 |
]. |
|
639 |
codeView syntaxElementSelection:nil. |
|
640 |
||
641 |
redraw ifTrue:[self redrawLines]. |
|
9979 | 642 |
|
10361 | 643 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
644 |
"Created: / 20-07-2011 / 18:52:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 645 |
"Modified: / 18-11-2011 / 14:58:08 / cg" |
10361 | 646 |
! |
647 |
||
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
648 |
highlightElement:element |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
649 |
"walk through the chain of elements and highlight each |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
650 |
Notice, that the chain links elements for the same-variable |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
651 |
(and lists for same-named-but-in-different-scope variables have |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
652 |
already been separated)" |
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
653 |
|
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
654 |
|e firstElement savedEmphasis currentSelection highlightSingle| |
10631 | 655 |
|
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
656 |
(currentSelection := codeView syntaxElementSelection) == element ifTrue:[ ^ self ]. "/ no change |
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
657 |
currentSelection notNil ifTrue:[ |
10631 | 658 |
self highlightClear: false. |
659 |
]. |
|
10361 | 660 |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
661 |
currentEmphasis := savedEmphasis := self highlighEmphasisFor:element. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
662 |
currentEmphasisForAssign := nil. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
663 |
|
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
664 |
highlightSingle := |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
665 |
[:element | |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
666 |
|start stop| |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
667 |
|
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
668 |
start := element start. |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
669 |
stop := element stop. |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
670 |
|
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
671 |
element assigned ifTrue:[ |
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
672 |
[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
673 |
currentEmphasis := currentEmphasisForAssign := assignmentEmphasis. |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
674 |
self highlightWithoutClearFrom:start to:stop. |
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
675 |
] ensure:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
676 |
currentEmphasis := savedEmphasis. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
677 |
]. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
678 |
] ifFalse:[ |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
679 |
self highlightWithoutClearFrom:start to:stop. |
12986
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 |
]. |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
682 |
|
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
683 |
element notNil ifTrue:[ |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
684 |
codeView syntaxElementSelection:element. |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
685 |
e := firstElement := element firstElementInChain. |
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
686 |
|
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
687 |
"/ 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
|
688 |
"/ 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
|
689 |
"/ redraw in some situations) |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
690 |
"/ can someone check this? |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
691 |
false ifTrue:[ |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
692 |
e == lastHighlightedElement ifTrue:[ |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
693 |
"/ same chain |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
694 |
highlightSingle value:element. |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
695 |
^ self |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
696 |
]. |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
697 |
lastHighlightedElement := e. "/ remember |
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 |
[ e notNil ] whileTrue:[ |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
701 |
"/ cg: suppress variables with same name, but in different blocks |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
702 |
"/ (e isVariable not or:[ e isInSameBlockScopeAs:firstElement]) ifTrue:[ |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
703 |
highlightSingle value:e. |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
704 |
"/ ]. |
10631 | 705 |
e := e nextElement |
706 |
]. |
|
707 |
]. |
|
10361 | 708 |
self redrawLines. |
9979 | 709 |
|
710 |
"Created: / 14-02-2010 / 16:18:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10361 | 711 |
"Modified: / 20-07-2011 / 18:52:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10631 | 712 |
"Modified: / 21-08-2011 / 10:22:58 / cg" |
9979 | 713 |
! |
714 |
||
715 |
highlightElementAtCursor |
|
716 |
self highlightElementAtLine: textView cursorLine col: textView cursorCol |
|
717 |
||
718 |
"Created: / 14-02-2010 / 16:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
719 |
"Modified: / 06-03-2010 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
720 |
! |
|
721 |
||
722 |
highlightElementAtLine:line col:col |
|
13866 | 723 |
|elementOrNil| |
9979 | 724 |
|
13866 | 725 |
elementOrNil := self elementAtLine: line col: col. |
13536
c7a7ca8afcdd
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13534
diff
changeset
|
726 |
self highlightElement:elementOrNil |
9979 | 727 |
|
728 |
"Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13866 | 729 |
"Modified: / 02-10-2013 / 01:29:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 730 |
! |
731 |
||
732 |
highlightElementAtX:x y:y |
|
14004
ee41e156d189
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
13946
diff
changeset
|
733 |
|elementOrNil| |
9979 | 734 |
|
14004
ee41e156d189
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
13946
diff
changeset
|
735 |
elementOrNil := self elementAtX:x y:y. |
ee41e156d189
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
13946
diff
changeset
|
736 |
self highlightElement:elementOrNil |
9979 | 737 |
|
738 |
"Created: / 14-02-2010 / 16:12:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
739 |
"Modified: / 06-03-2010 / 20:06:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 740 |
"Modified: / 21-08-2011 / 10:22:10 / cg" |
741 |
! |
|
742 |
||
743 |
highlightElementOrNil:e |
|
744 |
e notNil ifTrue:[ |
|
745 |
"/ cg: only if selected !! |
|
746 |
"/ self halt. |
|
747 |
self highlightElement:e. |
|
748 |
] ifFalse:[ |
|
749 |
self highlightClear |
|
750 |
]. |
|
751 |
||
752 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
753 |
"Created: / 21-08-2011 / 09:56:39 / cg" |
|
9979 | 754 |
! |
755 |
||
756 |
highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol |
|
757 |
|line start end| |
|
758 |
||
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
759 |
(lineNo between:startLine and:endLine) ifFalse:[ ^ self ]. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
760 |
|
9979 | 761 |
line := textView listAt:lineNo. |
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
762 |
line isEmpty ifTrue:[^self]. |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
763 |
|
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
764 |
start := (lineNo = startLine) |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
765 |
ifTrue:[ startCol ] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
766 |
ifFalse:[ line indexOfNonSeparator ]. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
767 |
end := (lineNo = endLine) |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
768 |
ifTrue:[ endCol ] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
769 |
ifFalse:[ line size ]. |
13866 | 770 |
line setRuns:(line runs asArray). |
771 |
"/ JV: CG commented following and added the commtent code below. |
|
772 |
"/ however, this clear all other emphasis like bold, color and so on!! |
|
773 |
line |
|
13109 | 774 |
emphasisFrom:(start max: 1) |
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
775 |
to:(end min: line size) |
13109 | 776 |
add: currentEmphasis. |
13866 | 777 |
"/ line |
778 |
"/ emphasizeFrom:(start max: 1) |
|
779 |
"/ to:(end min: line size) |
|
780 |
"/ with: currentEmphasis. |
|
781 |
line setRuns:(line runs asRunArray). |
|
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
782 |
|
10361 | 783 |
linesToRedraw add: lineNo. |
9979 | 784 |
|
785 |
"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
|
786 |
"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
|
787 |
"Modified: / 25-02-2014 / 21:01:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 788 |
! |
789 |
||
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
790 |
highlightVariable:element |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
791 |
(element notNil and:[ element isVariableOrSelf ]) ifTrue:[ |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
792 |
self highlightElement:element. |
9979 | 793 |
] ifFalse:[ |
794 |
self highlightClear. |
|
10361 | 795 |
]. |
796 |
||
797 |
"Modified: / 20-07-2011 / 18:54:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 798 |
"Modified: / 21-08-2011 / 09:39:42 / cg" |
9979 | 799 |
! |
800 |
||
801 |
highlightVariableAtCursor |
|
10631 | 802 |
self highlightElementOrNil:(self elementAtCursor) |
9979 | 803 |
|
804 |
"Modified: / 25-06-2010 / 14:53:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 805 |
"Modified: / 21-08-2011 / 09:56:56 / cg" |
9979 | 806 |
! |
807 |
||
808 |
highlightVariableAtX:x y:y |
|
10631 | 809 |
self highlightElementOrNil:(self elementAtX:x y:y). |
9979 | 810 |
|
811 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 812 |
"Modified: / 21-08-2011 / 10:24:50 / cg" |
9979 | 813 |
! |
814 |
||
815 |
highlightWithoutClearFrom: start to: end |
|
816 |
"Remove underlined emphasis" |
|
817 |
||
818 |
|startLine startCol endLine endCol| |
|
819 |
||
820 |
startLine := textView lineOfCharacterPosition:start. |
|
821 |
startCol := start - (textView characterPositionOfLine:startLine col:1) + 1. |
|
822 |
endLine := textView lineOfCharacterPosition:end. |
|
823 |
endCol := end - (textView characterPositionOfLine:endLine col:1) + 1. |
|
824 |
self highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
825 |
||
826 |
"Created: / 25-06-2010 / 14:15:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
827 |
! |
|
828 |
||
829 |
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
830 |
||
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
831 |
textView list keysAndValuesDo: [:lineNo :line| |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
832 |
line isText ifTrue: [ |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
833 |
self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
834 |
] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
835 |
]. |
9979 | 836 |
|
837 |
"Created: / 25-06-2010 / 14:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
838 |
! ! |
|
839 |
||
10361 | 840 |
!CodeNavigationService methodsFor:'redrawing'! |
841 |
||
842 |
redrawLines |
|
843 |
linesToRedraw do:[:lineNo| |
|
10588 | 844 |
textView invalidateLine: lineNo. |
10361 | 845 |
]. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
846 |
linesToRedraw := OrderedCollection new |
10361 | 847 |
|
848 |
"Created: / 20-07-2011 / 18:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10588 | 849 |
"Modified (format): / 18-08-2011 / 16:01:34 / cg" |
10361 | 850 |
! ! |
851 |
||
9979 | 852 |
!CodeNavigationService class methodsFor:'documentation'! |
853 |
||
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
854 |
version |
16294 | 855 |
^ '$Header$' |
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
856 |
! |
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
857 |
|
9979 | 858 |
version_CVS |
16294 | 859 |
^ '$Header$' |
9979 | 860 |
! |
861 |
||
862 |
version_SVN |
|
16294 | 863 |
^ '$Id$' |
9979 | 864 |
! ! |
12105
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
865 |