author | Claus Gittinger <cg@exept.de> |
Mon, 24 Jun 2013 16:20:38 +0200 | |
changeset 12986 | 145d28bf105e |
parent 12930 | 658aaa9b2245 |
child 12994 | 0899f74ec3ce |
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 |
||
405 |
!CodeNavigationService methodsFor:'private'! |
|
406 |
||
407 |
elementAtCursor |
|
408 |
^self elementAtLine: textView cursorLine col: textView cursorCol - 1 |
|
409 |
||
410 |
"Created: / 25-06-2010 / 14:39:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
411 |
! |
|
412 |
||
10631 | 413 |
elementAtLine:line col:colArg |
11740 | 414 |
|characterPosition syntaxElements index element col| |
10631 | 415 |
|
416 |
"/ if beyond end of line, do not advance into next line |
|
417 |
col := colArg min:(textView listAt:line) size. |
|
9979 | 418 |
|
419 |
characterPosition := textView characterPositionOfLine:line col:col. |
|
11740 | 420 |
syntaxElements := codeView syntaxElements. |
11741 | 421 |
syntaxElements isEmptyOrNil ifTrue:[ |
422 |
^ nil. |
|
423 |
]. |
|
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
424 |
0"1" to:0 by:-1 do:[:d | |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
425 |
index := (syntaxElements indexForInserting:characterPosition) - d. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
426 |
index > syntaxElements size ifTrue:[^nil]. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
427 |
element := syntaxElements at:index ifAbsent:nil. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
428 |
element notNil ifTrue:[ |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
429 |
(characterPosition between: element start - 1 and: element stop) ifTrue:[^element]. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
430 |
]. |
10631 | 431 |
]. |
432 |
^nil |
|
9979 | 433 |
|
434 |
"Created: / 25-06-2010 / 14:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 435 |
"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
|
436 |
"Modified: / 16-09-2011 / 17:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 437 |
! |
438 |
||
439 |
elementAtX:x y:y |
|
440 |
|visibleLine line col| |
|
441 |
||
10631 | 442 |
codeView syntaxElements isNil ifTrue:[^nil]. |
443 |
||
9979 | 444 |
visibleLine := textView visibleLineOfY:y. |
445 |
col := textView colOfX:x inVisibleLine:visibleLine. |
|
446 |
line := textView visibleLineToAbsoluteLine:visibleLine. |
|
447 |
^self elementAtLine:line col:col |
|
448 |
||
449 |
"Created: / 25-06-2010 / 14:52:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
450 |
"Modified: / 01-08-2010 / 08:50:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 451 |
"Modified: / 21-08-2011 / 10:26:08 / cg" |
452 |
! |
|
453 |
||
454 |
foo |
|
455 |
|characterPosition index element | |
|
456 |
||
457 |
characterPosition := 1 |
|
458 |
||
459 |
"Created: / 21-08-2011 / 10:48:05 / cg" |
|
9979 | 460 |
! |
461 |
||
462 |
highlighEmphasisFor: element |
|
463 |
||
10878 | 464 |
element isNil ifTrue:[^nil]. |
9979 | 465 |
|
10631 | 466 |
element isSelector ifTrue:[^selectorEmphasis]. |
467 |
element isVariable ifTrue:[^variableEmphasis]. |
|
468 |
element isSelf ifTrue:[^variableEmphasis]. |
|
9979 | 469 |
|
470 |
^nil |
|
471 |
||
472 |
"Created: / 25-06-2010 / 13:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 473 |
"Modified: / 18-11-2011 / 14:58:05 / cg" |
9979 | 474 |
! |
475 |
||
476 |
highlightClear |
|
477 |
||
10361 | 478 |
^self highlightClear: true. |
9979 | 479 |
|
480 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
|
481 |
"Created: / 25-06-2010 / 14:15:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10276 | 482 |
"Modified: / 08-07-2011 / 08:50:45 / cg" |
10361 | 483 |
"Modified: / 20-07-2011 / 18:52:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 484 |
! |
485 |
||
10361 | 486 |
highlightClear: redraw |
487 |
||
488 |
codeView syntaxElementSelection == nil ifTrue:[ ^ self ]. |
|
10878 | 489 |
textView list isNil ifTrue:[ ^ self ]. |
10361 | 490 |
textView list withIndexDo:[:line :lineNo | |
491 |
line isText ifTrue:[ |
|
492 |
(line hasEmphasis: currentEmphasis) ifTrue:[ |
|
493 |
line emphasisAllRemove:currentEmphasis. |
|
494 |
linesToRedraw add: lineNo. |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
495 |
] ifFalse:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
496 |
(currentEmphasisForAssign notNil and:[line hasEmphasis: currentEmphasisForAssign]) ifTrue:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
497 |
line emphasisAllRemove:currentEmphasisForAssign. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
498 |
linesToRedraw add: lineNo. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
499 |
] |
10361 | 500 |
] |
501 |
] |
|
502 |
]. |
|
503 |
codeView syntaxElementSelection:nil. |
|
504 |
||
505 |
redraw ifTrue:[self redrawLines]. |
|
9979 | 506 |
|
10361 | 507 |
"Modified: / 26-12-2007 / 12:28:05 / janfrog" |
508 |
"Created: / 20-07-2011 / 18:52:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10878 | 509 |
"Modified: / 18-11-2011 / 14:58:08 / cg" |
10361 | 510 |
! |
511 |
||
512 |
highlightElement:element |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
513 |
|e savedEmphasis| |
10631 | 514 |
|
515 |
codeView syntaxElementSelection == element ifTrue:[ ^ self ]. "/ no change |
|
516 |
codeView syntaxElementSelection notNil ifTrue:[ |
|
517 |
self highlightClear: false. |
|
518 |
]. |
|
10361 | 519 |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
520 |
currentEmphasis := savedEmphasis := self highlighEmphasisFor:element. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
521 |
currentEmphasisForAssign := nil. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
522 |
|
10631 | 523 |
element notNil ifTrue:[ |
524 |
codeView syntaxElementSelection:element. |
|
525 |
e := element firstElementInChain. |
|
526 |
[ e notNil ] whileTrue:[ |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
527 |
e assigned ifTrue:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
528 |
[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
529 |
currentEmphasis := currentEmphasisForAssign := assignmentEmphasis. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
530 |
self highlightWithoutClearFrom:e start to:e stop. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
531 |
] ensure:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
532 |
currentEmphasis := savedEmphasis. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
533 |
]. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
534 |
] ifFalse:[ |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
535 |
self highlightWithoutClearFrom:e start to:e stop. |
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
536 |
]. |
10631 | 537 |
e := e nextElement |
538 |
]. |
|
539 |
]. |
|
10361 | 540 |
self redrawLines. |
9979 | 541 |
|
542 |
"Created: / 14-02-2010 / 16:18:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10361 | 543 |
"Modified: / 20-07-2011 / 18:52:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10631 | 544 |
"Modified: / 21-08-2011 / 10:22:58 / cg" |
9979 | 545 |
! |
546 |
||
547 |
highlightElementAtCursor |
|
548 |
self highlightElementAtLine: textView cursorLine col: textView cursorCol |
|
549 |
||
550 |
"Created: / 14-02-2010 / 16:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
551 |
"Modified: / 06-03-2010 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
552 |
! |
|
553 |
||
554 |
highlightElementAtLine:line col:col |
|
11740 | 555 |
|characterPosition syntaxElements index element| |
9979 | 556 |
|
557 |
characterPosition := textView characterPositionOfLine:line col:col. |
|
11740 | 558 |
syntaxElements := codeView syntaxElements. |
11741 | 559 |
syntaxElements isEmptyOrNil ifTrue:[self highlightElement:nil. ^ self]. |
11740 | 560 |
index := syntaxElements indexForInserting:characterPosition. |
561 |
index > syntaxElements size ifTrue:[self highlightElement:nil. ^ self]. |
|
562 |
element := syntaxElements at:index. |
|
563 |
(characterPosition between: element start and: element stop) ifFalse:[element := nil]. |
|
9979 | 564 |
self highlightElement:element |
565 |
||
566 |
"Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
567 |
"Modified: / 01-08-2010 / 08:50:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
568 |
! |
|
569 |
||
570 |
highlightElementAtX:x y:y |
|
571 |
|visibleLine line col| |
|
572 |
||
10631 | 573 |
codeView syntaxElements isNil ifTrue:[^self]. |
9979 | 574 |
visibleLine := textView visibleLineOfY:y. |
575 |
col := textView colOfX:x inVisibleLine:visibleLine. |
|
576 |
line := textView visibleLineToAbsoluteLine:visibleLine. |
|
577 |
self highlightElementAtLine:line col:col |
|
578 |
||
579 |
"Created: / 14-02-2010 / 16:12:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
580 |
"Modified: / 06-03-2010 / 20:06:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 581 |
"Modified: / 21-08-2011 / 10:22:10 / cg" |
582 |
! |
|
583 |
||
584 |
highlightElementOrNil:e |
|
585 |
e notNil ifTrue:[ |
|
586 |
"/ cg: only if selected !! |
|
587 |
"/ self halt. |
|
588 |
self highlightElement:e. |
|
589 |
] ifFalse:[ |
|
590 |
self highlightClear |
|
591 |
]. |
|
592 |
||
593 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
594 |
"Created: / 21-08-2011 / 09:56:39 / cg" |
|
9979 | 595 |
! |
596 |
||
597 |
highlightLine:lineNo fromLine:startLine col:endLine toLine:startCol col:endCol |
|
598 |
|line start end| |
|
599 |
||
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
600 |
(lineNo between:startLine and:endLine) ifFalse:[ ^ self ]. |
9979 | 601 |
line := textView listAt:lineNo. |
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
602 |
line isEmpty ifTrue:[^self]. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
603 |
start := (lineNo = startLine) |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
604 |
ifTrue:[ startCol ] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
605 |
ifFalse:[ line indexOfNonSeparator ]. |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
606 |
end := (lineNo = endLine) |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
607 |
ifTrue:[ endCol ] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
608 |
ifFalse:[ line size ]. |
9979 | 609 |
line |
10291
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
610 |
emphasisFrom:(start max: 1) |
af5825474e18
changed: #highlightLine:fromLine:col:toLine:col:
Claus Gittinger <cg@exept.de>
parents:
10276
diff
changeset
|
611 |
to:(end min: line size) |
10361 | 612 |
add: currentEmphasis. |
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
613 |
|
10361 | 614 |
linesToRedraw add: lineNo. |
9979 | 615 |
|
616 |
"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
|
617 |
"Modified: / 08-07-2011 / 13:02:51 / cg" |
10361 | 618 |
"Modified: / 20-07-2011 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9979 | 619 |
! |
620 |
||
621 |
highlightVariable:e |
|
10631 | 622 |
(e notNil and:[ e isVariableOrSelf ]) ifTrue:[ |
9979 | 623 |
self highlightElement:e. |
624 |
] ifFalse:[ |
|
625 |
self highlightClear. |
|
10361 | 626 |
]. |
627 |
||
628 |
"Modified: / 20-07-2011 / 18:54:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 629 |
"Modified: / 21-08-2011 / 09:39:42 / cg" |
9979 | 630 |
! |
631 |
||
632 |
highlightVariableAtCursor |
|
10631 | 633 |
self highlightElementOrNil:(self elementAtCursor) |
9979 | 634 |
|
635 |
"Modified: / 25-06-2010 / 14:53:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 636 |
"Modified: / 21-08-2011 / 09:56:56 / cg" |
9979 | 637 |
! |
638 |
||
639 |
highlightVariableAtX:x y:y |
|
10631 | 640 |
self highlightElementOrNil:(self elementAtX:x y:y). |
9979 | 641 |
|
642 |
"Created: / 25-06-2010 / 14:52:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10631 | 643 |
"Modified: / 21-08-2011 / 10:24:50 / cg" |
9979 | 644 |
! |
645 |
||
646 |
highlightWithoutClearFrom: start to: end |
|
647 |
"Remove underlined emphasis" |
|
648 |
||
649 |
|startLine startCol endLine endCol| |
|
650 |
||
651 |
startLine := textView lineOfCharacterPosition:start. |
|
652 |
startCol := start - (textView characterPositionOfLine:startLine col:1) + 1. |
|
653 |
endLine := textView lineOfCharacterPosition:end. |
|
654 |
endCol := end - (textView characterPositionOfLine:endLine col:1) + 1. |
|
655 |
self highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
656 |
||
657 |
"Created: / 25-06-2010 / 14:15:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
658 |
! |
|
659 |
||
660 |
highlightWithoutClearFromLine: startLine col: startCol toLine: endLine col: endCol |
|
661 |
||
12913
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
662 |
textView list keysAndValuesDo: [:lineNo :line| |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
663 |
line isText ifTrue: [ |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
664 |
self highlightLine: lineNo fromLine: startLine col: endLine toLine: startCol col: endCol |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
665 |
] |
c5fdb1a82ed1
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12867
diff
changeset
|
666 |
]. |
9979 | 667 |
|
668 |
"Created: / 25-06-2010 / 14:15:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
669 |
! ! |
|
670 |
||
10361 | 671 |
!CodeNavigationService methodsFor:'redrawing'! |
672 |
||
673 |
redrawLines |
|
674 |
linesToRedraw do:[:lineNo| |
|
10588 | 675 |
textView invalidateLine: lineNo. |
10361 | 676 |
]. |
677 |
linesToRedraw := OrderedCollection new: 1 |
|
678 |
||
679 |
"Created: / 20-07-2011 / 18:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10588 | 680 |
"Modified (format): / 18-08-2011 / 16:01:34 / cg" |
10361 | 681 |
! ! |
682 |
||
9979 | 683 |
!CodeNavigationService class methodsFor:'documentation'! |
684 |
||
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
685 |
version |
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
686 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.26 2013-06-24 14:20:38 cg Exp $' |
12486
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
687 |
! |
0a82f2fcb6b3
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12485
diff
changeset
|
688 |
|
9979 | 689 |
version_CVS |
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
690 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeNavigationService.st,v 1.26 2013-06-24 14:20:38 cg Exp $' |
9979 | 691 |
! |
692 |
||
693 |
version_SVN |
|
12986
145d28bf105e
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
12930
diff
changeset
|
694 |
^ '$Id: Tools__CodeNavigationService.st,v 1.26 2013-06-24 14:20:38 cg Exp $' |
9979 | 695 |
! ! |
12105
44e930e29b99
class: Tools::CodeNavigationService
Claus Gittinger <cg@exept.de>
parents:
11741
diff
changeset
|
696 |