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