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