author | Claus Gittinger <cg@exept.de> |
Tue, 29 Nov 2011 11:21:54 +0100 | |
changeset 10912 | a90f6de79d36 |
parent 10877 | 1ed55c34722d |
child 10967 | 8c142eff5641 |
permissions | -rw-r--r-- |
9985 | 1 |
" |
10072 | 2 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
3 |
All Rights Reserved |
|
4 |
||
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. |
|
9985 | 25 |
" |
26 |
"{ Package: 'stx:libtool' }" |
|
27 |
||
28 |
"{ NameSpace: Tools }" |
|
29 |
||
30 |
SimpleView subclass:#CodeView2 |
|
31 |
instanceVariableNames:'gutterView textView textViewScroller methodHolder languageHolder |
|
32 |
classHolder browserHolder codeAspect modifiedChannel |
|
10793
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
33 |
showGutterChannel showAcceptCancelBarChannel modeHolder |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
34 |
serviceManager services servicesFromClient syntaxElements |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
35 |
syntaxElementSelection highlightEmphasis diffMode |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
36 |
synchronizedCodeViews' |
9985 | 37 |
classVariableNames:'TraceSelectors' |
38 |
poolDictionaries:'' |
|
39 |
category:'Interface-CodeView' |
|
40 |
! |
|
41 |
||
42 |
SimpleView subclass:#GutterView |
|
10781 | 43 |
instanceVariableNames:'codeView textView textViewScroller widthAcceptCancel |
44 |
widthAnnotations widthDiffInfo firstLineShown lastLineShown |
|
45 |
acceptColor cancelColor diffColor' |
|
9985 | 46 |
classVariableNames:'' |
47 |
poolDictionaries:'' |
|
48 |
privateIn:CodeView2 |
|
49 |
! |
|
50 |
||
51 |
CodeView subclass:#TextView |
|
10781 | 52 |
instanceVariableNames:'listOriginal codeView gutterView diffMode deletedLines |
53 |
insertedLines lastFirstLine changedLines scrolled originDiffText |
|
54 |
emptyLines changedDiffText suppressNotifications |
|
55 |
reallyModifiedChannel' |
|
9985 | 56 |
classVariableNames:'' |
57 |
poolDictionaries:'' |
|
58 |
privateIn:CodeView2 |
|
59 |
! |
|
60 |
||
61 |
!CodeView2 class methodsFor:'documentation'! |
|
62 |
||
63 |
copyright |
|
64 |
" |
|
10072 | 65 |
COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague |
66 |
All Rights Reserved |
|
67 |
||
68 |
Permission is hereby granted, free of charge, to any person |
|
69 |
obtaining a copy of this software and associated documentation |
|
70 |
files (the 'Software'), to deal in the Software without |
|
71 |
restriction, including without limitation the rights to use, |
|
72 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
73 |
copies of the Software, and to permit persons to whom the |
|
74 |
Software is furnished to do so, subject to the following |
|
75 |
conditions: |
|
76 |
||
77 |
The above copyright notice and this permission notice shall be |
|
78 |
included in all copies or substantial portions of the Software. |
|
79 |
||
80 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
81 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
82 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
83 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
84 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
85 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
86 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
87 |
OTHER DEALINGS IN THE SOFTWARE. |
|
9985 | 88 |
" |
89 |
! ! |
|
90 |
||
91 |
!CodeView2 class methodsFor:'initialization'! |
|
92 |
||
93 |
initialize |
|
94 |
"Invoked at system start or when the class is dynamically loaded." |
|
95 |
||
96 |
"/ please change as required (and remove this comment) |
|
97 |
||
98 |
TraceSelectors := IdentitySet new. |
|
99 |
||
100 |
"Modified: / 14-02-2010 / 15:36:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
101 |
! ! |
|
102 |
||
103 |
!CodeView2 class methodsFor:'debugging'! |
|
104 |
||
105 |
trace: aSelector |
|
106 |
||
107 |
TraceSelectors add: aSelector |
|
108 |
||
109 |
"Created: / 14-02-2010 / 09:26:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
110 |
! |
|
111 |
||
112 |
untrace: aSelector |
|
113 |
||
114 |
TraceSelectors remove: aSelector ifAbsent:[] |
|
115 |
||
116 |
"Created: / 14-02-2010 / 09:50:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
117 |
! |
|
118 |
||
119 |
untraceAll |
|
120 |
||
121 |
TraceSelectors := IdentitySet new |
|
122 |
||
123 |
"Created: / 14-02-2010 / 09:53:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
124 |
! ! |
|
125 |
||
126 |
!CodeView2 class methodsFor:'examples'! |
|
127 |
||
128 |
example1 |
|
129 |
||
130 |
| window codeView | |
|
131 |
||
132 |
||
133 |
window := StandardSystemView new. |
|
134 |
window extent: 300 @ 300. |
|
135 |
window label: 'CodeView2 example1'. |
|
136 |
||
137 |
codeView := Tools::CodeView2 in: window. |
|
138 |
codeView |
|
139 |
origin: 0.1 @ 0.1 |
|
140 |
corner: 0.9 @ 0.9. |
|
141 |
||
142 |
||
143 |
window open. |
|
144 |
||
145 |
"Created: / 02-09-2009 / 21:48:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
146 |
! ! |
|
147 |
||
148 |
!CodeView2 class methodsFor:'menu specs'! |
|
149 |
||
10293 | 150 |
debugMenu |
151 |
"This resource specification was automatically generated |
|
152 |
by the MenuEditor of ST/X." |
|
153 |
||
154 |
"Do not manually edit this!! If it is corrupted, |
|
155 |
the MenuEditor may not be able to read the specification." |
|
156 |
||
157 |
" |
|
158 |
MenuEditor new openOnClass:Tools::CodeView2 andSelector:#editMenu_stxStyle |
|
159 |
(Menu new fromLiteralArrayEncoding:(Tools::CodeView2 editMenu_stxStyle)) startUp |
|
160 |
" |
|
161 |
||
162 |
<resource: #menu> |
|
163 |
||
164 |
^ |
|
165 |
#(Menu |
|
166 |
( |
|
167 |
(MenuItem |
|
168 |
label: 'Inspect ' |
|
169 |
itemValue: inspectView |
|
170 |
translateLabel: true |
|
171 |
) |
|
172 |
(MenuItem |
|
173 |
label: 'Inspect Syntax Elements' |
|
174 |
itemValue: inspectSyntaxElements |
|
175 |
translateLabel: true |
|
176 |
) |
|
177 |
(MenuItem |
|
178 |
label: 'Inspect selected selector' |
|
179 |
itemValue: inspectSelectedSelector |
|
180 |
translateLabel: true |
|
181 |
) |
|
182 |
) |
|
183 |
nil |
|
184 |
nil |
|
185 |
) |
|
186 |
||
187 |
"Created: / 08-07-2011 / 13:36:02 / cg" |
|
188 |
! |
|
189 |
||
9985 | 190 |
editMenu |
191 |
"This resource specification was automatically generated |
|
192 |
by the MenuEditor of ST/X." |
|
193 |
||
194 |
"Do not manually edit this!! If it is corrupted, |
|
195 |
the MenuEditor may not be able to read the specification." |
|
196 |
||
197 |
" |
|
198 |
MenuEditor new openOnClass:Tools::CodeView2 andSelector:#editMenu |
|
199 |
(Menu new fromLiteralArrayEncoding:(Tools::CodeView2 editMenu)) startUp |
|
200 |
" |
|
201 |
||
10290 | 202 |
UserPreferences current eclipseStyleMenus ifTrue:[ |
203 |
^ self editMenu_eclipseStyle |
|
204 |
]. |
|
205 |
^ self editMenu_stxStyle |
|
206 |
||
207 |
"Modified: / 08-07-2011 / 13:23:35 / cg" |
|
208 |
! |
|
209 |
||
210 |
editMenu_eclipseStyle |
|
211 |
"This resource specification was automatically generated |
|
212 |
by the MenuEditor of ST/X." |
|
213 |
||
214 |
"Do not manually edit this!! If it is corrupted, |
|
215 |
the MenuEditor may not be able to read the specification." |
|
216 |
||
217 |
" |
|
218 |
MenuEditor new openOnClass:Tools::CodeView2 andSelector:#editMenu |
|
219 |
(Menu new fromLiteralArrayEncoding:(Tools::CodeView2 editMenu)) startUp |
|
220 |
" |
|
221 |
||
9985 | 222 |
<resource: #menu> |
223 |
||
224 |
^ |
|
225 |
#(Menu |
|
226 |
( |
|
227 |
(MenuItem |
|
10262 | 228 |
label: 'Implementors...' |
9985 | 229 |
itemValue: browseImplementorsOfIt |
230 |
translateLabel: true |
|
10262 | 231 |
submenuChannel: implementorsMenu |
9985 | 232 |
shortcutKey: ImplementorsOfIt |
233 |
) |
|
234 |
(MenuItem |
|
10262 | 235 |
label: 'Senders...' |
9985 | 236 |
itemValue: browseSendersOfIt |
237 |
translateLabel: true |
|
10262 | 238 |
submenuChannel: sendersMenu |
9985 | 239 |
shortcutKey: SendersOfIt |
240 |
) |
|
241 |
(MenuItem |
|
242 |
label: 'Refactor' |
|
243 |
translateLabel: true |
|
244 |
isVisible: false |
|
245 |
shortcutKey: Shift |
|
246 |
) |
|
247 |
(MenuItem |
|
248 |
label: '-' |
|
249 |
) |
|
250 |
(MenuItem |
|
251 |
label: 'Accept' |
|
252 |
itemValue: accept |
|
253 |
translateLabel: true |
|
254 |
shortcutKey: Accept |
|
255 |
) |
|
256 |
(MenuItem |
|
257 |
label: '-' |
|
258 |
) |
|
259 |
(MenuItem |
|
260 |
label: 'Cut' |
|
261 |
itemValue: cut |
|
262 |
translateLabel: true |
|
263 |
shortcutKey: Cut |
|
264 |
) |
|
265 |
(MenuItem |
|
266 |
label: 'Copy' |
|
267 |
itemValue: copySelection |
|
268 |
translateLabel: true |
|
269 |
shortcutKey: Copy |
|
270 |
) |
|
271 |
(MenuItem |
|
272 |
label: 'Paste' |
|
273 |
itemValue: pasteOrReplace |
|
274 |
translateLabel: true |
|
275 |
shortcutKey: Paste |
|
276 |
) |
|
277 |
(MenuItem |
|
278 |
label: '-' |
|
279 |
) |
|
280 |
(MenuItem |
|
281 |
label: 'Undo' |
|
282 |
itemValue: undo |
|
283 |
translateLabel: true |
|
284 |
shortcutKey: Undo |
|
285 |
) |
|
286 |
(MenuItem |
|
287 |
label: '-' |
|
288 |
) |
|
289 |
(MenuItem |
|
290 |
label: 'Do it' |
|
291 |
itemValue: doIt |
|
292 |
translateLabel: true |
|
293 |
shortcutKey: DoIt |
|
294 |
) |
|
295 |
(MenuItem |
|
296 |
label: 'Print it' |
|
297 |
itemValue: printIt |
|
298 |
translateLabel: true |
|
299 |
shortcutKey: PrintIt |
|
300 |
) |
|
301 |
(MenuItem |
|
302 |
label: 'Inspect it' |
|
303 |
itemValue: inspectIt |
|
304 |
translateLabel: true |
|
305 |
shortcutKey: InspectIt |
|
306 |
) |
|
307 |
(MenuItem |
|
308 |
label: 'Profile it' |
|
309 |
itemValue: profileIt |
|
310 |
translateLabel: true |
|
311 |
shortcutKey: InspectIt |
|
312 |
) |
|
313 |
(MenuItem |
|
314 |
label: '-' |
|
315 |
) |
|
316 |
(MenuItem |
|
317 |
label: 'Show Gutter' |
|
318 |
nameKey: ShowGutter |
|
319 |
translateLabel: true |
|
320 |
indication: showGutterChannel |
|
321 |
) |
|
322 |
(MenuItem |
|
323 |
label: 'More' |
|
324 |
nameKey: More |
|
325 |
translateLabel: true |
|
326 |
) |
|
327 |
(MenuItem |
|
328 |
label: 'Services' |
|
329 |
translateLabel: true |
|
330 |
submenuChannel: servicesMenu |
|
331 |
) |
|
332 |
(MenuItem |
|
333 |
label: 'Debug' |
|
334 |
translateLabel: true |
|
335 |
submenu: |
|
336 |
(Menu |
|
337 |
( |
|
338 |
(MenuItem |
|
339 |
label: 'Inspect ' |
|
340 |
itemValue: inspectView |
|
341 |
translateLabel: true |
|
342 |
) |
|
343 |
(MenuItem |
|
344 |
label: 'Inspect Syntax Elements' |
|
345 |
itemValue: inspectSyntaxElements |
|
346 |
translateLabel: true |
|
347 |
) |
|
348 |
(MenuItem |
|
349 |
label: 'Inspect selected selector' |
|
350 |
itemValue: inspectSelectedSelector |
|
351 |
translateLabel: true |
|
352 |
) |
|
353 |
) |
|
354 |
nil |
|
355 |
nil |
|
356 |
) |
|
357 |
) |
|
358 |
) |
|
359 |
nil |
|
360 |
nil |
|
361 |
) |
|
10290 | 362 |
|
363 |
"Created: / 08-07-2011 / 13:20:47 / cg" |
|
364 |
! |
|
365 |
||
366 |
editMenu_stxStyle |
|
367 |
"This resource specification was automatically generated |
|
368 |
by the MenuEditor of ST/X." |
|
369 |
||
370 |
"Do not manually edit this!! If it is corrupted, |
|
371 |
the MenuEditor may not be able to read the specification." |
|
372 |
||
373 |
" |
|
374 |
MenuEditor new openOnClass:Tools::CodeView2 andSelector:#editMenu_stxStyle |
|
375 |
(Menu new fromLiteralArrayEncoding:(Tools::CodeView2 editMenu_stxStyle)) startUp |
|
376 |
" |
|
377 |
||
378 |
<resource: #menu> |
|
379 |
||
380 |
^ |
|
381 |
#(Menu |
|
382 |
( |
|
383 |
(MenuItem |
|
384 |
label: 'Undo' |
|
385 |
itemValue: undo |
|
386 |
translateLabel: true |
|
387 |
shortcutKey: Undo |
|
388 |
) |
|
389 |
(MenuItem |
|
390 |
label: 'Again' |
|
391 |
itemValue: again |
|
392 |
translateLabel: true |
|
393 |
shortcutKey: Again |
|
394 |
) |
|
395 |
(MenuItem |
|
396 |
label: '-' |
|
397 |
) |
|
398 |
(MenuItem |
|
399 |
label: 'Cut' |
|
400 |
itemValue: cut |
|
401 |
translateLabel: true |
|
402 |
shortcutKey: Cut |
|
403 |
) |
|
404 |
(MenuItem |
|
405 |
label: 'Copy' |
|
406 |
itemValue: copySelection |
|
407 |
translateLabel: true |
|
408 |
shortcutKey: Copy |
|
409 |
) |
|
410 |
(MenuItem |
|
411 |
label: 'Paste' |
|
412 |
itemValue: pasteOrReplace |
|
413 |
translateLabel: true |
|
414 |
shortcutKey: Paste |
|
415 |
) |
|
416 |
(MenuItem |
|
417 |
label: '-' |
|
418 |
) |
|
419 |
(MenuItem |
|
420 |
label: 'DoIt' |
|
421 |
itemValue: doIt |
|
422 |
translateLabel: true |
|
423 |
shortcutKey: DoIt |
|
424 |
) |
|
425 |
(MenuItem |
|
426 |
label: 'PrintIt' |
|
427 |
itemValue: printIt |
|
428 |
translateLabel: true |
|
429 |
shortcutKey: PrintIt |
|
430 |
) |
|
431 |
(MenuItem |
|
432 |
label: 'InspectIt' |
|
433 |
itemValue: inspectIt |
|
434 |
translateLabel: true |
|
435 |
shortcutKey: InspectIt |
|
436 |
) |
|
437 |
(MenuItem |
|
438 |
label: '-' |
|
439 |
) |
|
440 |
(MenuItem |
|
441 |
label: 'Accept' |
|
442 |
itemValue: accept |
|
443 |
translateLabel: true |
|
444 |
shortcutKey: Accept |
|
445 |
) |
|
446 |
(MenuItem |
|
447 |
label: '-' |
|
448 |
) |
|
449 |
(MenuItem |
|
450 |
label: 'Refactor' |
|
451 |
translateLabel: true |
|
452 |
isVisible: false |
|
453 |
shortcutKey: Shift |
|
454 |
) |
|
455 |
(MenuItem |
|
456 |
label: 'Services' |
|
457 |
translateLabel: true |
|
458 |
submenuChannel: servicesMenu |
|
459 |
) |
|
460 |
(MenuItem |
|
461 |
label: '-' |
|
462 |
) |
|
463 |
(MenuItem |
|
464 |
label: 'More' |
|
465 |
nameKey: More |
|
466 |
translateLabel: true |
|
467 |
shortcutKey: Ctrl |
|
468 |
) |
|
469 |
) |
|
470 |
nil |
|
471 |
nil |
|
472 |
) |
|
9985 | 473 |
! ! |
474 |
||
475 |
!CodeView2 methodsFor:'accessing'! |
|
476 |
||
477 |
acceptAction:aBlock |
|
478 |
||
479 |
textView acceptAction: aBlock |
|
480 |
||
481 |
"Modified: / 01-08-2010 / 20:40:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
482 |
! |
|
483 |
||
10224 | 484 |
breakpoints |
485 |
||
486 |
services do:[:each| |
|
487 |
(each isKindOf: BreakpointService) ifTrue:[ |
|
488 |
^each breakpoints |
|
489 |
] |
|
490 |
]. |
|
10767 | 491 |
^ nil |
10224 | 492 |
|
493 |
"Created: / 06-07-2011 / 18:05:35 / jv" |
|
10767 | 494 |
"Modified: / 06-10-2011 / 14:13:53 / cg" |
10224 | 495 |
! |
496 |
||
10245 | 497 |
browser |
498 |
||
499 |
^self browserHolder value |
|
500 |
||
501 |
"Created: / 07-07-2011 / 12:25:59 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
502 |
! |
|
503 |
||
9985 | 504 |
codeAspect |
505 |
||
506 |
|app| |
|
507 |
codeAspect ifNotNil:[^codeAspect]. |
|
10409 | 508 |
methodHolder value ifNotNil:[^#method]. |
9985 | 509 |
|
510 |
^((app := self topView application) notNil and:[app respondsTo: #codeAspect]) |
|
511 |
ifTrue:[app codeAspect] |
|
512 |
ifFalse:[#expression] |
|
513 |
||
10409 | 514 |
"Modified: / 27-07-2011 / 13:05:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 515 |
! |
516 |
||
517 |
codeAspect:aSymbol |
|
518 |
codeAspect := aSymbol. |
|
519 |
! |
|
520 |
||
521 |
contents |
|
522 |
||
523 |
^textView contents |
|
524 |
||
525 |
"Created: / 14-02-2010 / 22:13:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
526 |
! |
|
527 |
||
528 |
contents: aStringOrStringCollection |
|
529 |
||
530 |
textView contents: aStringOrStringCollection. |
|
531 |
"/self update:#value with: aStringOrStringCollection from: textView model |
|
532 |
||
10330 | 533 |
"Modified: / 19-07-2011 / 13:18:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 534 |
! |
535 |
||
536 |
diffMode |
|
537 |
^ diffMode |
|
538 |
! |
|
539 |
||
540 |
diffMode:aBoolean |
|
541 |
diffMode := aBoolean. |
|
542 |
textView diffMode: aBoolean |
|
543 |
||
544 |
"Modified: / 08-04-2011 / 20:50:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
545 |
! |
|
546 |
||
547 |
font |
|
548 |
||
549 |
^textView font |
|
550 |
||
551 |
"Created: / 16-02-2010 / 10:26:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
552 |
! |
|
553 |
||
554 |
font: aFont |
|
555 |
||
556 |
^textView font: aFont |
|
557 |
||
558 |
"Created: / 16-02-2010 / 10:26:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
559 |
! |
|
560 |
||
561 |
mode |
|
562 |
||
563 |
^self modeHolder value |
|
564 |
||
565 |
"Created: / 13-06-2011 / 10:49:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
566 |
! |
|
567 |
||
568 |
mode: aSymbol |
|
569 |
||
570 |
self assert: (#(expression method) includes: aSymbol). |
|
571 |
||
572 |
^self modeHolder value: aSymbol |
|
573 |
||
574 |
"Created: / 13-06-2011 / 10:50:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
575 |
"Modified: / 15-06-2011 / 16:37:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
576 |
! |
|
577 |
||
10409 | 578 |
model |
579 |
||
580 |
^textView model. |
|
581 |
||
582 |
"Created: / 27-07-2011 / 12:47:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
583 |
! |
|
584 |
||
585 |
model: aValueModel |
|
586 |
||
587 |
|oldValue newValue| |
|
588 |
||
589 |
textView model notNil ifTrue:[ |
|
590 |
oldValue := textView model value. |
|
591 |
textView model removeDependent:self. |
|
592 |
]. |
|
593 |
textView model: aValueModel. |
|
594 |
textView model notNil ifTrue:[ |
|
595 |
textView model addDependent:self. |
|
596 |
]. |
|
597 |
newValue := textView model value. |
|
598 |
oldValue ~~ newValue ifTrue:[ |
|
599 |
self update:#value with:newValue from:textView model. |
|
600 |
]. |
|
601 |
||
602 |
"Modified: / 27-07-2011 / 12:58:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
603 |
! |
|
604 |
||
9985 | 605 |
modified |
606 |
"return true if text was modified" |
|
607 |
||
10245 | 608 |
^ self modifiedChannel value |
609 |
||
610 |
"Modified: / 07-07-2011 / 12:15:43 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
9985 | 611 |
! |
612 |
||
613 |
modified:aBoolean |
|
614 |
"set/clear the modified flag" |
|
615 |
||
10245 | 616 |
self modifiedChannel value:aBoolean |
617 |
||
618 |
"Modified: / 14-02-1997 / 16:44:05 / cg" |
|
619 |
"Modified: / 07-07-2011 / 12:15:39 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
9985 | 620 |
! |
621 |
||
622 |
scrolledView |
|
623 |
||
624 |
^self |
|
625 |
||
626 |
"Created: / 14-02-2010 / 22:54:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
627 |
! |
|
628 |
||
10487 | 629 |
services |
10767 | 630 |
^ services ? #() |
10487 | 631 |
|
632 |
"Created: / 05-08-2011 / 10:14:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10767 | 633 |
"Modified (format): / 06-10-2011 / 14:11:11 / cg" |
10487 | 634 |
! |
635 |
||
10755 | 636 |
services:aCollectionOfServices |
637 |
"allow setting of the services (instances); |
|
638 |
this is needed for FileBrowser, to setup a codeView2 without Smalltalk-specific |
|
639 |
services" |
|
640 |
||
10767 | 641 |
servicesFromClient := true. |
642 |
services := aCollectionOfServices. |
|
643 |
||
644 |
"Created: / 06-10-2011 / 14:15:36 / cg" |
|
10755 | 645 |
! |
646 |
||
10793
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
647 |
showAcceptCancelBar |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
648 |
|
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
649 |
^showAcceptCancelBarChannel value |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
650 |
|
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
651 |
"Created: / 10-10-2011 / 16:25:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
652 |
! |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
653 |
|
9985 | 654 |
showGutter |
655 |
||
656 |
^showGutterChannel value |
|
657 |
||
658 |
"Created: / 23-06-2010 / 19:37:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
659 |
! |
|
660 |
||
661 |
synchronizeWith: aCodeView |
|
662 |
||
663 |
self assert: aCodeView ~= self. |
|
664 |
(synchronizedCodeViews includes: aCodeView) ifTrue:[^self]. |
|
665 |
synchronizedCodeViews := synchronizedCodeViews copyWith: aCodeView. |
|
666 |
||
667 |
"Created: / 06-04-2010 / 14:13:14 / Jakub <zelenja7@fel.cvut.cz>" |
|
668 |
"Modified: / 23-06-2010 / 17:01:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
669 |
! ! |
|
670 |
||
10409 | 671 |
!CodeView2 methodsFor:'accessing - code component'! |
672 |
||
673 |
klass |
|
674 |
||
675 |
| v | |
|
676 |
||
677 |
(v := self classHolder value) notNil ifTrue:[^v]. |
|
678 |
(v := self methodHolder value) notNil ifTrue:[^v mclass]. |
|
679 |
||
680 |
^UndefinedObject |
|
681 |
||
682 |
"Created: / 27-07-2011 / 13:14:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
683 |
! |
|
684 |
||
685 |
klass: aClass |
|
686 |
||
687 |
"Created: / 27-07-2011 / 13:13:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
688 |
! |
|
689 |
||
690 |
language |
|
691 |
"return the value in 'languageHolder'" |
|
692 |
||
693 |
| v | |
|
694 |
||
695 |
(v := self languageHolder value) notNil ifTrue:[^v]. |
|
696 |
(v := self methodHolder value) notNil ifTrue:[^v programmingLanguage]. |
|
697 |
(v := self classHolder value) notNil ifTrue:[^v programmingLanguage]. |
|
698 |
||
699 |
^SmalltalkLanguage instance |
|
700 |
||
701 |
"Modified: / 17-06-2011 / 12:36:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
702 |
! |
|
703 |
||
704 |
language: newValue |
|
705 |
"set the value in 'languageHolder'" |
|
706 |
||
707 |
self languageHolder value: newValue |
|
708 |
! |
|
709 |
||
710 |
method |
|
711 |
||
712 |
^self methodHolder value |
|
713 |
||
714 |
"Created: / 27-07-2011 / 13:12:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
715 |
! |
|
716 |
||
717 |
method: aMethod |
|
718 |
||
719 |
^self methodHolder value: aMethod |
|
720 |
||
721 |
"Created: / 27-07-2011 / 13:12:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
722 |
! ! |
|
723 |
||
9985 | 724 |
!CodeView2 methodsFor:'aspects'! |
725 |
||
726 |
browserHolder |
|
10877 | 727 |
browserHolder isNil ifTrue:[ |
9985 | 728 |
browserHolder := ValueHolder new |
729 |
]. |
|
730 |
^browserHolder |
|
731 |
||
732 |
"Modified: / 14-02-2010 / 19:27:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10877 | 733 |
"Modified: / 18-11-2011 / 14:58:15 / cg" |
9985 | 734 |
! |
735 |
||
736 |
browserHolder:aValueModel |
|
737 |
browserHolder := aValueModel. |
|
738 |
! |
|
739 |
||
740 |
classHolder |
|
741 |
"return/create the 'classHolder' value holder (automatically generated)" |
|
742 |
||
743 |
classHolder isNil ifTrue:[ |
|
10409 | 744 |
classHolder := ValueHolder with: nil. |
9985 | 745 |
classHolder addDependent:self. |
746 |
]. |
|
747 |
^ classHolder |
|
748 |
||
10409 | 749 |
"Modified: / 27-07-2011 / 13:15:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 750 |
! |
751 |
||
752 |
classHolder:aValueModel |
|
753 |
"set the 'classHolder' value holder (automatically generated)" |
|
754 |
||
755 |
|old oldValue newValue| |
|
756 |
||
757 |
classHolder notNil ifTrue:[ |
|
758 |
oldValue := classHolder value. |
|
759 |
classHolder removeDependent:self. |
|
760 |
]. |
|
761 |
classHolder := aValueModel. |
|
762 |
classHolder notNil ifTrue:[ |
|
763 |
classHolder addDependent:self. |
|
764 |
]. |
|
765 |
old := methodHolder. |
|
766 |
newValue := classHolder value. |
|
767 |
oldValue ~~ newValue ifTrue:[ |
|
768 |
self update:#value with:newValue from:classHolder. |
|
769 |
]. |
|
770 |
||
771 |
self changed: #classHolder with: old -> classHolder |
|
772 |
||
773 |
"Modified: / 17-06-2011 / 12:56:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
774 |
! |
|
775 |
||
776 |
languageHolder |
|
777 |
languageHolder isNil ifTrue:[ |
|
10723 | 778 |
"/ cg: I dont like this default here; everyone who is not showing ST-code (expecco, filebrowser etc.) |
779 |
"/ has to explicitely clear the valueholder. I guess, it is better for the few |
|
780 |
"/ others to explicitely set it, if they do not provide syntaxHighlighter per method |
|
781 |
"/ or class. |
|
782 |
languageHolder := ValueHolder with: nil "SmalltalkLanguage instance". |
|
9985 | 783 |
languageHolder addDependent:self. |
784 |
]. |
|
785 |
^ languageHolder |
|
10723 | 786 |
|
787 |
"Modified (format): / 26-09-2011 / 17:04:04 / cg" |
|
9985 | 788 |
! |
789 |
||
790 |
languageHolder:aValueModel |
|
791 |
"set the 'languageHolder' value holder (automatically generated)" |
|
792 |
||
793 |
|old oldValue newValue| |
|
794 |
||
795 |
languageHolder notNil ifTrue:[ |
|
796 |
oldValue := languageHolder value. |
|
797 |
languageHolder removeDependent:self. |
|
798 |
]. |
|
799 |
languageHolder := aValueModel. |
|
800 |
languageHolder notNil ifTrue:[ |
|
801 |
languageHolder addDependent:self. |
|
802 |
]. |
|
803 |
old := languageHolder. |
|
804 |
newValue := languageHolder value. |
|
805 |
oldValue ~~ newValue ifTrue:[ |
|
806 |
self update:#value with:newValue from:languageHolder. |
|
807 |
]. |
|
808 |
||
809 |
self changed: #languageHolder with: old -> languageHolder |
|
810 |
||
811 |
"Modified: / 17-06-2011 / 12:56:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
812 |
! |
|
813 |
||
814 |
methodHolder |
|
815 |
"return/create the 'methodHolder' value holder (automatically generated)" |
|
816 |
||
817 |
methodHolder isNil ifTrue:[ |
|
818 |
methodHolder := ValueHolder new. |
|
819 |
methodHolder addDependent:self. |
|
820 |
]. |
|
821 |
^ methodHolder |
|
822 |
! |
|
823 |
||
824 |
methodHolder:aValueModel |
|
825 |
"set the 'methodHolder' value holder (automatically generated)" |
|
826 |
||
827 |
|old oldValue newValue| |
|
828 |
||
829 |
methodHolder notNil ifTrue:[ |
|
830 |
oldValue := methodHolder value. |
|
831 |
methodHolder removeDependent:self. |
|
832 |
]. |
|
833 |
old := methodHolder. |
|
834 |
methodHolder := aValueModel. |
|
835 |
methodHolder notNil ifTrue:[ |
|
836 |
methodHolder addDependent:self. |
|
837 |
]. |
|
838 |
newValue := methodHolder value. |
|
839 |
oldValue ~~ newValue ifTrue:[ |
|
840 |
self update:#value with:newValue from:methodHolder. |
|
841 |
]. |
|
842 |
||
843 |
self changed: #methodHolder with: old -> methodHolder |
|
844 |
||
845 |
"Modified: / 17-06-2011 / 12:55:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
846 |
! |
|
847 |
||
848 |
modeHolder |
|
849 |
"return/create the 'modeHolder' value holder (automatically generated)" |
|
850 |
||
851 |
modeHolder isNil ifTrue:[ |
|
852 |
modeHolder := #expression asValue. |
|
853 |
modeHolder addDependent:self. |
|
854 |
]. |
|
855 |
^ modeHolder |
|
856 |
||
857 |
"Modified: / 13-06-2011 / 10:52:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
858 |
! |
|
859 |
||
860 |
modeHolder:something |
|
861 |
"set the 'modeHolder' value holder (automatically generated)" |
|
862 |
||
863 |
|oldValue newValue| |
|
864 |
||
865 |
modeHolder notNil ifTrue:[ |
|
866 |
oldValue := modeHolder value. |
|
867 |
modeHolder removeDependent:self. |
|
868 |
]. |
|
869 |
modeHolder := something. |
|
870 |
modeHolder notNil ifTrue:[ |
|
871 |
modeHolder addDependent:self. |
|
872 |
]. |
|
873 |
newValue := modeHolder value. |
|
874 |
oldValue ~~ newValue ifTrue:[ |
|
875 |
self update:#value with:newValue from:modeHolder. |
|
876 |
]. |
|
877 |
||
878 |
self changed: #modeHolder with: modeHolder |
|
879 |
||
880 |
"Modified: / 17-06-2011 / 12:55:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
881 |
! ! |
|
882 |
||
883 |
!CodeView2 methodsFor:'change & update'! |
|
884 |
||
885 |
update:aspect with:param from:sender |
|
886 |
||
10245 | 887 |
sender == showGutterChannel ifTrue: [ |
888 |
self updateGutterVisibility. |
|
889 |
^self. |
|
890 |
]. |
|
9985 | 891 |
|
10662
4d67f850e4f7
comment/format in: #update:with:from:
Claus Gittinger <cg@exept.de>
parents:
10630
diff
changeset
|
892 |
services do:[:each | |
4d67f850e4f7
comment/format in: #update:with:from:
Claus Gittinger <cg@exept.de>
parents:
10630
diff
changeset
|
893 |
each isEnabled ifTrue:[ |
4d67f850e4f7
comment/format in: #update:with:from:
Claus Gittinger <cg@exept.de>
parents:
10630
diff
changeset
|
894 |
each update:aspect with:param from:sender |
4d67f850e4f7
comment/format in: #update:with:from:
Claus Gittinger <cg@exept.de>
parents:
10630
diff
changeset
|
895 |
] |
4d67f850e4f7
comment/format in: #update:with:from:
Claus Gittinger <cg@exept.de>
parents:
10630
diff
changeset
|
896 |
]. |
9985 | 897 |
|
898 |
super update:aspect with:param from:sender |
|
899 |
||
900 |
"Modified: / 23-06-2010 / 19:05:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10245 | 901 |
"Modified: / 07-07-2011 / 12:07:04 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
10767 | 902 |
"Modified: / 06-10-2011 / 14:14:36 / cg" |
9985 | 903 |
! |
904 |
||
905 |
updateGutterVisibility |
|
906 |
||
907 |
self showGutterChannel value ifTrue:[ |
|
908 |
textViewScroller origin:(gutterView width @ 0.0) corner:(1.0 @ 1.0). |
|
909 |
gutterView beVisible. |
|
910 |
] ifFalse:[ |
|
911 |
textViewScroller origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
912 |
gutterView beInvisible. |
|
913 |
] |
|
914 |
||
915 |
"Created: / 23-06-2010 / 19:05:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
916 |
! ! |
|
917 |
||
918 |
!CodeView2 methodsFor:'channels'! |
|
919 |
||
920 |
modifiedChannel |
|
921 |
"return the valueHolder holding true if text was modified" |
|
922 |
||
10245 | 923 |
^ textView modifiedChannel |
924 |
"/ ^ modifiedChannel |
|
925 |
||
926 |
"Modified: / 07-07-2011 / 12:07:26 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
9985 | 927 |
! |
928 |
||
929 |
modifiedChannel:aValueHolder |
|
930 |
"set the valueHolder holding true if text was modified" |
|
931 |
||
10662
4d67f850e4f7
comment/format in: #update:with:from:
Claus Gittinger <cg@exept.de>
parents:
10630
diff
changeset
|
932 |
textView modifiedChannel removeDependent:self. |
4d67f850e4f7
comment/format in: #update:with:from:
Claus Gittinger <cg@exept.de>
parents:
10630
diff
changeset
|
933 |
textView modifiedChannel:aValueHolder. |
4d67f850e4f7
comment/format in: #update:with:from:
Claus Gittinger <cg@exept.de>
parents:
10630
diff
changeset
|
934 |
textView modifiedChannel addDependent:self. |
10245 | 935 |
|
936 |
"/ |prev| |
|
937 |
"/ |
|
938 |
"/ prev := modifiedChannel. |
|
939 |
"/ modifiedChannel := aValueHolder. |
|
940 |
"/ self setupChannel:aValueHolder for:nil withOld:prev |
|
941 |
||
942 |
"Created: / 30-01-1998 / 14:51:32 / cg" |
|
943 |
"Modified: / 07-07-2011 / 12:07:43 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
10662
4d67f850e4f7
comment/format in: #update:with:from:
Claus Gittinger <cg@exept.de>
parents:
10630
diff
changeset
|
944 |
"Modified: / 05-09-2011 / 05:13:27 / cg" |
9985 | 945 |
! |
946 |
||
10785 | 947 |
reallyModifiedChannel |
948 |
"return the valueHolder holding true if text was modified" |
|
949 |
||
950 |
^ textView reallyModifiedChannel |
|
951 |
||
952 |
"Modified: / 07-07-2011 / 12:07:26 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
953 |
"Created: / 08-10-2011 / 12:47:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
954 |
! |
|
955 |
||
956 |
reallyModifiedChannel: aValueModel |
|
957 |
||
958 |
^ textView reallyModifiedChannel: aValueModel |
|
959 |
||
960 |
"Modified: / 07-07-2011 / 12:07:26 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
961 |
"Created: / 08-10-2011 / 12:47:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
962 |
! |
|
963 |
||
10793
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
964 |
showAcceptCancelBarChannel |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
965 |
|
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
966 |
^showAcceptCancelBarChannel |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
967 |
|
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
968 |
"Created: / 10-10-2011 / 16:23:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
969 |
! |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
970 |
|
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
971 |
showAcceptCancelBarChannel:aValueHolder |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
972 |
"set the valueHolder holding true if text was modified" |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
973 |
|
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
974 |
|prev| |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
975 |
|
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
976 |
prev := showAcceptCancelBarChannel. |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
977 |
showAcceptCancelBarChannel := aValueHolder. |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
978 |
self setupChannel:aValueHolder for:nil withOld:prev. |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
979 |
|
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
980 |
"Created: / 10-10-2011 / 16:24:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
981 |
! |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
982 |
|
9985 | 983 |
showGutterChannel |
984 |
||
985 |
^showGutterChannel |
|
986 |
||
987 |
"Created: / 23-06-2010 / 19:02:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
988 |
! |
|
989 |
||
990 |
showGutterChannel:aValueHolder |
|
991 |
"set the valueHolder holding true if text was modified" |
|
992 |
||
993 |
|prev| |
|
994 |
||
995 |
prev := showGutterChannel. |
|
996 |
showGutterChannel := aValueHolder. |
|
997 |
self setupChannel:aValueHolder for:nil withOld:prev |
|
998 |
||
999 |
"Created: / 23-06-2010 / 19:03:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1000 |
! ! |
|
1001 |
||
10262 | 1002 |
!CodeView2 methodsFor:'code services'! |
1003 |
||
1004 |
browseMethod: method |
|
1005 |
||
1006 |
self browseMethod: method label: nil. |
|
1007 |
||
1008 |
"Created: / 14-02-2010 / 19:41:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1009 |
! |
|
1010 |
||
1011 |
browseMethod: method label: label |
|
1012 |
||
10877 | 1013 |
self browser isNil ifTrue: [^NewSystemBrowser openInMethod:method]. |
10262 | 1014 |
(UserPreferences current alwaysOpenNewTabWhenCtrlClick |
1015 |
or:[self browser navigationState modified]) |
|
1016 |
ifTrue: |
|
1017 |
[self browser |
|
1018 |
spawnFullBrowserInClass: method mclass |
|
1019 |
selector:method selector |
|
1020 |
in:#newBuffer] |
|
1021 |
ifFalse: |
|
1022 |
[self browser |
|
1023 |
switchToClass: method containingClass |
|
1024 |
selector: method selector]. |
|
1025 |
||
1026 |
"Modified: / 19-02-2008 / 10:15:17 / janfrog" |
|
1027 |
"Created: / 19-10-2008 / 08:16:17 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
1028 |
"Modified: / 25-07-2010 / 13:34:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10877 | 1029 |
"Modified: / 18-11-2011 / 14:58:12 / cg" |
10262 | 1030 |
! |
1031 |
||
1032 |
browseMethods: methods label: label |
|
1033 |
||
1034 |
methods size = 1 ifTrue: |
|
1035 |
[^self browseMethod: methods anyOne label: label]. |
|
1036 |
||
1037 |
self browser |
|
1038 |
ifNil: [NewSystemBrowser browseMethods: methods title: label] |
|
1039 |
ifNotNil:[self browser spawnMethodBrowserFor:methods in:#newBuffer label:label] |
|
1040 |
||
1041 |
"Created: / 26-12-2007 / 11:32:04 / janfrog" |
|
1042 |
"Modified: / 19-10-2008 / 08:17:28 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
1043 |
! |
|
1044 |
||
1045 |
extractSelectorAndSelectedTextFrom: givenSelectedText |
|
1046 |
||
1047 |
| selector selectedText compilerClass na | |
|
1048 |
selectedText := givenSelectedText. |
|
1049 |
compilerClass := self language compilerClass. |
|
1050 |
selectedText size > 0 ifTrue:[ |
|
1051 |
self windowGroup withWaitCursorDo:[ |
|
1052 |
"/ hack, for now and expecco; must ask the Parser eventually... |
|
1053 |
(compilerClass notNil and:[compilerClass includesBehavior:JavaScriptParser]) ifTrue:[ |
|
1054 |
"/ selector is in one piece anyway |
|
1055 |
(selectedText includes:$_) ifFalse:[ |
|
1056 |
"/ zero or one args - sigh (need to parse more to figure this out) |
|
1057 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:1. |
|
1058 |
selectedText := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:0. |
|
1059 |
] ifTrue:[ |
|
1060 |
"/ count _#s plus one arg - sigh |
|
1061 |
na := (selectedText occurrencesOf:$_) + 1. |
|
1062 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:na |
|
1063 |
]. |
|
1064 |
] ifFalse:[ |
|
1065 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
|
1066 |
]. |
|
1067 |
] |
|
1068 |
]. |
|
1069 |
^Array with: selector with: selectedText |
|
1070 |
||
1071 |
"Created: / 30-06-2011 / 19:49:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1072 |
! |
|
1073 |
||
1074 |
implementorsOf: selector |
|
1075 |
||
10877 | 1076 |
selector isNil ifTrue:[^#()]. |
10262 | 1077 |
^SystemBrowser |
1078 |
findImplementorsOf: selector |
|
1079 |
in: Smalltalk allClasses |
|
1080 |
ignoreCase: false |
|
1081 |
||
1082 |
"Created: / 26-12-2007 / 11:37:11 / janfrog" |
|
10877 | 1083 |
"Modified: / 18-11-2011 / 14:58:17 / cg" |
10262 | 1084 |
! |
1085 |
||
1086 |
sendersOf: selector |
|
1087 |
||
10877 | 1088 |
selector isNil ifTrue:[^#()]. |
10262 | 1089 |
^SystemBrowser |
1090 |
findSendersOf: selector |
|
1091 |
in: Smalltalk allClasses |
|
1092 |
ignoreCase: false |
|
1093 |
||
1094 |
"Created: / 26-12-2007 / 11:37:22 / janfrog" |
|
1095 |
"Modified: / 30-06-2011 / 19:32:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10877 | 1096 |
"Modified: / 18-11-2011 / 14:58:19 / cg" |
10262 | 1097 |
! ! |
1098 |
||
9985 | 1099 |
!CodeView2 methodsFor:'delegation'! |
1100 |
||
1101 |
doesNotUnderstand: aMessage |
|
1102 |
||
1103 |
((textView respondsTo: aMessage selector) |
|
1104 |
and:[(TraceSelectors includes:aMessage selector) not]) |
|
1105 |
ifTrue:[^aMessage sendTo: textView]. |
|
1106 |
^super doesNotUnderstand: aMessage |
|
1107 |
||
1108 |
"Created: / 13-02-2010 / 23:27:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1109 |
"Modified: / 14-02-2010 / 09:53:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1110 |
! |
|
1111 |
||
1112 |
hasSelection |
|
1113 |
||
1114 |
^textView hasSelection |
|
1115 |
||
1116 |
"Created: / 14-02-2010 / 09:53:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1117 |
! ! |
|
1118 |
||
1119 |
!CodeView2 methodsFor:'delegation - drawing'! |
|
1120 |
||
1121 |
drawLine:lineNo in: view atX:x y:y width: w height:h from:startCol to:endColOrNil with:fg and:bg |
|
1122 |
"See the comment in |
|
1123 |
CodeViewService>>drawLine:in:atX..." |
|
1124 |
||
1125 |
services do:[:each| |
|
1126 |
each drawLine:lineNo in: view atX:x y:y width: w height:h from:startCol to:endColOrNil with:fg and:bg |
|
1127 |
] |
|
1128 |
||
1129 |
"Created: / 17-06-2011 / 13:50:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10767 | 1130 |
"Modified: / 06-10-2011 / 14:14:04 / cg" |
9985 | 1131 |
! |
1132 |
||
1133 |
redrawVisibleLine: visLineNr |
|
1134 |
||
1135 |
"Created: / 07-03-2010 / 14:44:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1136 |
! |
|
1137 |
||
1138 |
redrawVisibleLine:visLine col:colNr |
|
1139 |
||
1140 |
"Modified: / 05-11-2007 / 17:35:53 / cg" |
|
1141 |
"Modified: / 07-03-2010 / 14:45:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1142 |
! |
|
1143 |
||
1144 |
redrawVisibleLine:visLine from:startCol |
|
1145 |
||
1146 |
"Modified: / 07-03-2010 / 14:46:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1147 |
! |
|
1148 |
||
1149 |
redrawVisibleLine:visLine from:startCol to:endCol |
|
1150 |
||
1151 |
"Modified: / 07-03-2010 / 14:46:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1152 |
! ! |
|
1153 |
||
1154 |
!CodeView2 methodsFor:'delegation - events'! |
|
1155 |
||
1156 |
buttonMotion: button x:x y:y in: view |
|
1157 |
||
1158 |
"Delegates events to services. Answers true iff at least |
|
1159 |
one service handler method returns true. In that case, |
|
1160 |
the event is is NOT processes by the view." |
|
1161 |
||
10767 | 1162 |
^ services |
9985 | 1163 |
inject: false |
1164 |
into: |
|
1165 |
[:processed :service| |
|
1166 |
service isEnabled |
|
1167 |
ifFalse: |
|
1168 |
[processed] |
|
1169 |
ifTrue: |
|
1170 |
[processed | ((service buttonMotion: button x:x y:y in: view) == true)]]. |
|
1171 |
||
1172 |
"Modified: / 07-03-2010 / 13:53:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10767 | 1173 |
"Modified: / 06-10-2011 / 14:13:57 / cg" |
9985 | 1174 |
! |
1175 |
||
1176 |
buttonPress: button x:x y:y in: view |
|
1177 |
"Delegates events to services. Answers true iff at least |
|
1178 |
one service handler method returns true. In that case, |
|
1179 |
the event is is NOT processes by the view." |
|
1180 |
||
10767 | 1181 |
^ services |
9985 | 1182 |
inject: false |
1183 |
into: |
|
1184 |
[:processed :service| |
|
1185 |
service isEnabled |
|
1186 |
ifFalse: |
|
1187 |
[processed] |
|
1188 |
ifTrue: |
|
1189 |
[processed | ((service buttonPress: button x:x y:y in: view) == true)]]. |
|
1190 |
||
1191 |
"Modified: / 07-03-2010 / 13:53:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10767 | 1192 |
"Modified: / 06-10-2011 / 14:14:00 / cg" |
9985 | 1193 |
! |
1194 |
||
1195 |
keyPress: key x:x y:y in: view |
|
1196 |
||
1197 |
"Delegates events to services. Answers true iff at least |
|
1198 |
one service handler method returns true. In that case, |
|
1199 |
the event is is NOT processes by the view." |
|
1200 |
||
10767 | 1201 |
^ services |
9985 | 1202 |
inject: false |
1203 |
into: |
|
1204 |
[:processed :service| |
|
1205 |
service isEnabled |
|
1206 |
ifFalse: |
|
1207 |
[processed] |
|
1208 |
ifTrue: |
|
1209 |
[processed | ((service keyPress: key x:x y:y in: view) == true)]]. |
|
1210 |
||
1211 |
"Modified: / 07-03-2010 / 13:54:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10767 | 1212 |
"Modified: / 06-10-2011 / 14:14:11 / cg" |
9985 | 1213 |
! |
1214 |
||
1215 |
keyRelease: key x:x y:y in: view |
|
1216 |
||
1217 |
"Delegates events to services. Answers true iff at least |
|
1218 |
one service handler method returns true. In that case, |
|
1219 |
the event is is NOT processes by the view." |
|
1220 |
||
10767 | 1221 |
^ services |
9985 | 1222 |
inject: false |
1223 |
into: |
|
1224 |
[:processed :service| |
|
1225 |
service isEnabled |
|
1226 |
ifFalse: |
|
1227 |
[processed] |
|
1228 |
ifTrue: |
|
1229 |
[processed | ((service keyRelease: key x:x y:y in: view) == true)]]. |
|
1230 |
||
1231 |
"Modified: / 07-03-2010 / 13:54:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10767 | 1232 |
"Modified: / 06-10-2011 / 14:14:13 / cg" |
9985 | 1233 |
! |
1234 |
||
10224 | 1235 |
linesDeletedFrom: start to: end |
1236 |
||
1237 |
services do: [:each | |
|
1238 |
each isEnabled ifTrue: [ |
|
1239 |
each linesDeletedFrom: start to: end |
|
1240 |
] |
|
1241 |
]. |
|
1242 |
||
1243 |
"Created: / 06-07-2011 / 17:12:54 / jv" |
|
10767 | 1244 |
"Modified: / 06-10-2011 / 14:14:16 / cg" |
10781 | 1245 |
"Modified: / 07-10-2011 / 19:14:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10224 | 1246 |
! |
1247 |
||
1248 |
linesInsertedFrom: start to: end |
|
1249 |
||
1250 |
services do: [:each | |
|
1251 |
each isEnabled ifTrue: [ |
|
1252 |
each linesInsertedFrom: start to: end |
|
1253 |
] |
|
1254 |
]. |
|
1255 |
||
1256 |
"Created: / 06-07-2011 / 17:12:48 / jv" |
|
10767 | 1257 |
"Modified: / 06-10-2011 / 14:14:20 / cg" |
10224 | 1258 |
! |
1259 |
||
1260 |
linesModifiedFrom: start to: end |
|
1261 |
||
1262 |
services do: [:each | |
|
1263 |
each isEnabled ifTrue: [ |
|
1264 |
each linesModifiedFrom: start to: end |
|
1265 |
] |
|
1266 |
]. |
|
1267 |
||
1268 |
"Created: / 06-07-2011 / 17:12:58 / jv" |
|
10767 | 1269 |
"Modified: / 06-10-2011 / 14:13:44 / cg" |
10224 | 1270 |
! |
1271 |
||
9985 | 1272 |
scrollDown: nLines in: view |
1273 |
||
1274 |
view == textView |
|
1275 |
ifTrue: |
|
1276 |
["/my text view scrolled... |
|
1277 |
synchronizedCodeViews do:[:codeView|codeView scrollDown: nLines in: view]] |
|
1278 |
ifFalse: |
|
1279 |
["/other code view scrolls and I'm notified about that |
|
1280 |
textView basicScrollDown: nLines] |
|
1281 |
||
1282 |
"Created: / 06-04-2010 / 14:02:39 / Jakub <zelenja7@fel.cvut.cz>" |
|
1283 |
! |
|
1284 |
||
1285 |
scrollUp: nLines in: view |
|
1286 |
||
1287 |
view == textView |
|
1288 |
ifTrue: |
|
1289 |
["/my text view scrolled... |
|
1290 |
synchronizedCodeViews do:[:codeView|codeView scrollUp: nLines in: view]] |
|
1291 |
ifFalse: |
|
1292 |
["/other code view scrolls and I'm notified about that |
|
1293 |
textView basicScrollUp: nLines] |
|
1294 |
||
1295 |
"Created: / 06-04-2010 / 14:02:39 / Jakub <zelenja7@fel.cvut.cz>" |
|
1296 |
! ! |
|
1297 |
||
1298 |
!CodeView2 methodsFor:'diff mode'! |
|
1299 |
||
1300 |
recomputeDiff:view |
|
1301 |
|t1 t2 pom diffHelper view2| |
|
1302 |
||
1303 |
t1 := view getNewOriginText. |
|
1304 |
synchronizedCodeViews do:[:codeView | |
|
1305 |
view2 := codeView |
|
1306 |
]. |
|
1307 |
view changedDiffText:false. |
|
1308 |
view2 changedDiffText:false. |
|
1309 |
t2 := view2 getNewOriginText. |
|
1310 |
pom := DiffCodeView2 new. |
|
1311 |
(view == textView) ifTrue:[ |
|
1312 |
diffHelper := pom computeDiffDataForText1:t1 text2:t2. |
|
1313 |
(view) contents:(diffHelper text1). |
|
1314 |
(view) deletedLines:(diffHelper deleted). |
|
1315 |
(view) changedLines:(diffHelper changed). |
|
1316 |
(view) originDiffText:t1. |
|
1317 |
(view) emptyLines:(diffHelper inserted). |
|
1318 |
(view) changedLines:(diffHelper changed). |
|
1319 |
(view2) contents:(diffHelper text2). |
|
1320 |
(view2) insertedLines:(diffHelper inserted). |
|
1321 |
(view2) changedLines:(diffHelper changed). |
|
1322 |
(view2) originDiffText:t2. |
|
1323 |
(view2) emptyLines:(diffHelper deleted). |
|
1324 |
]. |
|
1325 |
||
1326 |
"Modified: / 22-06-2010 / 23:35:41 / Jakub <zelenja7@fel.cvut.cz>" |
|
1327 |
"Modified: / 23-06-2010 / 17:25:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1328 |
! ! |
|
1329 |
||
1330 |
!CodeView2 methodsFor:'initialization'! |
|
1331 |
||
1332 |
initialize |
|
1333 |
"Invoked when a new instance is created." |
|
1334 |
"Call super initialize" |
|
1335 |
||
1336 |
super initialize. |
|
1337 |
"Now set up some visual properties" |
|
1338 |
self level:-1. |
|
1339 |
"Now initialize sub-views" |
|
1340 |
showGutterChannel := (ValueHolder with: true). |
|
1341 |
showGutterChannel addDependent: self. |
|
10793
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
1342 |
showAcceptCancelBarChannel := (ValueHolder with: (UserPreferences current codeView2ShowAcceptCancel)). |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
1343 |
|
9985 | 1344 |
self initializeGutterView. |
1345 |
self initializeTextView. |
|
1346 |
gutterView setCodeView:self. |
|
1347 |
textView setCodeView:self. |
|
1348 |
modifiedChannel := ValueHolder with:false. |
|
1349 |
diffMode := false. |
|
1350 |
synchronizedCodeViews := #(). |
|
10767 | 1351 |
|
1352 |
servicesFromClient := false. |
|
9985 | 1353 |
services := OrderedCollection new. |
10834 | 1354 |
self initializeServices. |
9985 | 1355 |
|
1356 |
"Modified: / 14-12-2009 / 13:59:53 / Jindra <a>" |
|
1357 |
"Modified: / 06-04-2010 / 13:56:35 / Jakub <zelenja7@fel.cvut.cz>" |
|
10767 | 1358 |
"Modified: / 06-10-2011 / 14:15:48 / cg" |
10834 | 1359 |
"Modified: / 18-10-2011 / 19:17:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 1360 |
! |
1361 |
||
1362 |
initializeGutterView |
|
1363 |
||
1364 |
gutterView := CodeView2::GutterView new. |
|
1365 |
gutterView origin:(0.0 @ 0.0) corner:(gutterView preferredWidth @ 1.0). |
|
1366 |
showGutterChannel value ifTrue:[self addSubView: gutterView]. |
|
1367 |
||
1368 |
"Created: / 02-09-2009 / 21:35:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1369 |
"Modified: / 23-06-2010 / 19:14:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1370 |
! |
|
1371 |
||
1372 |
initializeServices |
|
1373 |
| serviceClasses | |
|
10409 | 1374 |
|
10755 | 1375 |
"/ only do it, if the services have not yet been defined by the user of this view |
1376 |
"/ (FileBrowser does not want Smalltalk-specific services) |
|
10767 | 1377 |
servicesFromClient ifFalse:[ |
10755 | 1378 |
serviceClasses := CodeViewService availableServices sort:[:a :b|name < b name]. |
1379 |
serviceClasses do:[:cls| |
|
1380 |
self registerService: cls new |
|
1381 |
]. |
|
1382 |
]. |
|
9985 | 1383 |
|
10409 | 1384 |
"Modified: / 27-07-2011 / 11:37:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10767 | 1385 |
"Modified: / 06-10-2011 / 14:16:01 / cg" |
9985 | 1386 |
! |
1387 |
||
1388 |
initializeTextView |
|
1389 |
||
1390 |
"Initialize textView. gutterView have to be |
|
1391 |
already initialized!!" |
|
1392 |
||
1393 |
textViewScroller := HVScrollableView for: CodeView2::TextView in: self. |
|
1394 |
textViewScroller |
|
1395 |
origin: ((self showGutter ifTrue:[gutterView width] ifFalse:[0.0]) @ 0.0) |
|
1396 |
corner: 1.0@1.0; |
|
1397 |
level: 0. |
|
1398 |
textView := textViewScroller scrolledView. |
|
1399 |
textView level: 0. |
|
1400 |
||
1401 |
textView modifiedChannel addDependent: self. |
|
1402 |
||
1403 |
"Created: / 02-09-2009 / 21:36:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1404 |
"Modified: / 23-06-2010 / 19:38:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1405 |
! ! |
|
1406 |
||
1407 |
!CodeView2 methodsFor:'menu actions'! |
|
1408 |
||
10689 | 1409 |
accept |
1410 |
textView accept |
|
1411 |
||
1412 |
"Created: / 07-09-2011 / 21:29:07 / cg" |
|
1413 |
! |
|
1414 |
||
10375 | 1415 |
again |
1416 |
textView again |
|
1417 |
||
1418 |
"Created: / 16-02-2010 / 19:36:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1419 |
"Created: / 22-07-2011 / 17:44:31 / cg" |
|
1420 |
! |
|
1421 |
||
9985 | 1422 |
browseImplementorsOfIt |
10262 | 1423 |
|
1424 |
textView browseImplementorsOfIt |
|
1425 |
||
1426 |
"Modified: / 30-06-2011 / 19:22:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9985 | 1427 |
! |
1428 |
||
1429 |
browseSendersOfIt |
|
10262 | 1430 |
|
1431 |
textView browseSendersOfIt |
|
1432 |
||
1433 |
"Modified: / 30-06-2011 / 19:22:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9985 | 1434 |
! |
1435 |
||
1436 |
copySelection |
|
1437 |
||
1438 |
textView copySelection |
|
1439 |
||
1440 |
"Created: / 16-02-2010 / 19:36:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1441 |
! |
|
1442 |
||
1443 |
cut |
|
1444 |
||
1445 |
textView cut |
|
1446 |
||
1447 |
"Created: / 16-02-2010 / 19:36:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1448 |
! |
|
1449 |
||
1450 |
doIt |
|
1451 |
||
1452 |
textView doIt |
|
1453 |
||
1454 |
"Modified: / 16-02-2010 / 19:38:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1455 |
! |
|
1456 |
||
1457 |
inspectIt |
|
1458 |
||
1459 |
textView inspectIt |
|
1460 |
||
1461 |
"Modified: / 16-02-2010 / 19:38:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1462 |
! |
|
1463 |
||
1464 |
inspectSelectedSelector |
|
1465 |
||
1466 |
self error: 'Not yet implemented' |
|
1467 |
||
1468 |
"Modified: / 14-02-2010 / 15:58:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1469 |
! |
|
1470 |
||
1471 |
inspectSyntaxElements |
|
1472 |
||
1473 |
syntaxElements inspect |
|
1474 |
||
1475 |
"Modified: / 14-02-2010 / 15:57:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1476 |
! |
|
1477 |
||
1478 |
inspectView |
|
1479 |
||
1480 |
self inspect |
|
1481 |
||
1482 |
"Modified: / 25-03-2010 / 17:58:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1483 |
! |
|
1484 |
||
1485 |
pasteOrReplace |
|
1486 |
||
1487 |
textView pasteOrReplace |
|
1488 |
||
1489 |
"Created: / 16-02-2010 / 19:37:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1490 |
! |
|
1491 |
||
1492 |
printIt |
|
1493 |
||
1494 |
textView printIt |
|
1495 |
||
1496 |
"Modified: / 16-02-2010 / 19:38:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1497 |
! |
|
1498 |
||
1499 |
profileIt |
|
1500 |
||
1501 |
textView profileIt |
|
1502 |
||
1503 |
"Created: / 27-08-2010 / 22:12:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1504 |
! |
|
1505 |
||
1506 |
undo |
|
1507 |
||
1508 |
textView undo |
|
1509 |
||
1510 |
"Created: / 16-02-2010 / 19:35:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1511 |
! ! |
|
1512 |
||
1513 |
!CodeView2 methodsFor:'menus-dynamic'! |
|
1514 |
||
1515 |
editMenu |
|
10780 | 1516 |
| editMenu superEditMenu moreMenu moreMenuItem | |
1517 |
||
1518 |
superEditMenu := textView superEditMenu. |
|
1519 |
moreMenu := superEditMenu subMenuAt: superEditMenu numberOfItems. |
|
1520 |
||
1521 |
textView sensor ctrlDown ifTrue:[ |
|
1522 |
^superEditMenu |
|
1523 |
]. |
|
10293 | 1524 |
|
9985 | 1525 |
editMenu := self class editMenu decodeAsLiteralArray. |
1526 |
moreMenuItem := editMenu menuItemLabeled: 'More'. |
|
1527 |
moreMenuItem submenu: moreMenu asMenu. |
|
1528 |
editMenu findGuiResourcesIn: self. |
|
1529 |
^editMenu |
|
1530 |
||
1531 |
"Created: / 25-12-2007 / 10:10:01 / janfrog" |
|
1532 |
"Modified: / 25-12-2007 / 19:50:53 / janfrog" |
|
1533 |
"Modified: / 18-10-2008 / 20:31:16 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
10293 | 1534 |
"Modified: / 08-07-2011 / 13:35:31 / cg" |
10780 | 1535 |
"Modified: / 07-10-2011 / 17:58:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 1536 |
! |
1537 |
||
10262 | 1538 |
implementorsMenu |
1539 |
||
1540 |
| selectorAndSelectedText selector selectedText implementors | |
|
1541 |
||
1542 |
selectedText := textView selectionAsString. |
|
1543 |
selectedText size > 0 ifTrue:[ |
|
1544 |
self windowGroup withWaitCursorDo:[ |
|
1545 |
selectorAndSelectedText := self extractSelectorAndSelectedTextFrom: selectedText. |
|
1546 |
selector := selectorAndSelectedText first. |
|
1547 |
selectedText := selectorAndSelectedText second. |
|
1548 |
||
1549 |
(selector notNil and:[selector = selectedText]) ifTrue:[ |
|
1550 |
implementors := (SystemBrowser |
|
1551 |
findImplementorsOfAny:(Array with:selectedText) |
|
1552 |
in:(Smalltalk allClasses) |
|
1553 |
ignoreCase:false) |
|
1554 |
||
1555 |
] ifFalse:[ |
|
1556 |
implementors := (SystemBrowser |
|
1557 |
findImplementorsOfAny:(Array with:selectedText with: selector) |
|
1558 |
in:(Smalltalk allClasses) |
|
1559 |
ignoreCase:false) |
|
1560 |
]. |
|
1561 |
] |
|
1562 |
] ifFalse:[ |
|
1563 |
implementors := #(). |
|
1564 |
]. |
|
1565 |
||
1566 |
^self implementorsMenu: implementors selector: (selector ? selectedText) |
|
1567 |
||
1568 |
"Modified: / 19-10-2008 / 08:16:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
1569 |
"Created: / 30-06-2011 / 19:28:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1570 |
! |
|
1571 |
||
9985 | 1572 |
implementorsMenu: implementors selector: selector |
1573 |
| menu| |
|
1574 |
||
1575 |
menu := Menu new. |
|
10465 | 1576 |
implementors isEmptyOrNil ifTrue:[ |
9985 | 1577 |
menu addItem:(MenuItem label:'No implementors found') disable |
1578 |
] ifFalse:[ |
|
1579 |
menu addItem:(MenuItem |
|
1580 |
label:(selector storeString , (' (all implementors) ') asText allItalic) |
|
1581 |
value:[ |
|
1582 |
self browseMethods:implementors |
|
1583 |
label:'Implementors of ' , selector storeString |
|
1584 |
]). |
|
1585 |
menu addSeparator. |
|
1586 |
implementors do:[:mth | |
|
1587 |
menu |
|
1588 |
addItem:(MenuItem label:(selector storeString |
|
1589 |
, (' in ' , mth containingClass name asText allBold)) |
|
1590 |
value:[ self browseMethod:mth label: 'Implementor of ' , selector storeString ]) |
|
1591 |
] |
|
1592 |
]. |
|
1593 |
^ menu |
|
1594 |
||
1595 |
"Modified: / 19-10-2008 / 08:16:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
1596 |
"Created: / 14-02-2010 / 19:39:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10465 | 1597 |
"Modified: / 04-08-2011 / 19:05:15 / cg" |
9985 | 1598 |
! |
1599 |
||
10262 | 1600 |
sendersMenu |
1601 |
||
1602 |
| selectorAndSelectedText selector selectedText senders | |
|
1603 |
||
1604 |
selectedText := textView selectionAsString. |
|
1605 |
selectedText size > 0 ifTrue:[ |
|
1606 |
self windowGroup withWaitCursorDo:[ |
|
1607 |
selectorAndSelectedText := self extractSelectorAndSelectedTextFrom: selectedText. |
|
1608 |
selector := selectorAndSelectedText first. |
|
1609 |
selectedText := selectorAndSelectedText second. |
|
1610 |
||
1611 |
(selector notNil and:[selector = selectedText]) ifTrue:[ |
|
1612 |
senders := (SystemBrowser |
|
1613 |
findSendersOfAny:(Array with:selectedText) |
|
1614 |
in:(Smalltalk allClasses) |
|
1615 |
ignoreCase:false) |
|
1616 |
||
1617 |
] ifFalse:[ |
|
1618 |
senders := (SystemBrowser |
|
1619 |
findSendersOfAny:(Array with:selectedText with: selector) |
|
1620 |
in:(Smalltalk allClasses) |
|
1621 |
ignoreCase:false) |
|
1622 |
]. |
|
1623 |
] |
|
1624 |
] ifFalse:[ |
|
1625 |
senders := #(). |
|
1626 |
]. |
|
1627 |
||
1628 |
^self sendersMenu: senders selector: (selector ? selectedText) |
|
1629 |
||
1630 |
"Modified: / 19-10-2008 / 08:16:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
1631 |
"Created: / 30-06-2011 / 19:28:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1632 |
! |
|
1633 |
||
9985 | 1634 |
sendersMenu: senders selector: selector |
10630
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
1635 |
| menu shownSenderItems numCut| |
9985 | 1636 |
|
10262 | 1637 |
menu := Menu new. |
10465 | 1638 |
senders isEmptyOrNil ifTrue:[ |
9985 | 1639 |
menu addItem:(MenuItem label:'No senders found') disable |
1640 |
] ifFalse:[ |
|
1641 |
menu addItem:(MenuItem |
|
1642 |
label:(selector storeString , (' (all senders)') asText allItalic) |
|
1643 |
value:[ |
|
1644 |
self browseMethods:senders |
|
1645 |
label:'Senders of ' , selector storeString |
|
1646 |
]). |
|
1647 |
menu addSeparator. |
|
10630
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
1648 |
shownSenderItems := (senders size > 20) ifTrue:[senders copyTo:20] ifFalse:[senders]. |
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
1649 |
numCut := senders size - 20. |
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
1650 |
shownSenderItems do:[:mth | |
9985 | 1651 |
menu |
1652 |
addItem:(MenuItem label:(mth selector storeString |
|
1653 |
, (' in ' , mth containingClass name asText allBold)) |
|
1654 |
value:[ self browseMethod:mth label: 'Sender of ' , selector storeString ]) |
|
10630
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
1655 |
]. |
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
1656 |
numCut > 0 ifTrue:[ |
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
1657 |
menu addSeparator. |
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
1658 |
menu addItem:(MenuItem label:('... %1 more senders not shown here' bindWith:numCut)) disable |
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
1659 |
]. |
9985 | 1660 |
]. |
1661 |
^ menu |
|
1662 |
||
1663 |
"Modified: / 19-10-2008 / 08:17:00 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
1664 |
"Created: / 14-02-2010 / 19:40:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10262 | 1665 |
"Modified: / 07-07-2011 / 14:51:54 / jv" |
10630
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
1666 |
"Modified: / 21-08-2011 / 11:44:00 / cg" |
9985 | 1667 |
! |
1668 |
||
1669 |
servicesMenu |
|
10293 | 1670 |
|menu item anyService| |
1671 |
||
9985 | 1672 |
menu := Menu new. |
10293 | 1673 |
|
1674 |
item := MenuItem label:(resources string:'Show Gutter'). |
|
1675 |
item indication:(self showGutterChannel). |
|
1676 |
menu addItem:item. |
|
1677 |
menu addSeparator. |
|
1678 |
||
1679 |
anyService := false. |
|
1680 |
services do:[:service | |
|
1681 |
|item| |
|
1682 |
||
1683 |
item := MenuItem label:(resources string:service label). |
|
1684 |
item indication:((AspectAdaptor forAspect:#enabled) subject:service). |
|
1685 |
menu addItem:item. |
|
1686 |
anyService := true. |
|
1687 |
]. |
|
1688 |
||
1689 |
anyService ifTrue:[ |
|
1690 |
menu addSeparator. |
|
1691 |
]. |
|
1692 |
||
1693 |
item := MenuItem label:(resources string:'Debug'). |
|
1694 |
item submenuChannel:[ self class debugMenu ]. |
|
1695 |
menu addItem:item. |
|
1696 |
||
1697 |
^ menu |
|
9985 | 1698 |
|
1699 |
"Created: / 07-03-2010 / 14:03:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10767 | 1700 |
"Modified: / 06-10-2011 / 14:14:30 / cg" |
9985 | 1701 |
! ! |
1702 |
||
1703 |
!CodeView2 methodsFor:'private'! |
|
1704 |
||
1705 |
codeCompletion |
|
1706 |
|cls |
|
1707 |
"/ crsrPos interval node checkedNode |
|
1708 |
"/ char start stop selectorSoFar matchingSelectors |
|
1709 |
| |
|
1710 |
||
1711 |
||
1712 |
cls := self classHolder value. |
|
1713 |
cls isNil ifTrue:[ |
|
1714 |
self showInfo:'No class'. |
|
1715 |
^ self. |
|
1716 |
]. |
|
1717 |
UserInformation handle:[:ex | |
|
1718 |
self showInfo:(ex messageText). |
|
1719 |
ex proceed. |
|
1720 |
] do:[ |
|
1721 |
self withWaitCursorDo:[ |
|
1722 |
DoWhatIMeanSupport codeCompletionForClass:cls codeView:self. |
|
1723 |
] |
|
1724 |
]. |
|
1725 |
^ self. |
|
1726 |
||
1727 |
"/ |
|
1728 |
"/ interval := self selectedInterval. |
|
1729 |
"/ interval isEmpty ifTrue:[ |
|
1730 |
"/ crsrPos := codeView characterPositionOfCursor - 1. |
|
1731 |
"/ char := codeView characterUnderCursor. |
|
1732 |
"/ [crsrPos > 1 and:[char isSeparator or:['.' includes:char]]] whileTrue:[ |
|
1733 |
"/ crsrPos := crsrPos - 1. |
|
1734 |
"/ char := codeView characterAtCharacterPosition:crsrPos. |
|
1735 |
"/ ]. |
|
1736 |
"/ interval := crsrPos to:crsrPos. |
|
1737 |
"/ ]. |
|
1738 |
"/ |
|
1739 |
"/ node := self findNodeForInterval:interval allowErrors:true. |
|
1740 |
"/ [node isNil] whileTrue:[ |
|
1741 |
"/ "/ expand to the left ... |
|
1742 |
"/ interval start > 1 ifFalse:[ |
|
1743 |
"/ self showInfo:'No parseNode found'. |
|
1744 |
"/ ^ self. |
|
1745 |
"/ ]. |
|
1746 |
"/ interval start:(interval start - 1). |
|
1747 |
"/ node := self findNodeForInterval:interval allowErrors:true. |
|
1748 |
"/ ]. |
|
1749 |
"/ |
|
1750 |
"/ node isVariable ifTrue:[ |
|
1751 |
"/ self codeCompletionForVariable:node inClass:cls. |
|
1752 |
"/ ^ self. |
|
1753 |
"/ ]. |
|
1754 |
"/ |
|
1755 |
"/ checkedNode := node. |
|
1756 |
"/ [checkedNode notNil] whileTrue:[ |
|
1757 |
"/ checkedNode isMessage ifTrue:[ |
|
1758 |
"/ self codeCompletionForMessage:checkedNode inClass:cls. |
|
1759 |
"/ ^ self |
|
1760 |
"/ ]. |
|
1761 |
"/ checkedNode isMethod ifTrue:[ |
|
1762 |
"/ self codeCompletionForMethod:checkedNode inClass:cls. |
|
1763 |
"/ ^ self. |
|
1764 |
"/ ]. |
|
1765 |
"/ checkedNode := checkedNode parent. |
|
1766 |
"/ ]. |
|
1767 |
"/ |
|
1768 |
"/ self showInfo:'Node is neither variable nor message.'. |
|
1769 |
||
1770 |
"Modified: / 04-07-2006 / 18:48:26 / fm" |
|
1771 |
"Modified: / 20-11-2006 / 12:30:59 / cg" |
|
1772 |
"Modified: / 16-02-2010 / 10:53:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1773 |
! |
|
1774 |
||
1775 |
reallyModified |
|
1776 |
"check for modified code by comparing the source against |
|
1777 |
the codeViews contents. |
|
1778 |
Thats the true modified value (in case user undid its changes, |
|
1779 |
and the displayed text is actually original" |
|
1780 |
||
1781 |
|modified changedSource originalSource s1 s2| |
|
1782 |
||
1783 |
textView modified ifTrue:[^true]. |
|
1784 |
||
1785 |
"/ higher prio to prevent it from being changed while we convert it (by editing) |
|
1786 |
Processor activeProcess |
|
1787 |
withHigherPriorityDo:[ |
|
1788 |
changedSource := textView contentsAsString asStringCollection. |
|
1789 |
]. |
|
1790 |
changedSource := changedSource collect:[:line | line string withoutTrailingSeparators withTabsExpanded]. |
|
1791 |
changedSource := changedSource collect:[:line | line isEmpty ifTrue:[nil] ifFalse:[line]]. |
|
1792 |
[changedSource size > 0 and:[changedSource last isNil]] whileTrue:[ |
|
1793 |
changedSource := changedSource copyWithoutLast:1 |
|
1794 |
]. |
|
1795 |
changedSource := changedSource asString. |
|
1796 |
||
1797 |
originalSource := textView model value ? ''. |
|
1798 |
||
1799 |
originalSource := originalSource asStringCollection. |
|
1800 |
originalSource := originalSource collect:[:line | line string withoutTrailingSeparators withTabsExpanded]. |
|
1801 |
originalSource := originalSource collect:[:line | line isEmpty ifTrue:[nil] ifFalse:[line]]. |
|
1802 |
[originalSource size > 0 and:[originalSource last isNil]] whileTrue:[ |
|
1803 |
originalSource := originalSource copyWithoutLast:1 |
|
1804 |
]. |
|
1805 |
||
1806 |
s1 := originalSource asString. |
|
1807 |
s2 := changedSource asString. |
|
1808 |
modified := (s1 ~= s2). |
|
1809 |
||
1810 |
^ modified |
|
1811 |
||
1812 |
"Created: / 06-02-2010 / 19:59:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1813 |
! |
|
1814 |
||
1815 |
showInfo: message |
|
1816 |
||
1817 |
| app | |
|
1818 |
(app := self topView application) ifNotNil: |
|
1819 |
[(app respondsTo: #showInfo:) ifTrue: |
|
1820 |
[app showInfo: message]]. |
|
1821 |
||
1822 |
"Modified: / 13-02-2010 / 23:25:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1823 |
! ! |
|
1824 |
||
1825 |
!CodeView2 methodsFor:'private-accessing'! |
|
1826 |
||
1827 |
gutterView |
|
1828 |
||
1829 |
^gutterView |
|
1830 |
||
1831 |
"Created: / 14-02-2010 / 15:21:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1832 |
! |
|
1833 |
||
1834 |
syntaxElementSelection |
|
1835 |
^ syntaxElementSelection |
|
1836 |
! |
|
1837 |
||
1838 |
syntaxElementSelection:something |
|
1839 |
syntaxElementSelection := something. |
|
1840 |
! |
|
1841 |
||
1842 |
syntaxElements |
|
1843 |
^ syntaxElements |
|
1844 |
! |
|
1845 |
||
1846 |
syntaxElements:something |
|
1847 |
syntaxElements := something. |
|
1848 |
! |
|
1849 |
||
1850 |
textView |
|
1851 |
||
1852 |
^textView |
|
1853 |
||
1854 |
"Created: / 14-02-2010 / 15:21:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1855 |
! |
|
1856 |
||
1857 |
textViewScroller |
|
1858 |
||
1859 |
^textViewScroller |
|
1860 |
||
1861 |
"Created: / 14-02-2010 / 15:21:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1862 |
! ! |
|
1863 |
||
1864 |
!CodeView2 methodsFor:'services'! |
|
1865 |
||
1866 |
registerService: aCodeViewService |
|
1867 |
||
1868 |
services add: aCodeViewService. |
|
1869 |
aCodeViewService registerIn: self |
|
1870 |
||
1871 |
"Created: / 06-03-2010 / 19:19:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1872 |
! |
|
1873 |
||
1874 |
underService: aCodeViewService |
|
1875 |
||
1876 |
services remove: aCodeViewService ifAbsent:[^self]. |
|
1877 |
aCodeViewService unregister. |
|
1878 |
||
1879 |
"Created: / 06-03-2010 / 19:21:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1880 |
! ! |
|
1881 |
||
1882 |
!CodeView2 methodsFor:'testing'! |
|
1883 |
||
10722 | 1884 |
isCodeView2 |
1885 |
||
1886 |
^true |
|
1887 |
||
1888 |
"Created: / 20-07-2010 / 15:43:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1889 |
! |
|
1890 |
||
9985 | 1891 |
isTextView |
1892 |
||
1893 |
^true |
|
1894 |
||
1895 |
"Created: / 14-02-2010 / 22:13:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1896 |
! ! |
|
1897 |
||
1898 |
!CodeView2::GutterView methodsFor:'accessing'! |
|
1899 |
||
1900 |
setTextView: aTextView |
|
1901 |
||
1902 |
self assert: textView isNil message:'Attempting to set textView twice'. |
|
1903 |
textView := aTextView. |
|
1904 |
||
10577 | 1905 |
"/ self backgroundPaint: textView backgroundPaint darkened lighter. |
1906 |
self viewBackground: (View defaultBackgroundColor). "/ textView backgroundPaint darkened lighter. |
|
9985 | 1907 |
self paint: textView paint. |
1908 |
self font: textView font. |
|
1909 |
||
1910 |
"Created: / 02-09-2009 / 21:55:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1911 |
"Modified: / 14-12-2009 / 15:09:29 / Jindra <a>" |
|
1912 |
"Modified: / 09-02-2010 / 20:03:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10577 | 1913 |
"Modified: / 17-08-2011 / 15:15:09 / cg" |
9985 | 1914 |
! |
1915 |
||
1916 |
setTextViewScroller:aScr |
|
1917 |
textViewScroller := aScr. |
|
1918 |
||
1919 |
"Created: / 07-12-2009 / 22:36:31 / Jindra <a>" |
|
1920 |
! ! |
|
1921 |
||
1922 |
!CodeView2::GutterView methodsFor:'accessing-dimensions'! |
|
1923 |
||
10781 | 1924 |
acceptButtonBottom |
1925 |
||
10791 | 1926 |
^(self height * 0.6) ceiling. |
10781 | 1927 |
|
1928 |
"Created: / 07-10-2011 / 19:53:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1929 |
! |
|
1930 |
||
1931 |
cancelButtonBottom |
|
1932 |
||
10791 | 1933 |
^(self height * 0.8) ceiling. |
10781 | 1934 |
|
1935 |
"Created: / 07-10-2011 / 19:54:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1936 |
! |
|
1937 |
||
9985 | 1938 |
padding |
1939 |
||
1940 |
^self paddingLeft + self paddingRight |
|
10781 | 1941 |
+ (widthAcceptCancel ? 0) |
9985 | 1942 |
+ (widthAnnotations ? 0) |
1943 |
+ (widthDiffInfo ? 0) |
|
1944 |
||
1945 |
"Created: / 14-02-2010 / 22:28:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10781 | 1946 |
"Modified: / 07-10-2011 / 19:01:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1947 |
"Modified (format): / 07-10-2011 / 20:45:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9985 | 1948 |
! |
1949 |
||
1950 |
paddingLeft |
|
1951 |
||
1952 |
^0"px" |
|
1953 |
||
1954 |
"Created: / 14-02-2010 / 22:27:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1955 |
"Modified: / 16-06-2011 / 13:47:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1956 |
! |
|
1957 |
||
1958 |
paddingRight |
|
1959 |
||
1960 |
^0"px" |
|
1961 |
||
1962 |
"Created: / 14-02-2010 / 22:27:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1963 |
"Modified: / 16-06-2011 / 13:47:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1964 |
! |
|
1965 |
||
1966 |
preferredExtent |
|
1967 |
||
1968 |
| w h | |
|
1969 |
||
1970 |
explicitExtent ifNotNil:[^explicitExtent]. |
|
1971 |
preferredExtent ifNotNil:[^preferredExtent]. |
|
1972 |
||
1973 |
w := (self font widthOf:'00') + self padding. |
|
1974 |
h := textView ifNotNil:[textView height] ifNil:[self font height * 12]. |
|
1975 |
||
1976 |
^preferredExtent := w @ h |
|
1977 |
||
1978 |
"Modified: / 16-06-2011 / 14:03:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1979 |
! ! |
|
1980 |
||
10781 | 1981 |
!CodeView2::GutterView methodsFor:'actions'! |
1982 |
||
1983 |
accept |
|
1984 |
||
1985 |
textView accept |
|
1986 |
||
1987 |
"Created: / 07-10-2011 / 20:23:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1988 |
! |
|
1989 |
||
1990 |
cancel |
|
1991 |
||
1992 |
textView cancel |
|
1993 |
||
1994 |
"Created: / 07-10-2011 / 20:23:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
1995 |
! |
|
1996 |
||
1997 |
diff |
|
1998 |
||
1999 |
"Created: / 07-10-2011 / 20:23:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2000 |
! ! |
|
2001 |
||
9985 | 2002 |
!CodeView2::GutterView methodsFor:'change & update'! |
2003 |
||
2004 |
update:something with:aParameter from:changedObject |
|
2005 |
self shown ifFalse:[^self]. |
|
2006 |
||
10326 | 2007 |
(changedObject == textView) ifTrue:[ |
2008 |
(something == #sizeOfContents) ifTrue:[ |
|
2009 |
"/ cg: with that test, it does not update when the text becomes smaller... |
|
2010 |
"/ (firstLineShown ~= textView firstLineShown |
|
2011 |
"/ or:[lastLineShown ~= (textView lastLineShown - 1)]) ifTrue:[ |
|
10312 | 2012 |
self invalidate. |
2013 |
^self. |
|
10326 | 2014 |
"/ ] |
2015 |
]. |
|
10312 | 2016 |
]. |
10781 | 2017 |
(changedObject == textView reallyModifiedChannel) ifTrue:[ |
2018 |
self invalidate. |
|
2019 |
]. |
|
9985 | 2020 |
|
2021 |
"/ changedObject == someOfMyValueHolders ifTrue:[ |
|
2022 |
"/ self doSomethingApropriate. |
|
2023 |
"/ ^ self. |
|
2024 |
"/ ]. |
|
2025 |
super update:something with:aParameter from:changedObject |
|
2026 |
||
10326 | 2027 |
"Modified (format): / 15-07-2011 / 20:14:04 / cg" |
10781 | 2028 |
"Modified: / 07-10-2011 / 19:25:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 2029 |
! ! |
2030 |
||
2031 |
!CodeView2::GutterView methodsFor:'event handling'! |
|
2032 |
||
2033 |
buttonPress: btn x: x y: y |
|
2034 |
||
2035 |
"Do not allow clicking on line numbers..." |
|
10781 | 2036 |
(x <= (self paddingLeft + widthAcceptCancel)) ifTrue:[ |
2037 |
(y < self acceptButtonBottom) ifTrue:[ |
|
2038 |
self accept. |
|
2039 |
^self. |
|
2040 |
]. |
|
2041 |
(y < self cancelButtonBottom) ifTrue:[ |
|
2042 |
self cancel. |
|
2043 |
^self. |
|
2044 |
]. |
|
2045 |
self diff. |
|
2046 |
^self. |
|
2047 |
]. |
|
2048 |
||
2049 |
||
2050 |
((x > (self paddingLeft + widthAcceptCancel)) or: |
|
2051 |
[x < (self width - self paddingRight - widthDiffInfo)]) |
|
9985 | 2052 |
ifTrue:[ |
2053 |
(codeView buttonPress: btn x:x y:y in: self) |
|
2054 |
ifFalse:[super buttonPress: btn x: x y: y] |
|
2055 |
] ifFalse:[ |
|
2056 |
super buttonPress: btn x: x y: y |
|
2057 |
] |
|
2058 |
||
2059 |
"Created: / 17-06-2011 / 13:02:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2060 |
! ! |
|
2061 |
||
2062 |
!CodeView2::GutterView methodsFor:'initialization'! |
|
2063 |
||
2064 |
initialize |
|
2065 |
||
2066 |
super initialize. |
|
10781 | 2067 |
widthAcceptCancel := 16. |
2068 |
widthAnnotations := 8. |
|
9985 | 2069 |
widthDiffInfo := 5. |
2070 |
||
10781 | 2071 |
acceptColor := Color green lighter. |
2072 |
cancelColor := Color red lighter lighter. |
|
2073 |
diffColor := Color yellow lighter lighter. |
|
2074 |
||
9985 | 2075 |
"Created: / 16-06-2011 / 13:47:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2076 |
! |
|
2077 |
||
2078 |
setCodeView: aCodeView2 |
|
2079 |
||
2080 |
codeView := aCodeView2. |
|
2081 |
codeView addDependent: self. |
|
10784 | 2082 |
codeView reallyModifiedChannel addDependent: self. |
9985 | 2083 |
textView := aCodeView2 textView. |
2084 |
textView addDependent: self. |
|
2085 |
textViewScroller := aCodeView2 textViewScroller. |
|
10577 | 2086 |
"/ self backgroundPaint: (textView viewBackground "backgroundPaint" blendWith: (Color gray:80)). |
2087 |
self viewBackground: (View defaultBackgroundColor). |
|
9985 | 2088 |
|
2089 |
"Created: / 14-02-2010 / 15:19:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10577 | 2090 |
"Modified: / 17-08-2011 / 15:15:55 / cg" |
10784 | 2091 |
"Modified: / 08-10-2011 / 11:58:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 2092 |
! ! |
2093 |
||
2094 |
!CodeView2::GutterView methodsFor:'queries'! |
|
2095 |
||
2096 |
displayedString: line |
|
2097 |
"get text to display in gutter for specified list line number" |
|
2098 |
||
2099 |
^(line asString). |
|
2100 |
||
2101 |
"Created: / 14-12-2009 / 13:37:47 / Jindra <a>" |
|
2102 |
! |
|
2103 |
||
2104 |
lineColor:line |
|
2105 |
"return special color for given line if required, nil otherwise" |
|
2106 |
"used only if lineFont return nil" |
|
2107 |
||
2108 |
^nil |
|
2109 |
||
2110 |
"Created: / 14-12-2009 / 15:01:31 / Jindra <a>" |
|
2111 |
! |
|
2112 |
||
2113 |
lineDisplayable:line |
|
2114 |
"true if this list line can be displayed" |
|
2115 |
^(textView listLineIsVisible:line) |
|
2116 |
||
2117 |
"Created: / 14-12-2009 / 13:38:23 / Jindra <a>" |
|
2118 |
! |
|
2119 |
||
2120 |
lineFont:line |
|
2121 |
"return special font for given line if required, nil otherwise" |
|
2122 |
||
2123 |
^nil |
|
2124 |
||
2125 |
"Created: / 14-12-2009 / 14:40:17 / Jindra <a>" |
|
2126 |
! |
|
2127 |
||
2128 |
yOfTextViewLine:line |
|
2129 |
^(textView yOfLine:line) + 1 |
|
2130 |
||
2131 |
"Created: / 14-12-2009 / 13:35:07 / Jindra <a>" |
|
2132 |
! ! |
|
2133 |
||
2134 |
!CodeView2::GutterView methodsFor:'redrawing'! |
|
2135 |
||
10781 | 2136 |
redrawAcceptCancelBarX: x y: y width:w height:h |
2137 |
||
2138 |
| rw acceptBottom cancelBottom | |
|
2139 |
||
2140 |
x > ((self paddingLeft) + (widthAcceptCancel ? 0)) ifTrue:[ |
|
2141 |
^self. |
|
2142 |
]. |
|
10791 | 2143 |
rw := ((x + w) min: (self paddingLeft + (widthAcceptCancel ? 0))) - x. |
10781 | 2144 |
|
2145 |
||
2146 |
textView reallyModified ifFalse:[ |
|
2147 |
self fillRectangleX:x y:y width:rw height:h color: self viewBackground |
|
2148 |
] ifTrue:[ |
|
2149 |
acceptBottom := self acceptButtonBottom. |
|
2150 |
cancelBottom := self cancelButtonBottom. |
|
2151 |
y < acceptBottom ifTrue:[ |
|
2152 |
self fillRectangleX:x y:y width:rw height: ((y + h) min: acceptBottom) color: acceptColor. |
|
2153 |
]. |
|
2154 |
(y < cancelBottom) ifTrue:[ |
|
2155 |
self fillRectangleX:x y: acceptBottom + 1width:rw height: ((y + h) min: cancelBottom) - acceptBottom - 1color: cancelColor. |
|
2156 |
]. |
|
2157 |
(y + h >= cancelBottom) ifTrue:[ |
|
2158 |
self fillRectangleX:x y: cancelBottom + 1 width:rw height: (y + h) - cancelBottom - 1 color: diffColor. |
|
2159 |
] |
|
2160 |
||
2161 |
] |
|
2162 |
||
2163 |
"Created: / 07-10-2011 / 19:44:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2164 |
! |
|
2165 |
||
9985 | 2166 |
redrawBackgroundX:x y:y width:w height:h |
2167 |
"redraws gutter background" |
|
2168 |
||
2169 |
"background is filled with background color" |
|
2170 |
self |
|
2171 |
fillRectangleX:x |
|
2172 |
y:y |
|
2173 |
width:w |
|
2174 |
height:h |
|
10781 | 2175 |
color: self viewBackground "backgroundPaint". |
9985 | 2176 |
|
2177 |
"separator line is drawn with foreground color" |
|
2178 |
self |
|
2179 |
displayLineFromX:(self width - 2) |
|
2180 |
y:y |
|
2181 |
toX:(self width - 2) |
|
2182 |
y:(y+h). |
|
2183 |
||
2184 |
"Created: / 14-12-2009 / 13:15:53 / Jindra <a>" |
|
2185 |
"Modified: / 14-12-2009 / 15:09:54 / Jindra <a>" |
|
10577 | 2186 |
"Modified: / 17-08-2011 / 15:12:47 / cg" |
10781 | 2187 |
"Modified (comment): / 07-10-2011 / 19:37:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 2188 |
! |
2189 |
||
2190 |
redrawLine:line |
|
2191 |
||
2192 |
^self redrawLine:line cleared: false. |
|
2193 |
||
2194 |
"Modified: / 17-06-2011 / 14:12:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2195 |
! |
|
2196 |
||
2197 |
redrawLine:line cleared: cleared |
|
2198 |
"redraws specified line. Returns width of drawn object. Color of drawn objects should be taken from lineFont, lineColor" |
|
2199 |
||
2200 |
|lineString y0 textW requiredW oldFont newFont oldColor newColor| |
|
2201 |
||
2202 |
lineString := self displayedString:line. |
|
2203 |
textW := (lineString widthOn:self). |
|
2204 |
requiredW := textW + self padding. |
|
2205 |
||
2206 |
oldFont := self font. |
|
2207 |
oldColor := self paint. |
|
2208 |
newFont := self lineFont:line. |
|
2209 |
newFont |
|
2210 |
ifNotNil:[ self font:newFont. ] |
|
2211 |
ifNil:[ |
|
2212 |
newColor := self lineColor:line. |
|
2213 |
newColor ifNotNil:[ self paint:newColor ]. |
|
2214 |
]. |
|
2215 |
||
2216 |
y0 := (self yOfTextViewLine:line) + ((self font) ascentOn:device). |
|
2217 |
||
2218 |
cleared ifFalse:[ |
|
2219 |
self clearRectangleX:0 y:y0 - font height width: self width - 2 height: font height + font descent. |
|
2220 |
]. |
|
2221 |
||
2222 |
"Let the services to draw annotations and other stuff" |
|
2223 |
codeView |
|
2224 |
drawLine:line in: self |
|
10781 | 2225 |
atX: self paddingLeft + (widthAcceptCancel ? 0) y:y0 width: widthAnnotations height: font height |
9985 | 2226 |
from:nil to:nil with:self paint and: self backgroundColor. |
2227 |
||
2228 |
self |
|
2229 |
displayString:lineString |
|
2230 |
x:(self width - textW - self paddingRight - widthDiffInfo) |
|
2231 |
y:y0. |
|
2232 |
newFont |
|
2233 |
ifNotNil:[ |
|
2234 |
self font:oldFont. |
|
2235 |
self paint:oldColor |
|
2236 |
] |
|
2237 |
ifNil:[ newColor ifNotNil:[ self paint:oldColor ]. ]. |
|
2238 |
^ requiredW. |
|
2239 |
||
2240 |
"Modified: / 14-12-2009 / 15:30:44 / Jindra <a>" |
|
2241 |
"Created: / 17-06-2011 / 14:11:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2242 |
! |
|
2243 |
||
10224 | 2244 |
redrawLinesFrom:start |
2245 |
||
10312 | 2246 |
start to: (textView lastLineShown - 1 min: textView list size) do:[:line| |
10224 | 2247 |
self redrawLine:line cleared: false. |
2248 |
] |
|
2249 |
||
2250 |
"Created: / 06-07-2011 / 17:25:36 / jv" |
|
10312 | 2251 |
"Modified: / 12-07-2011 / 17:14:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10224 | 2252 |
! |
2253 |
||
9985 | 2254 |
redrawX:x y:y width:w height:h |
10312 | 2255 |
| requiredW currentW | |
9985 | 2256 |
|
2257 |
self redrawBackgroundX:x y:y width:w height:h. |
|
10793
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
2258 |
|
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
2259 |
codeView showAcceptCancelBar ifTrue:[ |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
2260 |
self redrawAcceptCancelBarX:x y:y width:w height:h. |
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
2261 |
]. |
9985 | 2262 |
|
10312 | 2263 |
firstLineShown := textView firstLineShown. |
2264 |
lastLineShown := textView lastLineShown - 1 min: textView list size. |
|
9985 | 2265 |
|
2266 |
currentW := requiredW := self width. |
|
10312 | 2267 |
firstLineShown to:lastLineShown do: |
9985 | 2268 |
[:line | |
2269 |
requiredW := requiredW max: (self redrawLine:line cleared: true)]. |
|
2270 |
||
2271 |
(requiredW > self width) ifTrue:[ |
|
2272 |
self corner:(requiredW @ 1.0). |
|
2273 |
textViewScroller origin:(requiredW @ 0.0) corner:(1.0 @ 1.0). |
|
2274 |
self invalidate. |
|
2275 |
]. |
|
2276 |
||
2277 |
"Created: / 03-09-2009 / 08:22:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2278 |
"Modified: / 14-12-2009 / 14:13:14 / Jindra <a>" |
|
10793
c19380a197aa
Added channel for controlling visibility of accept/cancel
vrany
parents:
10791
diff
changeset
|
2279 |
"Modified: / 10-10-2011 / 16:35:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 2280 |
! ! |
2281 |
||
2282 |
!CodeView2::TextView methodsFor:'accessing'! |
|
2283 |
||
2284 |
changedDiffText |
|
2285 |
^ changedDiffText |
|
2286 |
! |
|
2287 |
||
2288 |
changedDiffText:something |
|
2289 |
changedDiffText := something. |
|
2290 |
! |
|
2291 |
||
2292 |
changedLines |
|
2293 |
^ changedLines |
|
2294 |
||
2295 |
"Created: / 26-04-2010 / 20:30:32 / Jakub <zelenja7@fel.cvut.cz>" |
|
2296 |
"Modified: / 26-04-2010 / 21:48:13 / Jakub <zelenja7@fel.cvut.cz>" |
|
2297 |
! |
|
2298 |
||
2299 |
changedLines:something |
|
2300 |
changedLines := something. |
|
2301 |
||
2302 |
"Created: / 26-04-2010 / 20:30:19 / Jakub <zelenja7@fel.cvut.cz>" |
|
2303 |
"Modified: / 02-05-2010 / 19:13:32 / Jakub <zelenja7@fel.cvut.cz>" |
|
2304 |
! |
|
2305 |
||
10781 | 2306 |
contents: text |
2307 |
||
2308 |
super contents: text. |
|
2309 |
reallyModifiedChannel value: false. |
|
2310 |
||
2311 |
"Created: / 07-10-2011 / 20:32:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2312 |
! |
|
2313 |
||
9985 | 2314 |
deletedLines |
2315 |
^ deletedLines |
|
2316 |
||
2317 |
"Modified: / 26-04-2010 / 21:48:23 / Jakub <zelenja7@fel.cvut.cz>" |
|
2318 |
! |
|
2319 |
||
2320 |
deletedLines:something |
|
2321 |
deletedLines:=something. |
|
2322 |
||
2323 |
"Modified: / 26-04-2010 / 21:48:54 / Jakub <zelenja7@fel.cvut.cz>" |
|
2324 |
! |
|
2325 |
||
2326 |
diffMode |
|
2327 |
^ diffMode |
|
2328 |
! |
|
2329 |
||
2330 |
diffMode:something |
|
2331 |
diffMode := something. |
|
2332 |
! |
|
2333 |
||
2334 |
emptyLines |
|
2335 |
^ emptyLines |
|
2336 |
! |
|
2337 |
||
2338 |
emptyLines:something |
|
2339 |
emptyLines := something. |
|
2340 |
! |
|
2341 |
||
2342 |
insertedLines |
|
2343 |
^ insertedLines |
|
2344 |
||
2345 |
"Modified: / 26-04-2010 / 21:48:27 / Jakub <zelenja7@fel.cvut.cz>" |
|
2346 |
! |
|
2347 |
||
2348 |
insertedLines:something |
|
2349 |
insertedLines:=something. |
|
2350 |
||
2351 |
"Modified: / 26-04-2010 / 21:48:59 / Jakub <zelenja7@fel.cvut.cz>" |
|
2352 |
! |
|
2353 |
||
10245 | 2354 |
modifiedChannel: aValueHolder |
2355 |
||
2356 |
super modifiedChannel: aValueHolder |
|
2357 |
||
2358 |
"Created: / 07-07-2011 / 12:27:11 / Jan Vrany <jan.vrant@fit.cvut,cz>" |
|
2359 |
! |
|
2360 |
||
9985 | 2361 |
originDiffText |
2362 |
^ originDiffText |
|
2363 |
! |
|
2364 |
||
2365 |
originDiffText:something |
|
2366 |
originDiffText := something. |
|
10781 | 2367 |
! |
2368 |
||
2369 |
reallyModified |
|
2370 |
||
2371 |
^self reallyModifiedChannel value |
|
2372 |
||
2373 |
"Created: / 07-10-2011 / 19:28:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
9985 | 2374 |
! ! |
2375 |
||
2376 |
!CodeView2::TextView methodsFor:'accessing - colors'! |
|
2377 |
||
2378 |
colorChanged |
|
2379 |
^ Color redByte:240 greenByte: 192 blueByte: 192 |
|
2380 |
||
2381 |
"Modified: / 24-06-2010 / 14:05:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2382 |
! |
|
2383 |
||
2384 |
colorDeleted |
|
2385 |
||
2386 |
^ self colorInserted. |
|
2387 |
"/^ Color pink |
|
2388 |
||
2389 |
"Modified: / 24-06-2010 / 14:16:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10781 | 2390 |
"Modified (format): / 07-10-2011 / 20:26:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 2391 |
! |
2392 |
||
2393 |
colorInserted |
|
2394 |
^ Color redByte: 239 greenByte: 225 blueByte: 152 |
|
2395 |
||
2396 |
"Modified: / 24-06-2010 / 14:13:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2397 |
! ! |
|
2398 |
||
10781 | 2399 |
!CodeView2::TextView methodsFor:'accessing-contents'! |
2400 |
||
10784 | 2401 |
list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStrings |
2402 |
||
2403 |
super list:aCollection expandTabs:expand scanForNonStrings:scan includesNonStrings:nonStrings. |
|
2404 |
listOriginal := aCollection copy. |
|
10834 | 2405 |
reallyModifiedChannel value: false. |
2406 |
self notifyLinesModifiedFrom: 1 to: list size. |
|
10784 | 2407 |
|
2408 |
"Created: / 08-10-2011 / 12:23:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2409 |
! |
|
2410 |
||
10781 | 2411 |
setList:aCollection expandTabs:expandTabs redraw:doRedraw |
2412 |
||
2413 |
super setList:aCollection expandTabs:expandTabs redraw:doRedraw. |
|
2414 |
listOriginal := aCollection copy. |
|
10834 | 2415 |
reallyModifiedChannel value: false. |
2416 |
self notifyLinesModifiedFrom: 1 to: list size. |
|
10781 | 2417 |
|
2418 |
"Created: / 07-10-2011 / 18:42:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2419 |
! ! |
|
2420 |
||
10785 | 2421 |
!CodeView2::TextView methodsFor:'accessing-state'! |
2422 |
||
2423 |
beUnmodified |
|
2424 |
||
2425 |
self modifiedChannel value: false. |
|
2426 |
reallyModifiedChannel value: false. |
|
2427 |
listOriginal := list copy. |
|
2428 |
||
2429 |
"Created: / 08-10-2011 / 12:51:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2430 |
! |
|
2431 |
||
2432 |
isModified |
|
2433 |
||
2434 |
^self modified |
|
2435 |
||
2436 |
"Created: / 08-10-2011 / 12:52:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2437 |
! |
|
2438 |
||
2439 |
isReallyModified |
|
2440 |
||
2441 |
^self reallyModified |
|
2442 |
||
2443 |
"Created: / 08-10-2011 / 12:52:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2444 |
! ! |
|
2445 |
||
10781 | 2446 |
!CodeView2::TextView methodsFor:'channels'! |
2447 |
||
2448 |
reallyModifiedChannel |
|
2449 |
||
2450 |
^ reallyModifiedChannel |
|
2451 |
||
2452 |
"Created: / 07-10-2011 / 18:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2453 |
! |
|
2454 |
||
2455 |
reallyModifiedChannel: aValueModel |
|
2456 |
||
2457 |
|prev| |
|
2458 |
||
2459 |
prev := reallyModifiedChannel. |
|
2460 |
prev notNil ifTrue:[ |
|
2461 |
gutterView notNil ifTrue:[ |
|
2462 |
reallyModifiedChannel removeDependent: gutterView. |
|
2463 |
] |
|
2464 |
]. |
|
2465 |
reallyModifiedChannel := aValueModel. |
|
2466 |
self setupChannel:aValueModel for:nil withOld:prev. |
|
2467 |
gutterView notNil ifTrue:[ |
|
2468 |
reallyModifiedChannel addDependent: gutterView. |
|
2469 |
] |
|
2470 |
||
2471 |
"Created: / 07-10-2011 / 18:50:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2472 |
! ! |
|
2473 |
||
9985 | 2474 |
!CodeView2::TextView methodsFor:'drawing'! |
2475 |
||
2476 |
drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg |
|
2477 |
||
2478 |
super |
|
2479 |
drawFromVisibleLine:startVisLineNr |
|
2480 |
to:endVisLineNr |
|
2481 |
with:fg |
|
2482 |
and:bg. |
|
2483 |
self redrawLines. |
|
2484 |
||
2485 |
"Created: / 05-04-2010 / 12:08:38 / Jakub <zelenja7@fel.cvut.cz>" |
|
2486 |
"Modified: / 02-05-2010 / 18:46:04 / Jakub <zelenja7@fel.cvut.cz>" |
|
2487 |
! |
|
2488 |
||
2489 |
drawLine:line fromX:x inVisible:visLineNr with:fg and:bg |
|
2490 |
||
2491 |
super |
|
2492 |
drawLine:line |
|
2493 |
fromX:x |
|
2494 |
inVisible:visLineNr |
|
2495 |
with:fg |
|
2496 |
and:bg. |
|
2497 |
self redrawLines. |
|
2498 |
||
2499 |
"Created: / 05-04-2010 / 12:07:07 / Jakub <zelenja7@fel.cvut.cz>" |
|
2500 |
"Modified: / 02-05-2010 / 18:46:00 / Jakub <zelenja7@fel.cvut.cz>" |
|
2501 |
! |
|
2502 |
||
2503 |
drawLine:lineStringArg inVisible:visLineNr col:col with:fg and:bg |
|
2504 |
||
2505 |
super |
|
2506 |
drawLine:lineStringArg |
|
2507 |
inVisible:visLineNr |
|
2508 |
col:col |
|
2509 |
with:fg |
|
2510 |
and:bg. |
|
2511 |
self redrawLines. |
|
2512 |
||
2513 |
"Created: / 05-04-2010 / 11:49:42 / Jakub <zelenja7@fel.cvut.cz>" |
|
2514 |
"Modified: / 02-05-2010 / 18:45:56 / Jakub <zelenja7@fel.cvut.cz>" |
|
2515 |
! |
|
2516 |
||
2517 |
drawLine:lineStringArg inVisible:visLineNr from:startCol to:endColOrNil with:fg and:bg |
|
2518 |
||
2519 |
super |
|
2520 |
drawLine:lineStringArg |
|
2521 |
inVisible:visLineNr |
|
2522 |
from:startCol |
|
2523 |
to:endColOrNil |
|
2524 |
with:fg |
|
2525 |
and:bg. |
|
2526 |
self redrawLines. |
|
2527 |
||
2528 |
"Created: / 05-04-2010 / 11:54:54 / Jakub <zelenja7@fel.cvut.cz>" |
|
2529 |
"Modified: / 02-05-2010 / 18:45:52 / Jakub <zelenja7@fel.cvut.cz>" |
|
2530 |
! |
|
2531 |
||
2532 |
drawLine:lineString inVisible:visLineNr from:startCol with:fg and:bg |
|
2533 |
||
2534 |
super |
|
2535 |
drawLine:lineString |
|
2536 |
inVisible:visLineNr |
|
2537 |
from:startCol |
|
2538 |
with:fg |
|
2539 |
and:bg. |
|
2540 |
self redrawLines. |
|
2541 |
||
2542 |
"Created: / 05-04-2010 / 11:54:26 / Jakub <zelenja7@fel.cvut.cz>" |
|
2543 |
"Modified: / 02-05-2010 / 18:45:48 / Jakub <zelenja7@fel.cvut.cz>" |
|
2544 |
! |
|
2545 |
||
2546 |
drawVisibleLine:visLineNr with:fg and:bg |
|
2547 |
||
2548 |
super |
|
2549 |
drawVisibleLine:visLineNr |
|
2550 |
with:fg |
|
2551 |
and:bg. |
|
2552 |
self redrawLines. |
|
2553 |
||
2554 |
"Created: / 05-04-2010 / 11:49:42 / Jakub <zelenja7@fel.cvut.cz>" |
|
2555 |
"Modified: / 02-05-2010 / 18:45:44 / Jakub <zelenja7@fel.cvut.cz>" |
|
2556 |
! |
|
2557 |
||
2558 |
redraw |
|
2559 |
"/ thisContext fullPrintAll. |
|
2560 |
super redraw. |
|
2561 |
||
2562 |
"Created: / 30-06-2011 / 11:04:32 / cg" |
|
2563 |
! |
|
2564 |
||
2565 |
redrawLines |
|
2566 |
|i pom| |
|
2567 |
||
2568 |
diffMode ifFalse:[^self]. |
|
2569 |
||
2570 |
pom := self hasSelection. |
|
2571 |
(pom) ifTrue:[ ^ self. ]. |
|
2572 |
i := 1. |
|
2573 |
[ |
|
2574 |
i <= (deletedLines size) |
|
2575 |
] whileTrue:[ |
|
2576 |
((deletedLines at:i) > 0) ifTrue:[ |
|
2577 |
super |
|
2578 |
drawVisibleLine:(deletedLines at:i) |
|
2579 |
with:fgColor |
|
2580 |
and:self colorDeleted. |
|
2581 |
]. |
|
2582 |
i := i + 1. |
|
2583 |
]. |
|
2584 |
i := 1. |
|
2585 |
[ |
|
2586 |
i <= (insertedLines size) |
|
2587 |
] whileTrue:[ |
|
2588 |
((insertedLines at:i) > 0) ifTrue:[ |
|
2589 |
super |
|
2590 |
drawVisibleLine:(insertedLines at:i) |
|
2591 |
with:fgColor |
|
2592 |
and:self colorInserted. |
|
2593 |
]. |
|
2594 |
i := i + 1. |
|
2595 |
]. |
|
2596 |
i := 1. |
|
2597 |
[ |
|
2598 |
i <= (changedLines size) |
|
2599 |
] whileTrue:[ |
|
2600 |
((changedLines at:i) > 0) ifTrue:[ |
|
2601 |
super |
|
2602 |
drawVisibleLine:(changedLines at:i) |
|
2603 |
with:fgColor |
|
2604 |
and:self colorChanged. |
|
2605 |
]. |
|
2606 |
i := i + 1. |
|
2607 |
]. |
|
2608 |
||
2609 |
"Created: / 26-04-2010 / 21:04:31 / Jakub <zelenja7@fel.cvut.cz>" |
|
2610 |
"Modified: / 22-06-2010 / 23:28:30 / Jakub <zelenja7@fel.cvut.cz>" |
|
2611 |
"Modified: / 08-04-2011 / 20:52:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2612 |
! ! |
|
2613 |
||
2614 |
!CodeView2::TextView methodsFor:'editing'! |
|
2615 |
||
2616 |
contentsChanged |
|
2617 |
super contentsChanged. |
|
2618 |
" |
|
2619 |
codeView diffMode ifTrue:[ |
|
2620 |
changedDiffText ifTrue:[ |
|
2621 |
codeView recomputeDiff:self. |
|
2622 |
] ifFalse:[ |
|
2623 |
changedDiffText := true. |
|
2624 |
]. |
|
2625 |
] |
|
2626 |
" |
|
2627 |
||
2628 |
"Created: / 22-06-2010 / 23:13:24 / Jakub <zelenja7@fel.cvut.cz>" |
|
2629 |
"Modified: / 01-08-2010 / 20:33:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2630 |
! |
|
2631 |
||
2632 |
getNewOriginText |
|
2633 |
|i size pole pom text helperText| |
|
2634 |
||
2635 |
i := 1. |
|
2636 |
pole := list. |
|
2637 |
size := list size. |
|
2638 |
text:=''. |
|
10877 | 2639 |
emptyLines isNil ifTrue:[emptyLines := #()]. |
9985 | 2640 |
[ i <= size ] whileTrue:[ |
2641 |
pom := emptyLines indexOf:i. |
|
2642 |
(pom = 0) ifFalse:[ |
|
2643 |
helperText := pole at:i. |
|
2644 |
(helperText = '') ifFalse:[ |
|
2645 |
(helperText isNil)ifTrue:[helperText:='']. |
|
2646 |
helperText:=helperText,Character cr. |
|
2647 |
text := text asString , helperText asString. |
|
2648 |
]. |
|
2649 |
] ifTrue:[ |
|
2650 |
helperText := pole at:i. |
|
2651 |
(helperText isNil)ifTrue:[helperText:='']. |
|
2652 |
helperText:=helperText,Character cr. |
|
2653 |
text := text asString , helperText asString. |
|
2654 |
]. |
|
2655 |
i:=i+1. |
|
2656 |
]. |
|
2657 |
^text |
|
2658 |
||
2659 |
"Created: / 22-06-2010 / 22:33:27 / Jakub <zelenja7@fel.cvut.cz>" |
|
2660 |
"Modified: / 24-06-2010 / 14:27:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10877 | 2661 |
"Modified: / 18-11-2011 / 14:58:22 / cg" |
9985 | 2662 |
! ! |
2663 |
||
2664 |
!CodeView2::TextView methodsFor:'editing-basic'! |
|
2665 |
||
10708
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2666 |
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2667 |
"delete characters from startCol to endCol in line lineNr" |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2668 |
|
10731 | 2669 |
super basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol. |
10708
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2670 |
self notifyLinesModifiedFrom: lineNr to: lineNr. |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2671 |
|
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2672 |
"Created: / 16-09-2011 / 15:13:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2673 |
! |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2674 |
|
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2675 |
basicDeleteFromLine:startLineNr toLine:endLineNr |
10728 | 2676 |
|
2677 |
super basicDeleteFromLine:startLineNr toLine:endLineNr. |
|
10708
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2678 |
self notifyLinesDeletedFrom:startLineNr to:endLineNr. |
9985 | 2679 |
|
2680 |
"Created: / 28-06-2011 / 09:09:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2681 |
! |
|
2682 |
||
2683 |
basicDeleteLineWithoutRedraw:lineNr |
|
2684 |
||
10728 | 2685 |
super basicDeleteLineWithoutRedraw:lineNr. |
2686 |
self notifyLinesDeletedFrom: lineNr to: lineNr. |
|
9985 | 2687 |
|
2688 |
"Created: / 28-06-2011 / 09:10:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2689 |
! |
|
2690 |
||
10708
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2691 |
basicInsert:aCharacter atLine:lineNr col:colNr |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2692 |
"insert a single character at lineNr/colNr; |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2693 |
set emphasis to character at current position" |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2694 |
|
10728 | 2695 |
super basicInsert:aCharacter atLine:lineNr col:colNr. |
10708
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2696 |
self notifyLinesModifiedFrom: lineNr to: lineNr. |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2697 |
|
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2698 |
"Created: / 16-09-2011 / 15:14:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2699 |
! |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2700 |
|
9985 | 2701 |
basicMergeLine:lineNr removeBlanks:removeBlanks |
2702 |
||
10728 | 2703 |
super basicMergeLine:lineNr removeBlanks:removeBlanks. |
9985 | 2704 |
self notifyLinesDeletedFrom: lineNr + 1 to: lineNr + 1. |
2705 |
||
2706 |
"Created: / 28-06-2011 / 09:13:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2707 |
! |
|
2708 |
||
2709 |
basicSplitLine:lineNr before:colNr |
|
2710 |
||
10728 | 2711 |
super basicSplitLine:lineNr before:colNr. |
2712 |
self notifyLinesInsertedFrom: lineNr +1 to: lineNr + 1. |
|
9985 | 2713 |
|
2714 |
"Created: / 28-06-2011 / 09:14:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2715 |
! ! |
|
2716 |
||
2717 |
!CodeView2::TextView methodsFor:'event handling'! |
|
2718 |
||
2719 |
buttonMotion:button x:x y:y |
|
2720 |
||
2721 |
(codeView buttonMotion:button x:x y:y in: self) |
|
2722 |
ifFalse:[super buttonMotion:button x:x y:y]. |
|
2723 |
||
2724 |
"Created: / 14-02-2010 / 16:23:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2725 |
"Modified: / 06-03-2010 / 20:10:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2726 |
! |
|
2727 |
||
2728 |
buttonPress: button x: x y: y |
|
2729 |
| ctrlDown | |
|
2730 |
||
2731 |
(codeView buttonPress:button x:x y:y in: self) |
|
2732 |
ifFalse:[super buttonPress:button x:x y:y]. |
|
2733 |
" |
|
2734 |
((ctrlDown := self sensor ctrlDown) and: [ codeView syntaxElementSelection notNil]) |
|
2735 |
ifTrue: [codeView buttonPressInTextView: button x:x y:y ctrlDown: ctrlDown]. |
|
2736 |
super |
|
2737 |
buttonPress: button |
|
2738 |
x: x |
|
2739 |
y: y |
|
2740 |
" |
|
2741 |
||
2742 |
"Created: / 14-02-2010 / 18:12:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2743 |
"Modified: / 06-03-2010 / 20:37:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2744 |
! |
|
2745 |
||
2746 |
exposeX:x y:y width:w height:h |
|
2747 |
super |
|
2748 |
exposeX:x |
|
2749 |
y:y |
|
2750 |
width:w |
|
2751 |
height:h. |
|
2752 |
self redrawLines. |
|
2753 |
||
2754 |
"Created: / 05-04-2010 / 10:07:50 / Jakub <zelenja7@fel.cvut.cz>" |
|
2755 |
"Modified: / 02-05-2010 / 18:41:07 / Jakub <zelenja7@fel.cvut.cz>" |
|
2756 |
! |
|
2757 |
||
2758 |
keyPress:key x:x y:y |
|
2759 |
(codeView keyPress:key x:x y:y in: self) |
|
2760 |
ifFalse:[super keyPress:key x:x y:y]. |
|
2761 |
||
2762 |
"Modified: / 06-03-2010 / 20:34:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2763 |
"Modified: / 05-04-2010 / 09:55:52 / Jakub <zelenja7@fel.cvut.cz>" |
|
2764 |
! |
|
2765 |
||
2766 |
keyRelease: key x: x y: y |
|
2767 |
||
2768 |
(codeView keyRelease:key x:x y:y in: self) |
|
2769 |
ifFalse:[super keyRelease:key x:x y:y]. |
|
2770 |
" |
|
2771 |
(key = #Control_L) ifTrue: |
|
2772 |
[ codeView highlightClear. self redraw ]. |
|
2773 |
||
2774 |
^ super |
|
2775 |
keyRelease: key |
|
2776 |
x: x |
|
2777 |
y: y |
|
2778 |
" |
|
2779 |
||
2780 |
"Created: / 14-02-2010 / 16:38:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2781 |
"Modified: / 06-03-2010 / 21:04:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2782 |
! ! |
|
2783 |
||
2784 |
!CodeView2::TextView methodsFor:'initialization'! |
|
2785 |
||
2786 |
initialize |
|
2787 |
||
2788 |
super initialize. |
|
2789 |
||
2790 |
changedDiffText := true. |
|
2791 |
diffMode := false. |
|
10224 | 2792 |
suppressNotifications := false. |
10523 | 2793 |
autoIndent := UserPreferences current codeView2AutoIndent. |
10781 | 2794 |
reallyModifiedChannel := false asValue. |
9985 | 2795 |
|
10630
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
2796 |
self enableMotionEvents. |
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
2797 |
|
9985 | 2798 |
"Created: / 23-06-2010 / 17:28:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10224 | 2799 |
"Modified: / 06-07-2011 / 17:46:31 / jv" |
10630
d59bc761de55
fixed: #sendersMenu:selector:
Claus Gittinger <cg@exept.de>
parents:
10577
diff
changeset
|
2800 |
"Modified: / 21-08-2011 / 10:09:29 / cg" |
10781 | 2801 |
"Modified: / 07-10-2011 / 19:22:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 2802 |
! |
2803 |
||
2804 |
setCodeView: aCodeView2 |
|
2805 |
||
2806 |
codeView := aCodeView2. |
|
2807 |
codeView addDependent: self. |
|
2808 |
gutterView := aCodeView2 gutterView. |
|
2809 |
||
2810 |
"Created: / 14-02-2010 / 15:22:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2811 |
"Modified: / 17-06-2011 / 12:43:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2812 |
! |
|
2813 |
||
2814 |
setGutterView: aGutterView |
|
2815 |
||
2816 |
self assert: gutterView isNil message:'Attempting to set gutterView twice'. |
|
2817 |
gutterView := aGutterView. |
|
2818 |
gutterView setTextView: self. |
|
2819 |
||
2820 |
"Created: / 02-09-2009 / 21:57:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2821 |
! ! |
|
2822 |
||
2823 |
!CodeView2::TextView methodsFor:'menu & menu actions'! |
|
2824 |
||
10781 | 2825 |
accept |
2826 |
||
2827 |
super accept. |
|
2828 |
reallyModifiedChannel value: false. |
|
10785 | 2829 |
listOriginal := list copy. |
10781 | 2830 |
|
2831 |
"Created: / 07-10-2011 / 19:36:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2832 |
! |
|
2833 |
||
10784 | 2834 |
cancel |
2835 |
||
10785 | 2836 |
self list: listOriginal |
10784 | 2837 |
|
2838 |
"Created: / 08-02-2010 / 09:29:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2839 |
! |
|
2840 |
||
9985 | 2841 |
editMenu |
2842 |
||
2843 |
^codeView editMenu |
|
2844 |
||
2845 |
"Created: / 14-02-2010 / 15:49:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2846 |
! ! |
|
2847 |
||
2848 |
!CodeView2::TextView methodsFor:'notification'! |
|
2849 |
||
2850 |
notifyLinesDeletedFrom: startLine to: endLine |
|
2851 |
||
10781 | 2852 |
self updateReallyModified. |
10224 | 2853 |
suppressNotifications ifTrue:[^self]. |
2854 |
codeView linesDeletedFrom: startLine to: endLine. |
|
2855 |
suppressNotifications := true. |
|
2856 |
||
9985 | 2857 |
"Created: / 28-06-2011 / 09:12:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10224 | 2858 |
"Modified: / 06-07-2011 / 17:47:05 / jv" |
10781 | 2859 |
"Modified: / 07-10-2011 / 19:20:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 2860 |
! |
2861 |
||
2862 |
notifyLinesInsertedFrom: startLine to: endLine |
|
2863 |
||
10781 | 2864 |
self updateReallyModified. |
10224 | 2865 |
suppressNotifications ifTrue:[^self]. |
2866 |
codeView linesInsertedFrom: startLine to: endLine. |
|
2867 |
suppressNotifications := true. |
|
2868 |
||
9985 | 2869 |
"Created: / 28-06-2011 / 09:12:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10224 | 2870 |
"Modified: / 06-07-2011 / 17:47:20 / jv" |
10781 | 2871 |
"Modified: / 07-10-2011 / 19:20:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10708
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2872 |
! |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2873 |
|
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2874 |
notifyLinesModifiedFrom: startLine to: endLine |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2875 |
|
10781 | 2876 |
self updateReallyModified. |
10708
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2877 |
suppressNotifications ifTrue:[^self]. |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2878 |
codeView linesModifiedFrom: startLine to: endLine. |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2879 |
suppressNotifications := true. |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2880 |
|
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2881 |
"Modified: / 06-07-2011 / 17:47:20 / jv" |
dd79e944752e
Fixes for syntax highlighting and code navigation. Now it should work fine debugger.
vrany
parents:
10689
diff
changeset
|
2882 |
"Created: / 16-09-2011 / 15:12:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 2883 |
! ! |
2884 |
||
2885 |
!CodeView2::TextView methodsFor:'private'! |
|
2886 |
||
2887 |
superEditMenu |
|
2888 |
||
2889 |
^super editMenu |
|
2890 |
||
2891 |
"Created: / 14-02-2010 / 15:48:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10781 | 2892 |
! |
2893 |
||
2894 |
updateReallyModified |
|
2895 |
"check for modified code by comparing the source against |
|
2896 |
the codeViews contents. |
|
2897 |
Thats the true modified value (in case user undid its changes, |
|
2898 |
and the displayed text is actually original" |
|
2899 |
||
10844
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2900 |
|modified changedSource originalSource| |
10781 | 2901 |
|
2902 |
reallyModifiedChannel isNil ifTrue:[^self]. |
|
10844
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2903 |
"JV@2011-10-27: Idea is not to do anything if nobody is |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2904 |
interested. Not sure if it is a good idea, thought." |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2905 |
reallyModifiedChannel dependents isEmptyOrNil ifTrue:[^self]. |
10781 | 2906 |
|
2907 |
"/ higher prio to prevent it from being changed while we convert it (by editing) |
|
10844
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2908 |
|
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2909 |
modified := false. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2910 |
|
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2911 |
list size ~~ listOriginal size ifTrue:[ |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2912 |
modified := true. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2913 |
] ifFalse:[ |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2914 |
changedSource := list ? #(). |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2915 |
changedSource := changedSource collect:[:line | line isEmptyOrNil ifTrue:[nil] ifFalse:[line]]. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2916 |
[changedSource size > 0 and:[changedSource last isNil]] whileTrue:[ |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2917 |
changedSource := changedSource removeLast. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2918 |
]. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2919 |
|
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2920 |
originalSource := listOriginal ? #() "self model value ? ''". |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2921 |
originalSource := originalSource collect:[:line | line isEmptyOrNil ifTrue:[nil] ifFalse:[line]]. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2922 |
[originalSource size > 0 and:[originalSource last isNil]] whileTrue:[ |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2923 |
originalSource := originalSource removeLast |
10781 | 2924 |
]. |
10844
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2925 |
originalSource size ~~ changedSource size ifTrue:[ |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2926 |
modified := true. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2927 |
] ifFalse:[ |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2928 |
| i s | |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2929 |
i := 1. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2930 |
s := originalSource size + 1. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2931 |
[ modified not and:[ i < s ] ] whileTrue:[ |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2932 |
| originalL changedL | |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2933 |
|
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2934 |
originalL := ((originalSource at: i) ? '') string. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2935 |
changedL := ((changedSource at: i) ? '') string. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2936 |
originalL ~= changedL ifTrue:[ |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2937 |
originalL withoutTrailingSeparators ~= changedL withoutTrailingSeparators ifTrue:[ |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2938 |
modified := true. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2939 |
] |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2940 |
]. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2941 |
i := i + 1. |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2942 |
] |
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2943 |
] |
10781 | 2944 |
]. |
2945 |
||
2946 |
reallyModifiedChannel value: modified |
|
2947 |
||
2948 |
"Created: / 07-10-2011 / 19:16:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
10783 | 2949 |
"Modified: / 08-10-2011 / 11:10:01 / cg" |
10844
cbb5f5dd900a
Performance fix in CodeView2::TextView>>updateReallyModified
vrany
parents:
10834
diff
changeset
|
2950 |
"Modified: / 28-10-2011 / 09:23:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9985 | 2951 |
! ! |
2952 |
||
2953 |
!CodeView2::TextView methodsFor:'scrolling'! |
|
2954 |
||
2955 |
basicScrollDown:nLines |
|
2956 |
|i| |
|
2957 |
||
2958 |
(lastFirstLine isNil) ifTrue:[ |
|
2959 |
lastFirstLine := firstLineShown. |
|
2960 |
]. |
|
2961 |
super scrollDown:nLines. |
|
2962 |
(lastFirstLine = firstLineShown) ifFalse:[ |
|
2963 |
i := 1. |
|
2964 |
[ |
|
2965 |
i <= changedLines size |
|
2966 |
] whileTrue:[ |
|
2967 |
super |
|
2968 |
drawVisibleLine:(changedLines at:i) |
|
2969 |
with:fgColor |
|
2970 |
and:Color white. |
|
2971 |
changedLines at:i put:(changedLines at:i) - nLines. |
|
2972 |
i := i + 1. |
|
2973 |
]. |
|
2974 |
i := 1. |
|
2975 |
[ |
|
2976 |
i <= insertedLines size |
|
2977 |
] whileTrue:[ |
|
2978 |
super |
|
2979 |
drawVisibleLine:(insertedLines at:i) |
|
2980 |
with:fgColor |
|
2981 |
and:Color white. |
|
2982 |
insertedLines at:i put:(insertedLines at:i) - nLines. |
|
2983 |
i := i + 1. |
|
2984 |
]. |
|
2985 |
i := 1. |
|
2986 |
[ |
|
2987 |
i <= deletedLines size |
|
2988 |
] whileTrue:[ |
|
2989 |
super |
|
2990 |
drawVisibleLine:(deletedLines at:i) |
|
2991 |
with:fgColor |
|
2992 |
and:Color white. |
|
2993 |
deletedLines at:i put:(deletedLines at:i) - nLines. |
|
2994 |
i := i + 1. |
|
2995 |
]. |
|
2996 |
lastFirstLine := firstLineShown. |
|
2997 |
self redrawLines. |
|
2998 |
]. |
|
2999 |
||
3000 |
"Created: / 06-04-2010 / 14:03:28 / Jakub <zelenja7@fel.cvut.cz>" |
|
3001 |
"Modified: / 02-05-2010 / 19:29:23 / Jakub <zelenja7@fel.cvut.cz>" |
|
3002 |
! |
|
3003 |
||
3004 |
basicScrollUp:nLines |
|
3005 |
|i| |
|
3006 |
||
3007 |
(scrolled isNil) ifTrue:[ |
|
3008 |
scrolled := false. |
|
3009 |
]. |
|
3010 |
(lastFirstLine isNil) ifTrue:[ |
|
3011 |
lastFirstLine := firstLineShown. |
|
3012 |
]. |
|
3013 |
super scrollUp:nLines. |
|
3014 |
(lastFirstLine = firstLineShown) ifFalse:[ |
|
3015 |
i := 1. |
|
3016 |
[ |
|
3017 |
i <= insertedLines size |
|
3018 |
] whileTrue:[ |
|
3019 |
super |
|
3020 |
drawVisibleLine:(insertedLines at:i) |
|
3021 |
with:fgColor |
|
3022 |
and:Color white. |
|
3023 |
insertedLines at:i put:(insertedLines at:i) + nLines. |
|
3024 |
i := i + 1. |
|
3025 |
]. |
|
3026 |
i := 1. |
|
3027 |
[ |
|
3028 |
i <= deletedLines size |
|
3029 |
] whileTrue:[ |
|
3030 |
super |
|
3031 |
drawVisibleLine:(deletedLines at:i) |
|
3032 |
with:fgColor |
|
3033 |
and:Color white. |
|
3034 |
deletedLines at:i put:(deletedLines at:i) + nLines. |
|
3035 |
i := i + 1. |
|
3036 |
]. |
|
3037 |
i := 1. |
|
3038 |
[ |
|
3039 |
i <= changedLines size |
|
3040 |
] whileTrue:[ |
|
3041 |
super |
|
3042 |
drawVisibleLine:(changedLines at:i) |
|
3043 |
with:fgColor |
|
3044 |
and:Color white. |
|
3045 |
changedLines at:i put:(changedLines at:i) + nLines. |
|
3046 |
i := i + 1. |
|
3047 |
]. |
|
3048 |
lastFirstLine := firstLineShown. |
|
3049 |
self redrawLines. |
|
3050 |
]. |
|
3051 |
||
3052 |
"Created: / 06-04-2010 / 14:03:46 / Jakub <zelenja7@fel.cvut.cz>" |
|
3053 |
"Modified: / 02-05-2010 / 19:19:27 / Jakub <zelenja7@fel.cvut.cz>" |
|
3054 |
! |
|
3055 |
||
3056 |
originChanged:delta |
|
3057 |
||
3058 |
super originChanged:delta. |
|
3059 |
||
3060 |
gutterView invalidate. |
|
3061 |
||
3062 |
"Created: / 07-12-2009 / 21:50:49 / Jindra <a>" |
|
3063 |
! |
|
3064 |
||
3065 |
scrollDown:nLines |
|
3066 |
||
3067 |
codeView scrollDown: nLines in: self. |
|
3068 |
self basicScrollDown: nLines. |
|
3069 |
||
3070 |
"Modified: / 06-04-2010 / 14:04:28 / Jakub <zelenja7@fel.cvut.cz>" |
|
3071 |
! |
|
3072 |
||
3073 |
scrollUp:nLines |
|
3074 |
||
3075 |
codeView scrollUp: nLines in: self. |
|
3076 |
self basicScrollUp: nLines. |
|
3077 |
||
3078 |
"Modified: / 06-04-2010 / 14:05:40 / Jakub <zelenja7@fel.cvut.cz>" |
|
3079 |
! ! |
|
3080 |
||
10224 | 3081 |
!CodeView2::TextView methodsFor:'undo & again'! |
3082 |
||
3083 |
nonUndoableDo: aBlock |
|
3084 |
||
3085 |
super nonUndoableDo: aBlock. |
|
3086 |
suppressNotifications := false. |
|
3087 |
||
3088 |
"Created: / 06-07-2011 / 17:48:27 / jv" |
|
3089 |
! |
|
3090 |
||
3091 |
undoableDo: aBlock info: into |
|
3092 |
||
3093 |
super undoableDo: aBlock info: into. |
|
3094 |
suppressNotifications := false. |
|
3095 |
||
3096 |
"Created: / 06-07-2011 / 17:48:49 / jv" |
|
3097 |
! ! |
|
3098 |
||
9985 | 3099 |
!CodeView2 class methodsFor:'documentation'! |
3100 |
||
10293 | 3101 |
version |
10877 | 3102 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeView2.st,v 1.39 2011-11-18 14:06:35 cg Exp $' |
10293 | 3103 |
! |
3104 |
||
9985 | 3105 |
version_CVS |
10877 | 3106 |
^ '$Header: /cvs/stx/stx/libtool/Tools__CodeView2.st,v 1.39 2011-11-18 14:06:35 cg Exp $' |
9985 | 3107 |
! |
3108 |
||
3109 |
version_SVN |
|
3110 |
^ '§Id: Tools__CodeView2.st 7797 2011-06-28 07:45:06Z vranyj1 §' |
|
3111 |
! ! |
|
3112 |
||
3113 |
CodeView2 initialize! |