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