author | Stefan Vogel <sv@exept.de> |
Fri, 22 Nov 2019 16:48:22 +0100 | |
changeset 19296 | 6ffe226271c1 |
parent 19295 | f4e49708a4de |
child 19370 | 4944c9c815ed |
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). |
|
19081 | 309 |
If the method returns true, it has eaten the event and it will not be processed |
310 |
by the view or other services. |
|
311 |
Notice, that this is called both for events in the gutter AND for events in the text." |
|
9979 | 312 |
|
10631 | 313 |
(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
|
314 |
textView isQuickMenuModifierPressed ifTrue:[ |
13699
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
315 |
button == 1 ifTrue: [ |
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
316 |
codeView sensor shiftDown ifTrue:[ |
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
317 |
^self button2Press |
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
318 |
]. |
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
319 |
^self button1Press |
462794004446
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13564
diff
changeset
|
320 |
]. |
12353
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 == #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
|
322 |
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
|
323 |
] ifFalse:[ |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
324 |
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
|
325 |
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
|
326 |
] |
9979 | 327 |
] |
10631 | 328 |
]. |
9979 | 329 |
^false |
330 |
||
331 |
"Created: / 06-03-2010 / 21:12:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
332 |
"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
|
333 |
"Modified: / 01-12-2013 / 23:42:02 / cg" |
9979 | 334 |
! |
335 |
||
12867 | 336 |
buttonRelease: button x:x y:y in: view |
337 |
"Handles an event in given view (a subview of codeView). |
|
338 |
If the method returns true, the event will not be processed |
|
339 |
by the view." |
|
340 |
||
341 |
"/ if I show a quick senders/implementors menu, eat this event |
|
342 |
^ menuShown notNil |
|
343 |
! |
|
344 |
||
13561
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
345 |
findNextVariableFromCursor |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
346 |
| currentElement nextElement | |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
347 |
|
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
348 |
codeView hasSelection ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
349 |
currentElement := self elementAtLine: textView selectionStartLine col: textView selectionStartCol. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
350 |
] ifFalse:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
351 |
currentElement := codeView syntaxElementSelection. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
352 |
]. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
353 |
currentElement isVariable ifTrue:[ |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
354 |
nextElement := currentElement nextElement. |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
355 |
nextElement notNil ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
356 |
textView selectFrom: nextElement start to: nextElement stop. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
357 |
] |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
358 |
] |
13561
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
359 |
|
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
360 |
"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
|
361 |
! |
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
362 |
|
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
363 |
findPreviousVariableFromCursor |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
364 |
| currentElement prevElement | |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
365 |
|
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
366 |
codeView hasSelection ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
367 |
currentElement := self elementAtLine: textView selectionStartLine col: textView selectionStartCol. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
368 |
] ifFalse:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
369 |
currentElement := codeView syntaxElementSelection. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
370 |
]. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
371 |
currentElement isVariable ifTrue:[ |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
372 |
prevElement := currentElement previousElement. |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
373 |
prevElement notNil ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
374 |
textView selectFrom: prevElement start to: prevElement stop. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
375 |
] |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
376 |
] |
13561
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
377 |
|
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
378 |
"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
|
379 |
! |
14ca499f0ca4
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13536
diff
changeset
|
380 |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
381 |
isQuickMenuModifierPressed |
13405
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
382 |
^ textView isQuickMenuModifierPressed |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
383 |
"/ |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
384 |
"/ sensor := textView sensor. |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
385 |
"/ UserPreferences current codeView2QuickSendersAndImplementorsOnControl ifTrue:[ |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
386 |
"/ ^ sensor ctrlDown |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
387 |
"/ ]. |
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
388 |
"/ ^ sensor metaDown |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
389 |
|
13405
071eccc590bb
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13203
diff
changeset
|
390 |
"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
|
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 |
|
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
393 |
isQuickMenuModifierReleased |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
394 |
|sensor| |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
395 |
|
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
396 |
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
|
397 |
UserPreferences current codeView2QuickSendersAndImplementorsOnControl ifTrue:[ |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
398 |
^ 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
|
399 |
]. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
400 |
^ 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
|
401 |
! |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
402 |
|
9979 | 403 |
keyPress:key x:x y:y in:view |
404 |
"Handles an event in given view (a subview of codeView). |
|
10588 | 405 |
If the method returns true, it has eaten the event and it will not be processed |
9979 | 406 |
by the view." |
10588 | 407 |
|
19296 | 408 |
<resource: #keyboard (#Control_L #Ctrl |
12105
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
409 |
#CursorRight #CursorDown #CursorLeft #CursorUp)> |
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
410 |
|
13463
3b75183ce219
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13422
diff
changeset
|
411 |
|ev p sensor| |
10631 | 412 |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
413 |
(view == textView) ifTrue:[ |
13463
3b75183ce219
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13422
diff
changeset
|
414 |
sensor := view sensor. |
3b75183ce219
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13422
diff
changeset
|
415 |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
416 |
"/ ("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
|
417 |
(textView isQuickMenuModifierPressed) ifTrue:[ |
10631 | 418 |
"/ because it is delegated, the position is not correct |
18409 | 419 |
p := view device translatePoint:(view device pointerPosition) fromView:nil toView:view. |
420 |
"/ ev := WindowGroup lastEvent. |
|
421 |
"/ 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
|
422 |
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
|
423 |
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
|
424 |
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
|
425 |
withArguments:{p x. p y.}. |
17040 | 426 |
^ false "/ true. -- no, don't eat the key |
9979 | 427 |
]. |
10661 | 428 |
|
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
429 |
"/ codeView reallyModified "textView modified" ifTrue:[ |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
430 |
"/ self highlightClear. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
431 |
"/ codeView syntaxElements: nil. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
432 |
"/ ^ false |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
433 |
"/ ]. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
434 |
|
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
435 |
|
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
436 |
(key == #FocusNext) ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
437 |
sensor pushUserEvent:#findNextVariableFromCursor for:self. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
438 |
^ true. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
439 |
]. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
440 |
(key == #FocusPrevious) ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
441 |
sensor pushUserEvent:#findPreviousVariableFromCursor for:self. |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
442 |
^ true. |
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 |
|
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
445 |
(key == #CursorRight |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
446 |
or:[key == #CursorDown |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
447 |
or:[key == #CursorLeft |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
448 |
or:[key == #CursorUp]]] |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
449 |
) ifTrue:[ |
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
450 |
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
|
451 |
] ifFalse:[ |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
452 |
"/ 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
|
453 |
] |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
454 |
|
9979 | 455 |
]. |
456 |
^ false |
|
457 |
||
458 |
"Created: / 06-03-2010 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10661 | 459 |
"Modified: / 05-09-2011 / 05:17:30 / cg" |
13564
05ed2f6a11ab
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13561
diff
changeset
|
460 |
"Modified: / 18-09-2013 / 15:20:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18327 | 461 |
"Modified: / 09-08-2018 / 10:32:11 / Claus Gittinger" |
18409 | 462 |
"Modified: / 21-09-2018 / 15:09:57 / sr" |
9979 | 463 |
! |
464 |
||
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
465 |
linesDeletedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
466 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
467 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
468 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
469 |
"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
|
470 |
"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
|
471 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
472 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
473 |
linesInsertedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
474 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
475 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
476 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
477 |
"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
|
478 |
"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
|
479 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
480 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
481 |
linesModifiedFrom: start to: end |
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 |
self highlightClear |
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 |
"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
|
486 |
"Created: / 16-09-2011 / 15:19:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 487 |
! ! |
488 |
||
489 |
!CodeNavigationService methodsFor:'initialization'! |
|
490 |
||
491 |
initialize |
|
492 |
||
493 |
super initialize. |
|
13109 | 494 |
|
495 |
"the following must only define a background - otherwise, syntax highlight fg is lost" |
|
9979 | 496 |
selectorEmphasis := self class defaultSelectorEmphasis. |
497 |
variableEmphasis := self class defaultVariableEmphasis. |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
498 |
assignmentEmphasis := self class defaultAssignmentEmphasis. |
10361 | 499 |
linesToRedraw := OrderedCollection new. |
9979 | 500 |
|
501 |
"Created: / 25-06-2010 / 14:05:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
502 |
! ! |
|
503 |
||
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
504 |
!CodeNavigationService methodsFor:'misc'! |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
505 |
|
15172
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
506 |
highlightClassVariable:name |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
507 |
"interface from browser (when a class var is selected)" |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
508 |
|
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
509 |
self highlightVariable:name isClassVariable:true |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
510 |
! |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
511 |
|
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
512 |
highlightInstanceVariable:name |
15172
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
513 |
"interface from browser (when an inst var is selected)" |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
514 |
|
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
515 |
self highlightVariable:name isClassVariable:false |
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 |
|
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
518 |
highlightVariable:name isClassVariable:isClassVariable |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
519 |
"interface from browser (when an inst or class var is selected)" |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
520 |
|
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
521 |
|element| |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
522 |
|
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
523 |
element := (codeView syntaxElements ? #()) |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
524 |
detect:[:e | |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
525 |
e isVariable |
15172
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
526 |
and:[ (isClassVariable |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
527 |
ifTrue:[e isClassVariable ] |
26249a020c0f
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
14448
diff
changeset
|
528 |
ifFalse:[e isInstanceVariable ]) |
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
529 |
and:[ e name = name ]] |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
530 |
] ifNone:nil. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
531 |
|
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
532 |
self highlightClear. |
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
533 |
codeView syntaxElementSelection:nil. |
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
534 |
self highlightVariable:element. |
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
535 |
! ! |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
536 |
|
9979 | 537 |
!CodeNavigationService methodsFor:'private'! |
538 |
||
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
539 |
elementAtCharacterPosition: pos |
18343 | 540 |
| elements low high mid midEl | |
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
541 |
|
18343 | 542 |
(elements := codeView syntaxElements) isEmptyOrNil ifTrue:[ ^ nil ]. |
543 |
||
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
544 |
low := 1. |
18343 | 545 |
high := elements size. |
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
546 |
|
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
547 |
[ low <= high ] whileTrue:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
548 |
mid := (low + high) >> 1. |
18343 | 549 |
midEl := elements at: mid. |
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
550 |
pos < midEl start ifTrue:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
551 |
high := mid - 1. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
552 |
] ifFalse:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
553 |
midEl stop < pos ifTrue:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
554 |
low := mid + 1. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
555 |
] ifFalse:[ |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
556 |
^ midEl |
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 |
]. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
560 |
^ nil. |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
561 |
|
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
562 |
"Created: / 15-02-2014 / 10:14:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18343 | 563 |
"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
|
564 |
! |
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
565 |
|
9979 | 566 |
elementAtCursor |
16294 | 567 |
^self elementAtLine: textView cursorLine col: textView cursorCol "- 1" |
9979 | 568 |
|
569 |
"Created: / 25-06-2010 / 14:39:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
570 |
! |
|
571 |
||
10631 | 572 |
elementAtLine:line col:colArg |
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
573 |
|col| |
10631 | 574 |
|
575 |
"/ if beyond end of line, do not advance into next line |
|
576 |
col := colArg min:(textView listAt:line) size. |
|
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
577 |
^ self elementAtCharacterPosition: (textView characterPositionOfLine:line col:col) |
9979 | 578 |
|
13946
458fb7b5c705
class: Tools::CodeNavigationService
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
13866
diff
changeset
|
579 |
"Created: / 15-02-2014 / 10:15:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 580 |
! |
581 |
||
582 |
elementAtX:x y:y |
|
583 |
|visibleLine line col| |
|
584 |
||
18343 | 585 |
codeView syntaxElements isEmptyOrNil ifTrue:[^nil]. |
10631 | 586 |
|
9979 | 587 |
visibleLine := textView visibleLineOfY:y. |
588 |
col := textView colOfX:x inVisibleLine:visibleLine. |
|
589 |
line := textView visibleLineToAbsoluteLine:visibleLine. |
|
590 |
^self elementAtLine:line col:col |
|
591 |
||
592 |
"Created: / 25-06-2010 / 14:52:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
593 |
"Modified: / 01-08-2010 / 08:50:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 594 |
"Modified: / 21-08-2011 / 10:26:08 / cg" |
18343 | 595 |
"Modified: / 22-08-2018 / 08:15:46 / Claus Gittinger" |
10631 | 596 |
! |
597 |
||
9979 | 598 |
highlighEmphasisFor: element |
599 |
||
10878 | 600 |
element isNil ifTrue:[^nil]. |
9979 | 601 |
|
10631 | 602 |
element isSelector ifTrue:[^selectorEmphasis]. |
603 |
element isVariable ifTrue:[^variableEmphasis]. |
|
604 |
element isSelf ifTrue:[^variableEmphasis]. |
|
9979 | 605 |
|
606 |
^nil |
|
607 |
||
608 |
"Created: / 25-06-2010 / 13:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 609 |
"Modified: / 18-11-2011 / 14:58:05 / cg" |
9979 | 610 |
! |
611 |
||
612 |
highlightClear |
|
613 |
||
10361 | 614 |
^self highlightClear: true. |
9979 | 615 |
|
616 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
|
617 |
"Created: / 25-06-2010 / 14:15:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10276 | 618 |
"Modified: / 08-07-2011 / 08:50:45 / cg" |
10361 | 619 |
"Modified: / 20-07-2011 / 18:52:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 620 |
! |
621 |
||
10361 | 622 |
highlightClear: redraw |
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
623 |
lastHighlightedElement := nil. |
10361 | 624 |
codeView syntaxElementSelection == nil ifTrue:[ ^ self ]. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
625 |
|
10878 | 626 |
textView list isNil ifTrue:[ ^ self ]. |
10361 | 627 |
textView list withIndexDo:[:line :lineNo | |
628 |
line isText ifTrue:[ |
|
629 |
(line hasEmphasis: currentEmphasis) ifTrue:[ |
|
630 |
line emphasisAllRemove:currentEmphasis. |
|
631 |
linesToRedraw add: lineNo. |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
632 |
] ifFalse:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
633 |
(currentEmphasisForAssign notNil and:[line hasEmphasis: currentEmphasisForAssign]) ifTrue:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
634 |
line emphasisAllRemove:currentEmphasisForAssign. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
635 |
linesToRedraw add: lineNo. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
636 |
] |
10361 | 637 |
] |
638 |
] |
|
639 |
]. |
|
640 |
codeView syntaxElementSelection:nil. |
|
641 |
||
642 |
redraw ifTrue:[self redrawLines]. |
|
9979 | 643 |
|
10361 | 644 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
645 |
"Created: / 20-07-2011 / 18:52:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 646 |
"Modified: / 18-11-2011 / 14:58:08 / cg" |
10361 | 647 |
! |
648 |
||
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
649 |
highlightElement:element |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
650 |
"walk through the chain of elements and highlight each |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
651 |
Notice, that the chain links elements for the same-variable |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
652 |
(and lists for same-named-but-in-different-scope variables have |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
653 |
already been separated)" |
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
654 |
|
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
655 |
|e firstElement savedEmphasis currentSelection highlightSingle| |
10631 | 656 |
|
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
657 |
(currentSelection := codeView syntaxElementSelection) == element ifTrue:[ ^ self ]. "/ no change |
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
658 |
currentSelection notNil ifTrue:[ |
10631 | 659 |
self highlightClear: false. |
660 |
]. |
|
10361 | 661 |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
662 |
currentEmphasis := savedEmphasis := self highlighEmphasisFor:element. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
663 |
currentEmphasisForAssign := nil. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
664 |
|
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
665 |
highlightSingle := |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
666 |
[:element | |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
667 |
|start stop| |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
668 |
|
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
669 |
start := element start. |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
670 |
stop := element stop. |
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
671 |
|
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
672 |
element assigned ifTrue:[ |
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
673 |
[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
674 |
currentEmphasis := currentEmphasisForAssign := assignmentEmphasis. |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
675 |
self highlightWithoutClearFrom:start to:stop. |
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
676 |
] ensure:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
677 |
currentEmphasis := savedEmphasis. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
678 |
]. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
679 |
] ifFalse:[ |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
680 |
self highlightWithoutClearFrom:start to:stop. |
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
681 |
]. |
13534
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 |
|
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
684 |
element notNil ifTrue:[ |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
685 |
codeView syntaxElementSelection:element. |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
686 |
e := firstElement := element firstElementInChain. |
13534
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
687 |
|
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
688 |
"/ 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
|
689 |
"/ 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
|
690 |
"/ redraw in some situations) |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
691 |
"/ can someone check this? |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
692 |
false ifTrue:[ |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
693 |
e == lastHighlightedElement ifTrue:[ |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
694 |
"/ same chain |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
695 |
highlightSingle value:element. |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
696 |
^ self |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
697 |
]. |
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
698 |
lastHighlightedElement := e. "/ remember |
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 |
|
e9982215307d
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13533
diff
changeset
|
701 |
[ e notNil ] whileTrue:[ |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
702 |
"/ cg: suppress variables with same name, but in different blocks |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
703 |
"/ (e isVariable not or:[ e isInSameBlockScopeAs:firstElement]) ifTrue:[ |
15458
c910159068d9
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15325
diff
changeset
|
704 |
highlightSingle value:e. |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
705 |
"/ ]. |
10631 | 706 |
e := e nextElement |
707 |
]. |
|
708 |
]. |
|
10361 | 709 |
self redrawLines. |
9979 | 710 |
|
711 |
"Created: / 14-02-2010 / 16:18:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10361 | 712 |
"Modified: / 20-07-2011 / 18:52:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10631 | 713 |
"Modified: / 21-08-2011 / 10:22:58 / cg" |
9979 | 714 |
! |
715 |
||
716 |
highlightElementAtCursor |
|
717 |
self highlightElementAtLine: textView cursorLine col: textView cursorCol |
|
718 |
||
719 |
"Created: / 14-02-2010 / 16:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
720 |
"Modified: / 06-03-2010 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
721 |
! |
|
722 |
||
723 |
highlightElementAtLine:line col:col |
|
13866 | 724 |
|elementOrNil| |
9979 | 725 |
|
13866 | 726 |
elementOrNil := self elementAtLine: line col: col. |
13536
c7a7ca8afcdd
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
13534
diff
changeset
|
727 |
self highlightElement:elementOrNil |
9979 | 728 |
|
729 |
"Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13866 | 730 |
"Modified: / 02-10-2013 / 01:29:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 731 |
! |
732 |
||
733 |
highlightElementAtX:x y:y |
|
14004
ee41e156d189
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
13946
diff
changeset
|
734 |
|elementOrNil| |
9979 | 735 |
|
14004
ee41e156d189
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
13946
diff
changeset
|
736 |
elementOrNil := self elementAtX:x y:y. |
ee41e156d189
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
13946
diff
changeset
|
737 |
self highlightElement:elementOrNil |
9979 | 738 |
|
739 |
"Created: / 14-02-2010 / 16:12:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
740 |
"Modified: / 06-03-2010 / 20:06:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 741 |
"Modified: / 21-08-2011 / 10:22:10 / cg" |
742 |
! |
|
743 |
||
744 |
highlightElementOrNil:e |
|
745 |
e notNil ifTrue:[ |
|
746 |
"/ cg: only if selected !! |
|
747 |
"/ self halt. |
|
748 |
self highlightElement:e. |
|
749 |
] ifFalse:[ |
|
750 |
self highlightClear |
|
751 |
]. |
|
752 |
||
753 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
754 |
"Created: / 21-08-2011 / 09:56:39 / cg" |
|
9979 | 755 |
! |
756 |
||
757 |
highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol |
|
758 |
|line start end| |
|
759 |
||
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
760 |
(lineNo between:startLine and:endLine) ifFalse:[ ^ self ]. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
761 |
|
9979 | 762 |
line := textView listAt:lineNo. |
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
763 |
line isEmpty ifTrue:[^self]. |
15470
e59f6dc9d610
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
15458
diff
changeset
|
764 |
|
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
765 |
start := (lineNo = startLine) |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
766 |
ifTrue:[ startCol ] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
767 |
ifFalse:[ line indexOfNonSeparator ]. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
768 |
end := (lineNo = endLine) |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
769 |
ifTrue:[ endCol ] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
770 |
ifFalse:[ line size ]. |
13866 | 771 |
line setRuns:(line runs asArray). |
772 |
"/ JV: CG commented following and added the commtent code below. |
|
773 |
"/ however, this clear all other emphasis like bold, color and so on!! |
|
774 |
line |
|
13109 | 775 |
emphasisFrom:(start max: 1) |
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
776 |
to:(end min: line size) |
13109 | 777 |
add: currentEmphasis. |
13866 | 778 |
"/ line |
779 |
"/ emphasizeFrom:(start max: 1) |
|
780 |
"/ to:(end min: line size) |
|
781 |
"/ with: currentEmphasis. |
|
782 |
line setRuns:(line runs asRunArray). |
|
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
783 |
|
10361 | 784 |
linesToRedraw add: lineNo. |
9979 | 785 |
|
786 |
"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
|
787 |
"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
|
788 |
"Modified: / 25-02-2014 / 21:01:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 789 |
! |
790 |
||
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
791 |
highlightVariable:element |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
792 |
(element notNil and:[ element isVariableOrSelf ]) ifTrue:[ |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
793 |
self highlightElement:element. |
9979 | 794 |
] ifFalse:[ |
795 |
self highlightClear. |
|
10361 | 796 |
]. |
797 |
||
798 |
"Modified: / 20-07-2011 / 18:54:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 799 |
"Modified: / 21-08-2011 / 09:39:42 / cg" |
9979 | 800 |
! |
801 |
||
802 |
highlightVariableAtCursor |
|
10631 | 803 |
self highlightElementOrNil:(self elementAtCursor) |
9979 | 804 |
|
805 |
"Modified: / 25-06-2010 / 14:53:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 806 |
"Modified: / 21-08-2011 / 09:56:56 / cg" |
9979 | 807 |
! |
808 |
||
809 |
highlightVariableAtX:x y:y |
|
10631 | 810 |
self highlightElementOrNil:(self elementAtX:x y:y). |
9979 | 811 |
|
812 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 813 |
"Modified: / 21-08-2011 / 10:24:50 / cg" |
9979 | 814 |
! |
815 |
||
816 |
highlightWithoutClearFrom: start to: end |
|
817 |
"Remove underlined emphasis" |
|
818 |
||
819 |
|startLine startCol endLine endCol| |
|
820 |
||
821 |
startLine := textView lineOfCharacterPosition:start. |
|
822 |
startCol := start - (textView characterPositionOfLine:startLine col:1) + 1. |
|
823 |
endLine := textView lineOfCharacterPosition:end. |
|
824 |
endCol := end - (textView characterPositionOfLine:endLine col:1) + 1. |
|
825 |
self highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
826 |
||
827 |
"Created: / 25-06-2010 / 14:15:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
828 |
! |
|
829 |
||
830 |
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
831 |
||
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
832 |
textView list keysAndValuesDo: [:lineNo :line| |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
833 |
line isText ifTrue: [ |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
834 |
self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
835 |
] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
836 |
]. |
9979 | 837 |
|
838 |
"Created: / 25-06-2010 / 14:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
839 |
! ! |
|
840 |
||
10361 | 841 |
!CodeNavigationService methodsFor:'redrawing'! |
842 |
||
843 |
redrawLines |
|
844 |
linesToRedraw do:[:lineNo| |
|
10588 | 845 |
textView invalidateLine: lineNo. |
10361 | 846 |
]. |
12997
f03191d56013
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12994
diff
changeset
|
847 |
linesToRedraw := OrderedCollection new |
10361 | 848 |
|
849 |
"Created: / 20-07-2011 / 18:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10588 | 850 |
"Modified (format): / 18-08-2011 / 16:01:34 / cg" |
10361 | 851 |
! ! |
852 |
||
9979 | 853 |
!CodeNavigationService class methodsFor:'documentation'! |
854 |
||
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
855 |
version |
16294 | 856 |
^ '$Header$' |
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
857 |
! |
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
858 |
|
9979 | 859 |
version_CVS |
16294 | 860 |
^ '$Header$' |
9979 | 861 |
! |
862 |
||
863 |
version_SVN |
|
16294 | 864 |
^ '$Id$' |
9979 | 865 |
! ! |
12105
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
866 |