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