author | Claus Gittinger <cg@exept.de> |
Mon, 24 Jun 2013 19:09:03 +0200 | |
changeset 12994 | 0899f74ec3ce |
parent 12986 | 145d28bf105e |
child 12997 | f03191d56013 |
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 |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
31 |
instanceVariableNames:'selectorEmphasis variableEmphasis currentEmphasis |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
32 |
currentEmphasisForAssign linesToRedraw menuShown |
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 |
|
73 |
||
74 |
"Answers short label - for UI" |
|
75 |
||
76 |
^'Semi-modal Code Navigation' |
|
77 |
||
78 |
"Created: / 07-03-2010 / 14:00:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10412 | 79 |
! |
80 |
||
81 |
requiredServices |
|
82 |
||
83 |
^#(#'Tools::CodeHighlightingService') |
|
84 |
||
85 |
"Created: / 27-07-2011 / 11:40:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9979 | 86 |
! ! |
87 |
||
88 |
!CodeNavigationService class methodsFor:'accessing - defaults'! |
|
89 |
||
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
90 |
defaultAssignmentEmphasis |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
91 |
DefaultAssignmentEmphasis isNil ifTrue:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
92 |
^ Array with:(#backgroundColor -> (UserPreferences current assignmentBackgroundColorForNavigationService)) |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
93 |
]. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
94 |
^ DefaultAssignmentEmphasis |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
95 |
! |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
96 |
|
9979 | 97 |
defaultSelectorEmphasis |
10631 | 98 |
DefaultSelectorEmphasis isNil ifTrue:[ |
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
99 |
^ Array with:(#backgroundColor -> (UserPreferences current selectorBackgroundColorForNavigationService)) |
10631 | 100 |
]. |
101 |
^ DefaultSelectorEmphasis |
|
102 |
||
103 |
"Modified: / 21-08-2011 / 09:58:18 / cg" |
|
9979 | 104 |
! |
105 |
||
106 |
defaultVariableEmphasis |
|
10631 | 107 |
DefaultVariableEmphasis isNil ifTrue:[ |
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
108 |
^ Array with:(#backgroundColor -> (UserPreferences current variableBackgroundColorForNavigationService)) |
10631 | 109 |
]. |
110 |
^ DefaultVariableEmphasis |
|
9979 | 111 |
|
112 |
"Created: / 25-06-2010 / 13:56:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 113 |
"Modified: / 21-08-2011 / 11:04:20 / cg" |
9979 | 114 |
! ! |
115 |
||
10651 | 116 |
!CodeNavigationService methodsFor:'change & update'! |
117 |
||
118 |
update: aspect with: param from: sender |
|
10661 | 119 |
sender == textView modifiedChannel ifTrue:[ |
120 |
codeView reallyModified ifTrue:[ |
|
121 |
"/ no longer highlight - the info is wrong anyway !! |
|
122 |
self highlightClear. |
|
123 |
]. |
|
124 |
]. |
|
125 |
||
10653 | 126 |
"JV: I changed 'halt' to 'breakPoint: #cg'" |
10651 | 127 |
|
128 |
"Created: / 22-08-2011 / 16:22:19 / cg" |
|
10653 | 129 |
"Modified: / 25-08-2011 / 15:10:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10661 | 130 |
"Modified: / 05-09-2011 / 05:15:42 / cg" |
10651 | 131 |
! ! |
132 |
||
9979 | 133 |
!CodeNavigationService methodsFor:'code services'! |
134 |
||
10631 | 135 |
browseClass:class |
136 |
self browser isNil ifTrue:[ ^ NewSystemBrowser browseClass:class ]. |
|
9979 | 137 |
(UserPreferences current alwaysOpenNewTabWhenCtrlClick |
10631 | 138 |
or:[ self browser navigationState modified ]) |
139 |
ifTrue:[ |
|
140 |
self browser |
|
141 |
spawnFullBrowserInClass:class |
|
142 |
selector:nil |
|
143 |
in:#newBuffer |
|
144 |
] |
|
145 |
ifFalse:[ self browser switchToClass:class ] |
|
9979 | 146 |
|
147 |
"Created: / 15-02-2010 / 09:36:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
148 |
"Modified: / 25-07-2010 / 11:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 149 |
"Modified: / 21-08-2011 / 10:07:30 / cg" |
9979 | 150 |
! |
151 |
||
152 |
browser |
|
153 |
||
154 |
^codeView browserHolder value |
|
155 |
||
156 |
"Created: / 06-03-2010 / 21:14:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
157 |
! ! |
|
158 |
||
159 |
!CodeNavigationService methodsFor:'event handling'! |
|
160 |
||
161 |
button1Press |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
162 |
|element| |
9979 | 163 |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
164 |
(element := codeView syntaxElementSelection) notNil ifTrue:[ |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
165 |
element type == #selector ifTrue:[self button1PressForSelector: element value. ^true]. |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
166 |
element type == #class ifTrue:[self browseClass:element value. ^true]. |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
167 |
]. |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
168 |
^ false |
9979 | 169 |
|
170 |
"Created: / 14-02-2010 / 18:43:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
171 |
"Modified: / 06-03-2010 / 21:11:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 172 |
"Modified: / 18-11-2011 / 14:58:02 / cg" |
9979 | 173 |
! |
174 |
||
175 |
button1PressForSelector: selector |
|
12867 | 176 |
| impls | |
9979 | 177 |
|
10254 | 178 |
impls := codeView implementorsOf: selector. |
10631 | 179 |
"/ impls size = 1 ifTrue:[^codeView browseMethod: impls anyOne]. |
12867 | 180 |
[ |
181 |
menuShown := codeView implementorsMenu: impls selector: selector. |
|
182 |
self highlightClear. |
|
183 |
menuShown showAtPointer. |
|
184 |
] ensure:[ |
|
185 |
menuShown := nil |
|
186 |
]. |
|
9979 | 187 |
|
188 |
"Created: / 14-02-2010 / 18:50:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10254 | 189 |
"Modified: / 30-06-2011 / 19:34:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10271 | 190 |
"Modified: / 07-07-2011 / 17:16:23 / jv" |
10631 | 191 |
"Modified: / 21-08-2011 / 11:06:08 / cg" |
9979 | 192 |
! |
193 |
||
194 |
button2Press |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
195 |
| element | |
9979 | 196 |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
197 |
(element := codeView syntaxElementSelection) notNil ifTrue:[ |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
198 |
element type == #selector ifTrue:[self button2PressForSelector: element value. ^ true]. |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
199 |
]. |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
200 |
^ false |
9979 | 201 |
|
202 |
"Created: / 14-02-2010 / 18:43:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
203 |
"Modified: / 17-06-2011 / 08:58:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
204 |
! |
|
205 |
||
206 |
button2PressForSelector: selector |
|
12867 | 207 |
| senders | |
9979 | 208 |
|
10631 | 209 |
senders := codeView sendersOf: selector. |
210 |
"/ senders size = 1 ifTrue:[ codeView browseMethod: senders anyOne. ^ self]. |
|
12867 | 211 |
[ |
212 |
menuShown := codeView sendersMenu: senders selector: selector. |
|
213 |
self highlightClear. |
|
214 |
menuShown showAtPointer. |
|
215 |
] ensure:[ |
|
216 |
menuShown := nil. |
|
217 |
]. |
|
9979 | 218 |
|
219 |
"Created: / 14-02-2010 / 18:50:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10254 | 220 |
"Modified: / 30-06-2011 / 19:34:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10631 | 221 |
"Modified: / 21-08-2011 / 11:34:49 / cg" |
9979 | 222 |
! |
223 |
||
10631 | 224 |
buttonMotion:button x:x y:y in:view |
9979 | 225 |
"Handles an event in given view (a subview of codeView). |
226 |
If the method returns true, the event will not be processed |
|
227 |
by the view." |
|
10631 | 228 |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
229 |
(view == textView and:[ textView sensor metaDown ]) ifTrue:[ |
10631 | 230 |
self highlightElementAtX:x y:y. |
231 |
^ true |
|
232 |
]. |
|
233 |
^ false |
|
9979 | 234 |
|
235 |
"Created: / 06-03-2010 / 20:40:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 236 |
"Modified (format): / 21-08-2011 / 10:07:15 / cg" |
9979 | 237 |
! |
238 |
||
239 |
buttonPress: button x:x y:y in: view |
|
240 |
||
241 |
"Handles an event in given view (a subview of codeView). |
|
242 |
If the method returns true, the event will not be processed |
|
243 |
by the view." |
|
244 |
||
10631 | 245 |
(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
|
246 |
textView isQuickMenuModifierPressed ifTrue:[ |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
247 |
button == 1 ifTrue: [^self button1Press]. |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
248 |
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
|
249 |
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
|
250 |
] ifFalse:[ |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
251 |
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
|
252 |
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
|
253 |
] |
9979 | 254 |
] |
10631 | 255 |
]. |
9979 | 256 |
^false |
257 |
||
258 |
"Created: / 06-03-2010 / 21:12:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
259 |
"Modified: / 25-06-2010 / 14:53:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 260 |
"Modified (format): / 21-08-2011 / 10:06:54 / cg" |
9979 | 261 |
! |
262 |
||
12867 | 263 |
buttonRelease: button x:x y:y in: view |
264 |
"Handles an event in given view (a subview of codeView). |
|
265 |
If the method returns true, the event will not be processed |
|
266 |
by the view." |
|
267 |
||
268 |
"/ if I show a quick senders/implementors menu, eat this event |
|
269 |
^ menuShown notNil |
|
270 |
! |
|
271 |
||
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
272 |
isQuickMenuModifierPressed |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
273 |
|sensor| |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
274 |
|
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
275 |
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
|
276 |
UserPreferences current codeView2QuickSendersAndImplementorsOnControl ifTrue:[ |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
277 |
^ sensor ctrlDown |
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
278 |
]. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
279 |
^ sensor metaDown |
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
280 |
! |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
281 |
|
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
282 |
isQuickMenuModifierReleased |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
283 |
|sensor| |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
284 |
|
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
285 |
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
|
286 |
UserPreferences current codeView2QuickSendersAndImplementorsOnControl ifTrue:[ |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
287 |
^ 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
|
288 |
]. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
289 |
^ 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
|
290 |
! |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
291 |
|
9979 | 292 |
keyPress:key x:x y:y in:view |
293 |
"Handles an event in given view (a subview of codeView). |
|
10588 | 294 |
If the method returns true, it has eaten the event and it will not be processed |
9979 | 295 |
by the view." |
10588 | 296 |
|
12105
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
297 |
<resource: #keyboard (#Control_L #Ctrl |
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
298 |
#CursorRight #CursorDown #CursorLeft #CursorUp)> |
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
299 |
|
10631 | 300 |
|ev p| |
301 |
||
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
302 |
(view == textView) ifTrue:[ |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
303 |
"/ ("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
|
304 |
(textView isQuickMenuModifierPressed) ifTrue:[ |
10631 | 305 |
"/ because it is delegated, the position is not correct |
306 |
ev := WindowGroup lastEventQuerySignal query. |
|
307 |
p := view device translatePoint:(ev x @ ev y) fromView:ev view toView:view. |
|
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
308 |
view sensor |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
309 |
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
|
310 |
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
|
311 |
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
|
312 |
^ false "/ true. -- no, dont eat the key |
9979 | 313 |
]. |
10661 | 314 |
|
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
315 |
"/ codeView reallyModified "textView modified" ifTrue:[ |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
316 |
"/ self highlightClear. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
317 |
"/ codeView syntaxElements: nil. |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
318 |
"/ ^ false |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
319 |
"/ ]. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
320 |
|
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
321 |
view sensor metaDown ifTrue:[ |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
322 |
(key == #CursorRight or:[key == #CursorDown]) ifTrue:[ |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
323 |
view sensor pushUserEvent:#findNextVariableFromCursor for:self. |
12930
658aaa9b2245
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
12913
diff
changeset
|
324 |
] ifFalse:[(key == #CursorLeft or:[key == #CursorUp]) ifTrue:[ |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
325 |
view sensor pushUserEvent:#findPreviousVariableFromCursor for:self. |
12930
658aaa9b2245
class: Tools::CodeNavigationService
Stefan Vogel <sv@exept.de>
parents:
12913
diff
changeset
|
326 |
]]. |
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
327 |
] ifFalse:[ |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
328 |
(key == #CursorRight |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
329 |
or:[key == #CursorDown |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
330 |
or:[key == #CursorLeft |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
331 |
or:[key == #CursorUp]]] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
332 |
) ifTrue:[ |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
333 |
view sensor pushUserEvent:#highlightVariableAtCursor for:self . |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
334 |
] ifFalse:[ |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
335 |
view sensor pushUserEvent:#highlightClear for:self . |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
336 |
] |
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
337 |
] |
9979 | 338 |
]. |
339 |
^ false |
|
340 |
||
341 |
"Created: / 06-03-2010 / 20:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10661 | 342 |
"Modified: / 05-09-2011 / 05:17:30 / cg" |
10727 | 343 |
"Modified: / 27-09-2011 / 19:24:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 344 |
! |
345 |
||
346 |
keyRelease: key x:x y:y in: view |
|
347 |
"Handles an event in given view (a subview of codeView). |
|
10588 | 348 |
If the method returns true, it has eaten the event and it will not be processed |
9979 | 349 |
by the view." |
350 |
||
10631 | 351 |
|ev p| |
352 |
||
12353
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
353 |
(view == textView and:[textView isQuickMenuModifierReleased]) ifTrue:[ |
9d725076871b
changed default for Jan's quick menus to use the ALT button isntead
Claus Gittinger <cg@exept.de>
parents:
12105
diff
changeset
|
354 |
"/ (view == textView and:[key == #'Control_L' or:[key == #Ctrl]]) ifTrue:[ |
10631 | 355 |
"/ because it is delegated, the position is not correct |
356 |
ev := WindowGroup lastEventQuerySignal query. |
|
357 |
p := view device translatePoint:(ev x @ ev y) fromView:ev view toView:view. |
|
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
358 |
"/ self highlightClear. |
10631 | 359 |
"/ view sensor pushUserEvent:#highlightClear for: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
|
360 |
^ false "/ true -- do not eat the event |
10588 | 361 |
]. |
362 |
^ false |
|
9979 | 363 |
|
364 |
"Created: / 06-03-2010 / 21:03:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 365 |
"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
|
366 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
367 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
368 |
linesDeletedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
369 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
370 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
371 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
372 |
"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
|
373 |
"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
|
374 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
375 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
376 |
linesInsertedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
377 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
378 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
379 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
380 |
"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
|
381 |
"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
|
382 |
! |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
383 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
384 |
linesModifiedFrom: start to: end |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
385 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
386 |
self highlightClear |
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
387 |
|
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
388 |
"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
|
389 |
"Created: / 16-09-2011 / 15:19:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 390 |
! ! |
391 |
||
392 |
!CodeNavigationService methodsFor:'initialization'! |
|
393 |
||
394 |
initialize |
|
395 |
||
396 |
super initialize. |
|
397 |
selectorEmphasis := self class defaultSelectorEmphasis. |
|
398 |
variableEmphasis := self class defaultVariableEmphasis. |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
399 |
assignmentEmphasis := self class defaultAssignmentEmphasis. |
10361 | 400 |
linesToRedraw := OrderedCollection new. |
9979 | 401 |
|
402 |
"Created: / 25-06-2010 / 14:05:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
403 |
! ! |
|
404 |
||
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
405 |
!CodeNavigationService methodsFor:'misc'! |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
406 |
|
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
407 |
highlightInstanceVariable:name |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
408 |
|element| |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
409 |
|
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
410 |
element := (codeView syntaxElements ? #()) |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
411 |
detect:[:e | |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
412 |
e isVariable |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
413 |
and:[ e isInstanceVariable |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
414 |
and:[ e name = name ]] |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
415 |
] ifNone:nil. |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
416 |
element notNil ifTrue:[ |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
417 |
codeView syntaxElementSelection:nil. |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
418 |
self highlightVariable:element |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
419 |
]. |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
420 |
! ! |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
421 |
|
9979 | 422 |
!CodeNavigationService methodsFor:'private'! |
423 |
||
424 |
elementAtCursor |
|
425 |
^self elementAtLine: textView cursorLine col: textView cursorCol - 1 |
|
426 |
||
427 |
"Created: / 25-06-2010 / 14:39:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
428 |
! |
|
429 |
||
10631 | 430 |
elementAtLine:line col:colArg |
11740 | 431 |
|characterPosition syntaxElements index element col| |
10631 | 432 |
|
433 |
"/ if beyond end of line, do not advance into next line |
|
434 |
col := colArg min:(textView listAt:line) size. |
|
9979 | 435 |
|
436 |
characterPosition := textView characterPositionOfLine:line col:col. |
|
11740 | 437 |
syntaxElements := codeView syntaxElements. |
11741 | 438 |
syntaxElements isEmptyOrNil ifTrue:[ |
439 |
^ nil. |
|
440 |
]. |
|
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
441 |
0"1" to:0 by:-1 do:[:d | |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
442 |
index := (syntaxElements indexForInserting:characterPosition) - d. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
443 |
index > syntaxElements size ifTrue:[^nil]. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
444 |
element := syntaxElements at:index ifAbsent:nil. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
445 |
element notNil ifTrue:[ |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
446 |
(characterPosition between: element start - 1 and: element stop) ifTrue:[^element]. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
447 |
]. |
10631 | 448 |
]. |
449 |
^nil |
|
9979 | 450 |
|
451 |
"Created: / 25-06-2010 / 14:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 452 |
"Modified: / 21-08-2011 / 11:03:29 / cg" |
10709
e3257bcab5de
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10661
diff
changeset
|
453 |
"Modified: / 16-09-2011 / 17:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 454 |
! |
455 |
||
456 |
elementAtX:x y:y |
|
457 |
|visibleLine line col| |
|
458 |
||
10631 | 459 |
codeView syntaxElements isNil ifTrue:[^nil]. |
460 |
||
9979 | 461 |
visibleLine := textView visibleLineOfY:y. |
462 |
col := textView colOfX:x inVisibleLine:visibleLine. |
|
463 |
line := textView visibleLineToAbsoluteLine:visibleLine. |
|
464 |
^self elementAtLine:line col:col |
|
465 |
||
466 |
"Created: / 25-06-2010 / 14:52:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
467 |
"Modified: / 01-08-2010 / 08:50:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 468 |
"Modified: / 21-08-2011 / 10:26:08 / cg" |
469 |
! |
|
470 |
||
471 |
foo |
|
472 |
|characterPosition index element | |
|
473 |
||
474 |
characterPosition := 1 |
|
475 |
||
476 |
"Created: / 21-08-2011 / 10:48:05 / cg" |
|
9979 | 477 |
! |
478 |
||
479 |
highlighEmphasisFor: element |
|
480 |
||
10878 | 481 |
element isNil ifTrue:[^nil]. |
9979 | 482 |
|
10631 | 483 |
element isSelector ifTrue:[^selectorEmphasis]. |
484 |
element isVariable ifTrue:[^variableEmphasis]. |
|
485 |
element isSelf ifTrue:[^variableEmphasis]. |
|
9979 | 486 |
|
487 |
^nil |
|
488 |
||
489 |
"Created: / 25-06-2010 / 13:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 490 |
"Modified: / 18-11-2011 / 14:58:05 / cg" |
9979 | 491 |
! |
492 |
||
493 |
highlightClear |
|
494 |
||
10361 | 495 |
^self highlightClear: true. |
9979 | 496 |
|
497 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
|
498 |
"Created: / 25-06-2010 / 14:15:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10276 | 499 |
"Modified: / 08-07-2011 / 08:50:45 / cg" |
10361 | 500 |
"Modified: / 20-07-2011 / 18:52:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 501 |
! |
502 |
||
10361 | 503 |
highlightClear: redraw |
504 |
||
505 |
codeView syntaxElementSelection == nil ifTrue:[ ^ self ]. |
|
10878 | 506 |
textView list isNil ifTrue:[ ^ self ]. |
10361 | 507 |
textView list withIndexDo:[:line :lineNo | |
508 |
line isText ifTrue:[ |
|
509 |
(line hasEmphasis: currentEmphasis) ifTrue:[ |
|
510 |
line emphasisAllRemove:currentEmphasis. |
|
511 |
linesToRedraw add: lineNo. |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
512 |
] ifFalse:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
513 |
(currentEmphasisForAssign notNil and:[line hasEmphasis: currentEmphasisForAssign]) ifTrue:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
514 |
line emphasisAllRemove:currentEmphasisForAssign. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
515 |
linesToRedraw add: lineNo. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
516 |
] |
10361 | 517 |
] |
518 |
] |
|
519 |
]. |
|
520 |
codeView syntaxElementSelection:nil. |
|
521 |
||
522 |
redraw ifTrue:[self redrawLines]. |
|
9979 | 523 |
|
10361 | 524 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
525 |
"Created: / 20-07-2011 / 18:52:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 526 |
"Modified: / 18-11-2011 / 14:58:08 / cg" |
10361 | 527 |
! |
528 |
||
529 |
highlightElement:element |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
530 |
|e savedEmphasis| |
10631 | 531 |
|
532 |
codeView syntaxElementSelection == element ifTrue:[ ^ self ]. "/ no change |
|
533 |
codeView syntaxElementSelection notNil ifTrue:[ |
|
534 |
self highlightClear: false. |
|
535 |
]. |
|
10361 | 536 |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
537 |
currentEmphasis := savedEmphasis := self highlighEmphasisFor:element. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
538 |
currentEmphasisForAssign := nil. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
539 |
|
10631 | 540 |
element notNil ifTrue:[ |
541 |
codeView syntaxElementSelection:element. |
|
542 |
e := element firstElementInChain. |
|
543 |
[ e notNil ] whileTrue:[ |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
544 |
e assigned ifTrue:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
545 |
[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
546 |
currentEmphasis := currentEmphasisForAssign := assignmentEmphasis. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
547 |
self highlightWithoutClearFrom:e start to:e stop. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
548 |
] ensure:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
549 |
currentEmphasis := savedEmphasis. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
550 |
]. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
551 |
] ifFalse:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
552 |
self highlightWithoutClearFrom:e start to:e stop. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
553 |
]. |
10631 | 554 |
e := e nextElement |
555 |
]. |
|
556 |
]. |
|
10361 | 557 |
self redrawLines. |
9979 | 558 |
|
559 |
"Created: / 14-02-2010 / 16:18:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10361 | 560 |
"Modified: / 20-07-2011 / 18:52:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10631 | 561 |
"Modified: / 21-08-2011 / 10:22:58 / cg" |
9979 | 562 |
! |
563 |
||
564 |
highlightElementAtCursor |
|
565 |
self highlightElementAtLine: textView cursorLine col: textView cursorCol |
|
566 |
||
567 |
"Created: / 14-02-2010 / 16:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
568 |
"Modified: / 06-03-2010 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
569 |
! |
|
570 |
||
571 |
highlightElementAtLine:line col:col |
|
11740 | 572 |
|characterPosition syntaxElements index element| |
9979 | 573 |
|
574 |
characterPosition := textView characterPositionOfLine:line col:col. |
|
11740 | 575 |
syntaxElements := codeView syntaxElements. |
11741 | 576 |
syntaxElements isEmptyOrNil ifTrue:[self highlightElement:nil. ^ self]. |
11740 | 577 |
index := syntaxElements indexForInserting:characterPosition. |
578 |
index > syntaxElements size ifTrue:[self highlightElement:nil. ^ self]. |
|
579 |
element := syntaxElements at:index. |
|
580 |
(characterPosition between: element start and: element stop) ifFalse:[element := nil]. |
|
9979 | 581 |
self highlightElement:element |
582 |
||
583 |
"Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
584 |
"Modified: / 01-08-2010 / 08:50:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
585 |
! |
|
586 |
||
587 |
highlightElementAtX:x y:y |
|
588 |
|visibleLine line col| |
|
589 |
||
10631 | 590 |
codeView syntaxElements isNil ifTrue:[^self]. |
9979 | 591 |
visibleLine := textView visibleLineOfY:y. |
592 |
col := textView colOfX:x inVisibleLine:visibleLine. |
|
593 |
line := textView visibleLineToAbsoluteLine:visibleLine. |
|
594 |
self highlightElementAtLine:line col:col |
|
595 |
||
596 |
"Created: / 14-02-2010 / 16:12:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
597 |
"Modified: / 06-03-2010 / 20:06:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 598 |
"Modified: / 21-08-2011 / 10:22:10 / cg" |
599 |
! |
|
600 |
||
601 |
highlightElementOrNil:e |
|
602 |
e notNil ifTrue:[ |
|
603 |
"/ cg: only if selected !! |
|
604 |
"/ self halt. |
|
605 |
self highlightElement:e. |
|
606 |
] ifFalse:[ |
|
607 |
self highlightClear |
|
608 |
]. |
|
609 |
||
610 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
611 |
"Created: / 21-08-2011 / 09:56:39 / cg" |
|
9979 | 612 |
! |
613 |
||
614 |
highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol |
|
615 |
|line start end| |
|
616 |
||
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
617 |
(lineNo between:startLine and:endLine) ifFalse:[ ^ self ]. |
9979 | 618 |
line := textView listAt:lineNo. |
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
619 |
line isEmpty ifTrue:[^self]. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
620 |
start := (lineNo = startLine) |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
621 |
ifTrue:[ startCol ] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
622 |
ifFalse:[ line indexOfNonSeparator ]. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
623 |
end := (lineNo = endLine) |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
624 |
ifTrue:[ endCol ] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
625 |
ifFalse:[ line size ]. |
9979 | 626 |
line |
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
627 |
emphasisFrom:(start max: 1) |
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
628 |
to:(end min: line size) |
10361 | 629 |
add: currentEmphasis. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
630 |
|
10361 | 631 |
linesToRedraw add: lineNo. |
9979 | 632 |
|
633 |
"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
|
634 |
"Modified: / 08-07-2011 / 13:02:51 / cg" |
10361 | 635 |
"Modified: / 20-07-2011 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 636 |
! |
637 |
||
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
638 |
highlightVariable:element |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
639 |
(element notNil and:[ element isVariableOrSelf ]) ifTrue:[ |
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
640 |
self highlightElement:element. |
9979 | 641 |
] ifFalse:[ |
642 |
self highlightClear. |
|
10361 | 643 |
]. |
644 |
||
645 |
"Modified: / 20-07-2011 / 18:54:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 646 |
"Modified: / 21-08-2011 / 09:39:42 / cg" |
9979 | 647 |
! |
648 |
||
649 |
highlightVariableAtCursor |
|
10631 | 650 |
self highlightElementOrNil:(self elementAtCursor) |
9979 | 651 |
|
652 |
"Modified: / 25-06-2010 / 14:53:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 653 |
"Modified: / 21-08-2011 / 09:56:56 / cg" |
9979 | 654 |
! |
655 |
||
656 |
highlightVariableAtX:x y:y |
|
10631 | 657 |
self highlightElementOrNil:(self elementAtX:x y:y). |
9979 | 658 |
|
659 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 660 |
"Modified: / 21-08-2011 / 10:24:50 / cg" |
9979 | 661 |
! |
662 |
||
663 |
highlightWithoutClearFrom: start to: end |
|
664 |
"Remove underlined emphasis" |
|
665 |
||
666 |
|startLine startCol endLine endCol| |
|
667 |
||
668 |
startLine := textView lineOfCharacterPosition:start. |
|
669 |
startCol := start - (textView characterPositionOfLine:startLine col:1) + 1. |
|
670 |
endLine := textView lineOfCharacterPosition:end. |
|
671 |
endCol := end - (textView characterPositionOfLine:endLine col:1) + 1. |
|
672 |
self highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
673 |
||
674 |
"Created: / 25-06-2010 / 14:15:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
675 |
! |
|
676 |
||
677 |
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
678 |
||
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
679 |
textView list keysAndValuesDo: [:lineNo :line| |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
680 |
line isText ifTrue: [ |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
681 |
self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
682 |
] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
683 |
]. |
9979 | 684 |
|
685 |
"Created: / 25-06-2010 / 14:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
686 |
! ! |
|
687 |
||
10361 | 688 |
!CodeNavigationService methodsFor:'redrawing'! |
689 |
||
690 |
redrawLines |
|
691 |
linesToRedraw do:[:lineNo| |
|
10588 | 692 |
textView invalidateLine: lineNo. |
10361 | 693 |
]. |
694 |
linesToRedraw := OrderedCollection new: 1 |
|
695 |
||
696 |
"Created: / 20-07-2011 / 18:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10588 | 697 |
"Modified (format): / 18-08-2011 / 16:01:34 / cg" |
10361 | 698 |
! ! |
699 |
||
9979 | 700 |
!CodeNavigationService class methodsFor:'documentation'! |
701 |
||
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
702 |
version |
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
703 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.27 2013-06-24 17:09:03 cg Exp $' |
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
704 |
! |
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
705 |
|
9979 | 706 |
version_CVS |
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
707 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.27 2013-06-24 17:09:03 cg Exp $' |
9979 | 708 |
! |
709 |
||
710 |
version_SVN |
|
12994
0899f74ec3ce
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12986
diff
changeset
|
711 |
^ '$Id: Tools__CodeNavigationService.st,v 1.27 2013-06-24 17:09:03 cg Exp $' |
9979 | 712 |
! ! |
12105
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
713 |