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