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