author | Claus Gittinger <cg@exept.de> |
Mon, 23 Feb 2015 12:37:42 +0100 | |
changeset 5279 | 3af2da2c44e6 |
parent 5250 | 38534f27c2f7 |
child 5290 | 6e5158a5c59b |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
5053 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2277 | 12 |
"{ Package: 'stx:libwidg' }" |
13 |
||
5250 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
TextCollector subclass:#Workspace |
5002 | 17 |
instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor |
18 |
commentStrings autoDefineWorkspaceVariables simulatedSelf |
|
19 |
autoDefineVariables compilerClass allowValueDrop |
|
20 |
poolsConsideredInDoIts namespaceForDoits editedMethodOrClass |
|
21 |
editedClass editedMethod editedLanguage' |
|
22 |
classVariableNames:'DefaultViewBackground DefaultErrorForegroundColor |
|
23 |
DefaultErrorBackgroundColor DefaultWarningBackgroundColor |
|
24 |
DefaultWarningForegroundColor WorkspaceVariables DoItHistory |
|
5144 | 25 |
Sniplets Snippets' |
5002 | 26 |
poolDictionaries:'' |
27 |
category:'Interface-Smalltalk' |
|
0 | 28 |
! |
29 |
||
4726 | 30 |
Workspace comment:'' |
3155 | 31 |
! |
32 |
||
32 | 33 |
!Workspace class methodsFor:'documentation'! |
34 |
||
38 | 35 |
copyright |
36 |
" |
|
37 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
5053 | 38 |
All Rights Reserved |
38 | 39 |
|
40 |
This software is furnished under a license and may be used |
|
41 |
only in accordance with the terms of that license and with the |
|
42 |
inclusion of the above copyright notice. This software may not |
|
43 |
be provided or otherwise made available to, or used by, any |
|
44 |
other person. No title to or ownership of the software is |
|
45 |
hereby transferred. |
|
46 |
" |
|
47 |
! |
|
48 |
||
32 | 49 |
documentation |
50 |
" |
|
51 |
a view for editable text which can evaluate expressions. |
|
38 | 52 |
I.e. its basically a view for editable text, with added |
53 |
'doIt', 'printIt' and 'inspectIt' functions on the popup-menu. |
|
125 | 54 |
|
38 | 55 |
The action to be performed on doIt is defined by a block, |
58 | 56 |
which can be defined by the owner of this view. |
60 | 57 |
(thus you can put a workspace into more complex widgets, and |
58 |
control what should happen on 'doIt'). |
|
58 | 59 |
|
5053 | 60 |
A useful default action is automatically defined, which simply |
61 |
evaluates the selection as a smalltalk expression. |
|
578 | 62 |
(but, a lisp or prolog workspace would define its own action, |
63 |
to call for another compiler/interpreter ...) |
|
32 | 64 |
|
4922 | 65 |
Special workspace- and doIt variables: |
5053 | 66 |
workspaces can be configured to automatically define undefined variables |
67 |
as either workspace- or doIt variables. When encountering undefined variables, |
|
68 |
the parser asks for an action, which is responded with #workspace or doIt if a |
|
69 |
workspace is the requestor of a doIt. Both are implemented as value holders, and |
|
70 |
the parser will generate code sending value/value: instead of normal assignment. |
|
71 |
Workspace variables are kept in the Workspace class and will both persist between doIts |
|
72 |
and also be visible across workspaces. They are perfect for scripting (and therefore anabled |
|
73 |
by default when stx is started with one of the scripting options). |
|
74 |
DoIt variables are only valid during a single doIt. |
|
75 |
Be aware that when you ask from the outside via workspaceVariableAt:, you'll get a valueHolder. |
|
76 |
This is by purbose, as it allows for easy monitoring and tracing of changes. |
|
77 |
||
123 | 78 |
Caveat: |
5053 | 79 |
in this version, Workspace does not yet support doIt in MVC setups. |
80 |
For now, simulate this by setting the doItAction, to notify the |
|
81 |
model manually about the doIt. |
|
123 | 82 |
|
83 |
||
578 | 84 |
[instance variables:] |
32 | 85 |
|
121 | 86 |
doItAction <Block> block to evaluate for doIt |
123 | 87 |
|
5053 | 88 |
errorFgColor <Color> fg-Color to be used when highlighting errors |
121 | 89 |
|
90 |
errorBgColor <Color> bg-Color to be used when highlighting errors |
|
58 | 91 |
|
578 | 92 |
codeStartPosition private temporary |
121 | 93 |
|
578 | 94 |
|
95 |
[styleSheet values:] |
|
121 | 96 |
|
97 |
codeErrorSelectionForegroundColor fg color to highlight errors |
|
5053 | 98 |
(default: selection fg) |
418 | 99 |
|
121 | 100 |
codeErrorSelectionBackgroundColor bg color to highlight errors |
5053 | 101 |
(default: selection bg) |
578 | 102 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
103 |
[start with:] |
5053 | 104 |
Workspace open |
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
105 |
|
578 | 106 |
[see also:] |
5053 | 107 |
Workspace EditTextView |
108 |
Parser ByteCodeCompiler |
|
583 | 109 |
|
110 |
[author:] |
|
5053 | 111 |
Claus Gittinger |
32 | 112 |
" |
201 | 113 |
! ! |
114 |
||
3712 | 115 |
!Workspace class methodsFor:'accessing'! |
116 |
||
117 |
sniplets |
|
5144 | 118 |
<resource: #obsolete> |
119 |
self obsoleteMethodWarning. |
|
120 |
^ self snippets |
|
3713 | 121 |
|
122 |
" |
|
5144 | 123 |
Snippets := nil |
3713 | 124 |
" |
3712 | 125 |
! |
126 |
||
127 |
sniplets:something |
|
5144 | 128 |
<resource: #obsolete> |
129 |
self obsoleteMethodWarning. |
|
130 |
self snippets:something |
|
131 |
! |
|
132 |
||
133 |
snippets |
|
134 |
Snippets isNil ifTrue:[ |
|
135 |
Snippets := Dictionary new. |
|
136 |
self initializeDefaultAbbreviations. |
|
137 |
]. |
|
138 |
^ Snippets |
|
139 |
||
140 |
" |
|
141 |
Snippets := nil |
|
142 |
" |
|
143 |
! |
|
144 |
||
145 |
snippets:aDictionary |
|
146 |
Snippets := aDictionary. |
|
3712 | 147 |
! ! |
148 |
||
201 | 149 |
!Workspace class methodsFor:'defaults'! |
150 |
||
4799
4baf5f98c387
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4784
diff
changeset
|
151 |
defaultCompletionSupportClass |
4baf5f98c387
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4784
diff
changeset
|
152 |
^ WorkspaceCompletionSupport |
4baf5f98c387
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4784
diff
changeset
|
153 |
|
4baf5f98c387
Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4784
diff
changeset
|
154 |
"Created: / 26-09-2013 / 17:59:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
155 |
! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
156 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
157 |
defaultLabel |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
158 |
"my default window label" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
159 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
160 |
^ 'Workspace' |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
161 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
162 |
"Created: / 16.5.1998 / 16:53:37 / cg" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
163 |
! |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
164 |
|
3716 | 165 |
initializeDefaultAbbreviations |
5144 | 166 |
"default snippets/abbreviations. TODO: save/load snippets" |
167 |
||
168 |
"flush and reinitialize snippets with: |
|
169 |
Snippets := Dictionary new. |
|
3741 | 170 |
" |
3807 | 171 |
"after a code change below, update with: |
5144 | 172 |
self initializeDefaultAbbreviations. |
3735 | 173 |
" |
3807 | 174 |
|
175 |
#( |
|
5144 | 176 |
't' 'true' |
177 |
'f' 'false' |
|
178 |
's' 'self' |
|
179 |
'su' 'super' |
|
180 |
'ss' 'super ' |
|
181 |
'n' 'nil' |
|
182 |
'y' 'yourself.' |
|
183 |
||
184 |
'in' 'isNil ' |
|
185 |
'nn' 'notNil ' |
|
186 |
'ie' 'isEmpty ' |
|
187 |
'ne' 'notEmpty ' |
|
188 |
'ien' 'isEmptyOrNil ' |
|
189 |
'nen' 'notEmptyOrNil ' |
|
190 |
||
191 |
'it' 'ifTrue:[!!' |
|
192 |
'if' 'ifFalse:[!!' |
|
193 |
'itf' 'ifTrue:[!!] ifFalse:[].' |
|
194 |
'int' 'isNil ifTrue:[!!].' |
|
195 |
'inf' 'isNil ifFalse:[!!].' |
|
196 |
'ints' 'isNil ifTrue:[^ self].' |
|
197 |
'infs' 'isNil ifFalse:[^ self].' |
|
198 |
'nnt' 'notNil ifTrue:[!!].' |
|
199 |
'nnf' 'notNil ifFalse:[!!].' |
|
200 |
'iet' 'isEmpty ifTrue:[!!].' |
|
201 |
'net' 'notEmpty ifTrue:[!!].' |
|
202 |
'ief' 'isEmpty ifFalse:[!!].' |
|
203 |
'nef' 'notEmpty ifFalse:[!!].' |
|
204 |
||
205 |
'wt' 'whileTrue:[!!]' |
|
206 |
'wf' 'whileFalse:[!!]' |
|
207 |
||
208 |
'do' 'do:[:each |!!]' |
|
209 |
'd:' 'do:[:each |!!]' |
|
210 |
'kdo' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
211 |
'kvd' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
212 |
'kv:' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
213 |
'k:' 'keysDo:[:eachKey | !!]' |
|
214 |
'dt' 'detect:[:each | !!]' |
|
215 |
'de' 'detect:[:each | !!]' |
|
216 |
'det' 'detect:[:each | !!]' |
|
217 |
'dtn' 'detect:[:each | !!] ifNone:[]' |
|
218 |
'cl' 'collect:[:each | !!]' |
|
219 |
'co' 'collect:[:each | !!]' |
|
220 |
'col' 'collect:[:each | !!]' |
|
221 |
'sl' 'select:[:each | !!]' |
|
222 |
'se' 'select:[:each | !!]' |
|
223 |
'sel' 'select:[:each | !!]' |
|
224 |
'rj' 'reject:[:each | !!]' |
|
225 |
're' 'reject:[:each | !!]' |
|
226 |
'rej' 'reject:[:each | !!]' |
|
227 |
'inj' 'inject:!! into:[:accum :each | ]' |
|
228 |
||
229 |
'ex' 'Error handle:[ex | !!] do:[].' |
|
230 |
'sh' 'self halt.' |
|
231 |
'mt' 'MessageTally spyOn:[!!].' |
|
232 |
||
233 |
'ih' '!! ifTrue:[ self halt ].' |
|
234 |
'ik' 'includesKey: #' |
|
235 |
'is' 'includesString: #' |
|
236 |
||
237 |
'af' 'asFilename ' |
|
238 |
'as' 'asString ' |
|
239 |
'aoc' 'asOrderedCollection ' |
|
240 |
||
241 |
'np' 'nextPut: ' |
|
242 |
'npa' 'nextPutAll: ' |
|
243 |
'npl' 'nextPutLine: ' |
|
244 |
||
245 |
'ps' 'printString' |
|
246 |
'sr' 'self subclassResponsibility.' |
|
247 |
||
248 |
'ati' 'at:!! ifAbsent: ' |
|
249 |
'atip' 'at:!! ifAbsentPut:[ ] ' |
|
250 |
'ap' 'at:!! ' |
|
251 |
||
252 |
'st' 'Smalltalk' |
|
253 |
'ts' 'Transcript showCR:''!!''.' |
|
254 |
'trs' 'Transcript showCR:''!!''.' |
|
255 |
'abb' 'Workspace snippets inspect.' |
|
256 |
'ws' 'Delay waitForSeconds: 1.' |
|
257 |
'wfs' 'Delay waitForSeconds: 1.' |
|
258 |
'wfm' 'Delay waitForMilliseconds: 1000.' |
|
259 |
'ini' 'initialize\ super initialize.\ ' |
|
260 |
'newi' 'new\ ^ super new initialize.' |
|
261 |
'upd' 'update:something with:aParameter from:changedObject\ !!\ ^ super update:something with:aParameter from:changedObject.' |
|
262 |
'OC' 'OrderedCollection' |
|
263 |
'oc' 'OrderedCollection' |
|
264 |
'SC' 'SortedCollection' |
|
265 |
'sc' 'SortedCollection' |
|
266 |
'D' 'Dictionary' |
|
267 |
'ID' 'IdentityDictionary' |
|
268 |
'Id' 'IdentityDictionary' |
|
269 |
'id' 'IdentityDictionary' |
|
270 |
'iD' 'IdentityDictionary' |
|
271 |
'OCn' 'OrderedCollection new.' |
|
272 |
'ocn' 'OrderedCollection new.' |
|
273 |
'SCn' 'SortedCollection new.' |
|
274 |
'IDn' 'IdentityDictionary new' |
|
275 |
'idn' 'IdentityDictionary new' |
|
276 |
'Dn' 'Dictionary new' |
|
277 |
'dn' 'Dictionary new' |
|
278 |
'Sn' 'Set new' |
|
279 |
'sn' 'Set new' |
|
280 |
'A' 'Array' |
|
281 |
'a' 'Array' |
|
282 |
'An' 'Array new:' |
|
283 |
'an' 'Array new:' |
|
284 |
'Aw' 'Array with:' |
|
285 |
'aw' 'Array with:' |
|
286 |
'Aww' 'Array with:!! with:' |
|
287 |
'sww' 'Array with:!! with:' |
|
288 |
'Awww' 'Array with:!! with: with:' |
|
289 |
'awww' 'Array with:!! with: with:' |
|
290 |
'Awwww' 'Array with:!! with: with: with:' |
|
291 |
'awwww' 'Array with:!! with: with: with:' |
|
292 |
'aw2' 'Array with:!! with:' |
|
293 |
'aw3' 'Array with:!! with: with:' |
|
294 |
'aw4' 'Array with:!! with: with: with:' |
|
295 |
'0' '(0.0 @ 0.0)' |
|
296 |
'1' '(1.0 @ 1.0)' |
|
297 |
'[' '[:!! ]' |
|
298 |
'(' '(!! )' |
|
299 |
||
300 |
"/ typos... |
|
301 |
'eslf' 'self' |
|
302 |
'slef' 'self' |
|
303 |
'sefl' 'self' |
|
304 |
'elf' 'self' |
|
305 |
'slf' 'self' |
|
306 |
'sef' 'self' |
|
307 |
||
308 |
'iftrue' 'ifTrue' |
|
309 |
'iffalse' 'ifFalse' |
|
310 |
'iftrue:' 'ifTrue:' |
|
311 |
'iffalse:' 'ifFalse:' |
|
3807 | 312 |
) pairWiseDo:[:abbrev :text | |
5144 | 313 |
Snippets |
314 |
at:abbrev put:text "/ ifPresent:[ self error:'duplicate abbreviation key' ] |
|
3807 | 315 |
]. |
4148
2fe252a82d5b
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4141
diff
changeset
|
316 |
|
4453
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
317 |
"Modified: / 26-09-2012 / 14:48:42 / cg" |
3716 | 318 |
! |
319 |
||
201 | 320 |
updateStyleCache |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
321 |
"extract values from the styleSheet and cache them in class variables" |
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
322 |
|
1354 | 323 |
<resource: #style (#'codeErrorSelection.foregroundColor' |
5053 | 324 |
#'codeErrorSelection.backgroundColor' |
325 |
#'codeView.backgroundColor' )> |
|
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
326 |
|
1354 | 327 |
DefaultErrorForegroundColor := StyleSheet colorAt:'codeErrorSelection.foregroundColor'. |
328 |
DefaultErrorBackgroundColor := StyleSheet colorAt:'codeErrorSelection.backgroundColor'. |
|
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
329 |
DefaultViewBackground := StyleSheet colorAt:'codeView.backgroundColor'. |
32 | 330 |
! ! |
331 |
||
2776 | 332 |
!Workspace class methodsFor:'getting a new Workspace'! |
0 | 333 |
|
32 | 334 |
open |
0 | 335 |
"launch a new workspace" |
336 |
||
418 | 337 |
|scr topView workspace f| |
0 | 338 |
|
5053 | 339 |
topView := StandardSystemView |
340 |
label:(self classResources string:(self defaultLabel)) |
|
341 |
" minExtent:(100 @ 100)". |
|
23 | 342 |
|
418 | 343 |
scr := HVScrollableView for:self in:topView. |
344 |
scr origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
345 |
workspace := scr scrolledView. |
|
0 | 346 |
|
418 | 347 |
"/ adjust topViews extent according to my font |
348 |
||
0 | 349 |
f := workspace font. |
350 |
topView extent:((f widthOf:'x') * 40) @ (f height * 10). |
|
7 | 351 |
topView open. |
131 | 352 |
^ workspace |
0 | 353 |
|
58 | 354 |
" |
355 |
Workspace open |
|
356 |
" |
|
418 | 357 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
358 |
"Modified: / 16.5.1998 / 16:53:53 / cg" |
857 | 359 |
! |
360 |
||
361 |
openForRemote:hostName |
|
362 |
"launch a new workspace to evaluate expression on some remote machine. |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
363 |
Entered expressions are sent over to some partner machine, evaluated there, |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
364 |
and the result is shown here. |
857 | 365 |
This requires the RemoteObjects package to be loaded." |
366 |
||
367 |
|server remoteCompiler workspace| |
|
368 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
369 |
RemoteObjectServer isNil ifTrue:[ |
5053 | 370 |
self warn:'no remoteObjectServer available'. |
371 |
^ nil |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
372 |
]. |
857 | 373 |
|
374 |
server := RemoteObjectServer on:hostName. |
|
375 |
remoteCompiler := server get:#Compiler. |
|
376 |
||
377 |
workspace := self open. |
|
5053 | 378 |
workspace topView |
379 |
label:(self classResources string:'Remote Workspace {%1}' with:hostName). |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
380 |
|
857 | 381 |
workspace doItAction: |
5053 | 382 |
[:theCode | |
383 |
remoteCompiler |
|
384 |
evaluate:theCode |
|
385 |
in:nil |
|
386 |
receiver:nil |
|
387 |
notifying:workspace |
|
388 |
logged:true |
|
389 |
ifFail:nil |
|
390 |
] |
|
857 | 391 |
" |
392 |
Workspace openForRemote:'andi' |
|
393 |
" |
|
394 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
395 |
"Modified: / 16.5.1998 / 16:57:38 / cg" |
2686 | 396 |
! |
397 |
||
2794 | 398 |
openWith:initialText selected:selectedBoolean |
2686 | 399 |
"launch a new workspace with some initial contents" |
400 |
||
401 |
|workspace| |
|
402 |
||
403 |
workspace := self open. |
|
2794 | 404 |
workspace contents:initialText selected:selectedBoolean. |
2686 | 405 |
^ workspace |
406 |
||
407 |
" |
|
408 |
Workspace openWith:'Transcript showCR:''hello world''' |
|
409 |
" |
|
0 | 410 |
! ! |
411 |
||
2657 | 412 |
!Workspace class methodsFor:'history'! |
413 |
||
414 |
clearDoItHistory |
|
415 |
DoItHistory := nil |
|
416 |
! |
|
417 |
||
418 |
doItHistory |
|
419 |
^ DoItHistory |
|
420 |
! |
|
421 |
||
422 |
doItHistorySize |
|
423 |
"the number of remembered doIts" |
|
424 |
||
425 |
^ 20 |
|
426 |
! |
|
427 |
||
428 |
rememberDoIt:aString |
|
429 |
|string| |
|
430 |
||
431 |
string := aString asString string withoutSeparators. |
|
2726 | 432 |
(string asCollectionOfWords size <= 1) ifTrue:[ |
5053 | 433 |
Error handle:[:ex | |
434 |
"/ unparsable |
|
435 |
^ self |
|
436 |
] do:[ |
|
437 |
((Scanner new scanTokens:string) size <= 1) ifTrue:[ |
|
438 |
"it's a variable only" |
|
439 |
^ self |
|
440 |
] |
|
441 |
] |
|
2726 | 442 |
]. |
2657 | 443 |
|
444 |
DoItHistory isNil ifTrue:[ |
|
5053 | 445 |
DoItHistory := OrderedCollection new. |
2657 | 446 |
]. |
447 |
DoItHistory remove:string ifAbsent:nil. |
|
448 |
DoItHistory addFirst:string. |
|
449 |
DoItHistory size > self doItHistorySize ifTrue:[ |
|
5053 | 450 |
DoItHistory removeLast |
2657 | 451 |
]. |
452 |
! ! |
|
453 |
||
1523
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
454 |
!Workspace class methodsFor:'queries'! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
455 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
456 |
isVisualStartable |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
457 |
"returns whether this application class can be started via #open |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
458 |
(i.e. via a double click on the class in the browser)" |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
459 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
460 |
^ self == Workspace |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
461 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
462 |
"Created: / 16.5.1998 / 16:59:00 / cg" |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
463 |
"Modified: / 16.5.1998 / 16:59:39 / cg" |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
464 |
! ! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
465 |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
466 |
!Workspace class methodsFor:'workspace variables'! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
467 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
468 |
addWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
469 |
"create a new workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
470 |
|
1933 | 471 |
|holder| |
472 |
||
3325 | 473 |
holder := self workspaceVariables at:name ifAbsentPut:[ ValueHolder new ]. |
1933 | 474 |
^ holder |
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
475 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
476 |
|
3157 | 477 |
anyWorkspaceVariableIsDefined |
478 |
^ WorkspaceVariables notEmptyOrNil |
|
479 |
||
480 |
"Created: / 20-04-2005 / 11:57:53 / cg" |
|
481 |
! |
|
482 |
||
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
483 |
removeAllWorkspaceVariables |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
484 |
"delete all workspace variables" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
485 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
486 |
WorkspaceVariables := nil |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
487 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
488 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
489 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
490 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
491 |
removeWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
492 |
"delete a workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
493 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
494 |
WorkspaceVariables notNil ifTrue:[ |
5053 | 495 |
WorkspaceVariables removeKey:name ifAbsent:nil. |
496 |
WorkspaceVariables := WorkspaceVariables asNilIfEmpty. |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
497 |
]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
498 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
499 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
500 |
workspaceVariableAt:name |
4924 | 501 |
"retrieve a workspace variable's value" |
502 |
||
503 |
^ (self workspaceVariableHolderAt:name) value |
|
504 |
||
505 |
" |
|
506 |
Workspace workspaceVariableAt:'foo' put:1234. |
|
5053 | 507 |
Workspace workspaceVariableAt:'foo' |
4924 | 508 |
" |
509 |
! |
|
510 |
||
511 |
workspaceVariableAt:name put:aValue |
|
512 |
"set or define a workspace variable" |
|
513 |
||
514 |
(self workspaceVariables at:name ifAbsentPut:[ ValueHolder new]) value:aValue |
|
515 |
! |
|
516 |
||
517 |
workspaceVariableHolderAt:name |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
518 |
"retrieve a workspace variable (actually, a holder onto it)" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
519 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
520 |
WorkspaceVariables isNil ifTrue:[^ nil]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
521 |
^ WorkspaceVariables at:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
522 |
|
4924 | 523 |
" |
524 |
Workspace workspaceVariableAt:'foo' put:1234. |
|
525 |
Workspace workspaceVariableAt:'foo' put:1234. |
|
526 |
" |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
527 |
! |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
528 |
|
3157 | 529 |
workspaceVariableNames |
4923 | 530 |
"retrieve the collection of workspace variable names only" |
3157 | 531 |
|
532 |
WorkspaceVariables isNil ifTrue:[^ #()]. |
|
533 |
^ WorkspaceVariables keys |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
534 |
|
3157 | 535 |
"Created: / 20-04-2005 / 11:42:45 / cg" |
536 |
! |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
537 |
|
3157 | 538 |
workspaceVariables |
4924 | 539 |
"retrieve the collection of workspace variable holders. |
3157 | 540 |
That is a dictionary associating names to values." |
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
541 |
|
3325 | 542 |
WorkspaceVariables isNil ifTrue:[ |
5053 | 543 |
WorkspaceVariables := Dictionary new. |
3325 | 544 |
]. |
545 |
^ WorkspaceVariables |
|
3157 | 546 |
|
547 |
"Modified: / 20-04-2005 / 11:43:14 / cg" |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
548 |
! ! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
549 |
|
201 | 550 |
!Workspace methodsFor:'accessing'! |
0 | 551 |
|
3428 | 552 |
allowValueDrop:aBoolean |
553 |
"if on (the default), any smalltalk value can be dropped and leads to a workspace variable |
|
554 |
holding on to that being defined. Can be turned off, if youdont like this (for standAlone apps)" |
|
555 |
||
556 |
allowValueDrop := aBoolean. |
|
557 |
||
558 |
"Created: / 28-11-2006 / 16:13:02 / cg" |
|
559 |
! |
|
560 |
||
2679 | 561 |
autoDefineVariables |
4090 | 562 |
"undefined variables handling: |
5053 | 563 |
are automatically defined as workspace variable if autoDefineVariables is #workspace. |
564 |
are automatically defined as doit variable if autoDefineVariables is #doit. |
|
565 |
are left undefined if autoDefineVariables is nil." |
|
4090 | 566 |
|
5053 | 567 |
^ autoDefineVariables |
2535 | 568 |
! |
569 |
||
2679 | 570 |
autoDefineVariables:nilOrSymbol |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
571 |
"undefined variables handling: |
5053 | 572 |
are automatically defined as workspace variable if nilOrSymbol is #workspace. |
573 |
are automatically defined as doit variable if nilOrSymbol is #doit. |
|
574 |
are left undefined if nilOrSymbol is nil." |
|
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
575 |
|
2679 | 576 |
autoDefineVariables := nilOrSymbol. |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
577 |
|
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
578 |
"Modified: / 28-11-2006 / 16:21:01 / cg" |
2679 | 579 |
! |
2535 | 580 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
581 |
commentStrings:anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
582 |
"define the comment strings" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
583 |
|
4876 | 584 |
"/ The argument must be of the form: |
585 |
"/ #( |
|
586 |
"/ '"/' |
|
587 |
"/ ('"' '"') |
|
588 |
"/ ) |
|
5053 | 589 |
"/ where simple string elements define the EOL comment sequence, |
4876 | 590 |
"/ and pairs define regular comment opening/closing seqeuences. |
591 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
592 |
commentStrings := anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
593 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
594 |
"Created: / 9.11.1997 / 01:05:25 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
595 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
596 |
|
201 | 597 |
doItAction |
598 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 599 |
|
201 | 600 |
^ doItAction |
0 | 601 |
! |
602 |
||
4584 | 603 |
doItAction:aOneArgBlock |
604 |
"define the action to be performed when 'doIt' is selected. |
|
5053 | 605 |
The block will be evaluated, passing the selection as a String argument. |
4584 | 606 |
A default doItAction is set for you in the initialize method." |
607 |
||
608 |
doItAction := aOneArgBlock |
|
609 |
||
610 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
611 |
! |
|
612 |
||
4675 | 613 |
editedClass |
614 |
"for the code completion" |
|
615 |
||
616 |
editedMethodOrClass isNil ifTrue:[^ nil]. |
|
617 |
^ editedMethodOrClass isBehavior ifTrue:[editedMethodOrClass] ifFalse:[editedMethodOrClass mclass] |
|
618 |
! |
|
619 |
||
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
620 |
editedLanguage |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
621 |
editedLanguage notNil ifTrue:[ |
5053 | 622 |
^ editedLanguage |
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
623 |
]. |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
624 |
editedMethod notNil ifTrue:[ |
5053 | 625 |
^ editedMethod programmingLanguage. |
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
626 |
]. |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
627 |
editedClass notNil ifTrue:[ |
5053 | 628 |
editedClass programmingLanguage. |
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
629 |
]. |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
630 |
^ nil |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
631 |
|
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
632 |
"Modified: / 18-09-2013 / 12:58:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
633 |
! |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
634 |
|
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
635 |
editedLanguage:aProgrammingLanguageOrNil |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
636 |
editedLanguage := aProgrammingLanguageOrNil. |
5024 | 637 |
aProgrammingLanguageOrNil notNil ifTrue:[ |
5053 | 638 |
commentStrings := aProgrammingLanguageOrNil commentStrings. |
5024 | 639 |
]. |
4776
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
640 |
! |
fb82694b23d8
Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4769
diff
changeset
|
641 |
|
4675 | 642 |
editedMethod |
643 |
"for the code completion" |
|
644 |
||
645 |
editedMethodOrClass isNil ifTrue:[^ nil]. |
|
646 |
^ editedMethodOrClass isBehavior ifTrue:[nil] ifFalse:[editedMethodOrClass] |
|
647 |
! |
|
648 |
||
4606 | 649 |
editedMethodOrClass |
650 |
"for the code completion" |
|
651 |
||
652 |
^ editedMethodOrClass. |
|
653 |
! |
|
654 |
||
655 |
editedMethodOrClass:aMethodOrClass |
|
656 |
"for the code completion" |
|
657 |
||
658 |
editedMethodOrClass := aMethodOrClass. |
|
659 |
! |
|
660 |
||
3007 | 661 |
errorBackgroundColor |
662 |
errorBgColor notNil ifTrue:[ ^ errorBgColor ]. |
|
663 |
DefaultErrorBackgroundColor notNil ifTrue:[ ^ DefaultErrorBackgroundColor ]. |
|
4921 | 664 |
self graphicsDevice hasColors ifTrue:[ ^ Color red ]. |
3007 | 665 |
|
666 |
^ selectionBgColor |
|
667 |
! |
|
668 |
||
669 |
errorForegroundColor |
|
670 |
errorFgColor notNil ifTrue:[ ^ errorFgColor ]. |
|
671 |
DefaultErrorForegroundColor notNil ifTrue:[ ^ DefaultErrorForegroundColor ]. |
|
672 |
^ selectionFgColor |
|
673 |
! |
|
674 |
||
4815 | 675 |
nameSpaceForDoits |
676 |
"can be used by the embedding application to control doIt execution |
|
677 |
(especially: for tools like expecco, to provide better workspaces" |
|
678 |
||
679 |
^ namespaceForDoits ? Smalltalk |
|
680 |
! |
|
681 |
||
4436 | 682 |
nameSpaceForDoits:aNameSpaceOrNil |
683 |
"can be used by the embedding application to control doIt execution |
|
684 |
(especially: for tools like expecco, to provide better workspaces" |
|
685 |
||
686 |
namespaceForDoits := aNameSpaceOrNil. |
|
687 |
||
688 |
"Created: / 26-07-2012 / 23:06:04 / cg" |
|
689 |
! |
|
690 |
||
4391 | 691 |
namespaceForDoits:aNameSpaceOrNil |
692 |
"can be used by the embedding application to control doIt execution |
|
693 |
(especially: for tools like expecco, to provide better workspaces" |
|
694 |
||
4436 | 695 |
<resource: #obsolete> |
696 |
||
4391 | 697 |
namespaceForDoits := aNameSpaceOrNil. |
698 |
||
699 |
"Created: / 04-03-2012 / 13:34:51 / cg" |
|
700 |
! |
|
701 |
||
702 |
poolsConsideredInDoIts:aCollectionOfPools |
|
703 |
"can be used by the embedding application to control doIt execution |
|
704 |
(especially: for tools like expecco, to provide better workspaces" |
|
705 |
||
706 |
poolsConsideredInDoIts := aCollectionOfPools. |
|
707 |
||
708 |
"Modified (format): / 04-03-2012 / 13:35:00 / cg" |
|
3537 | 709 |
! |
710 |
||
2601 | 711 |
simulatedSelf:anObject |
712 |
"define what self is in an evaluation" |
|
713 |
||
714 |
simulatedSelf := anObject |
|
3007 | 715 |
! |
716 |
||
717 |
warningBackgroundColor |
|
718 |
DefaultWarningBackgroundColor notNil ifTrue:[ ^ DefaultWarningBackgroundColor ]. |
|
4921 | 719 |
self graphicsDevice hasColors ifTrue:[ ^ Color orange ]. |
3007 | 720 |
|
721 |
^ selectionBgColor |
|
722 |
! |
|
723 |
||
724 |
warningForegroundColor |
|
725 |
DefaultWarningForegroundColor notNil ifTrue:[ ^ DefaultWarningForegroundColor ]. |
|
726 |
^ selectionFgColor |
|
201 | 727 |
! ! |
728 |
||
729 |
!Workspace methodsFor:'compiler interface'! |
|
730 |
||
2303 | 731 |
compilerClass |
4432
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
732 |
^ compilerClass "? Compiler" |
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
733 |
|
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
734 |
"Modified: / 19-07-2012 / 17:04:35 / cg" |
2980 | 735 |
! |
736 |
||
737 |
compilerClass:aCompilerClass |
|
738 |
compilerClass := aCompilerClass |
|
2303 | 739 |
! |
740 |
||
201 | 741 |
currentSourceCode |
742 |
"special interface to compiler - called by parser |
|
743 |
to get the updated source code after a corrected error" |
|
744 |
||
745 |
^ self contents |
|
0 | 746 |
! |
747 |
||
201 | 748 |
wantChangeLog |
749 |
"sent by the compiler to ask if a changeLog entry should |
|
750 |
be written. Return true here." |
|
0 | 751 |
|
201 | 752 |
^ true |
0 | 753 |
! ! |
754 |
||
2754 | 755 |
!Workspace methodsFor:'compiler interface-error handling'! |
0 | 756 |
|
201 | 757 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
758 |
"compiler notifies us of a correctable error; |
|
759 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
760 |
this method should return true to the compiler if user wants the error |
|
761 |
to be corrected; false otherwise" |
|
762 |
||
4675 | 763 |
|action sameForAllHolder possibleFixes doNotShowAgainHolder doNotShowAgainForThisMethodHolder| |
764 |
||
765 |
"/ the declare/correct fixes are here for backward compatibility |
|
766 |
"/ (in previous versions, these two were always offered as fix, |
|
767 |
"/ and compilers which honor the old interface will not anwer the PossibleCorrectionsQuery) |
|
768 |
possibleFixes := Parser possibleCorrectionsQuery query. |
|
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
769 |
|
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
770 |
sameForAllHolder := false asValue. |
201 | 771 |
|
772 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
5053 | 773 |
doNotShowAgainHolder := false asValue. |
774 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
4675 | 775 |
|
5053 | 776 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
777 |
|box declareButton makeSpaceOnlyOnce| |
|
3383 | 778 |
|
5053 | 779 |
box := ex box. |
780 |
(box isKindOf:OptionBox) ifFalse:[ ex reject ]. "/ a bad hack for subDialogs... needs fix |
|
781 |
makeSpaceOnlyOnce := [ box addVerticalSpace:10. makeSpaceOnlyOnce := nil ]. |
|
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
782 |
|
5053 | 783 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
784 |
makeSpaceOnlyOnce value. |
|
785 |
box verticalPanel |
|
786 |
add:(CheckBox |
|
787 |
label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
788 |
model:doNotShowAgainHolder). |
|
789 |
]. |
|
790 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
791 |
makeSpaceOnlyOnce value. |
|
792 |
box verticalPanel |
|
793 |
add:(CheckBox |
|
794 |
label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
|
795 |
model:doNotShowAgainForThisMethodHolder). |
|
796 |
]. |
|
797 |
SameForAllNotification isHandled ifTrue:[ |
|
798 |
box addVerticalSpace:10. |
|
799 |
box addCheckBoxAtBottom:'Same action for all' on:sameForAllHolder |
|
800 |
]. |
|
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
801 |
|
5053 | 802 |
declareButton := box buttons at:2. |
803 |
declareButton pressAction:declareButton controller releaseAction. |
|
804 |
declareButton controller beTriggerOnDown. |
|
805 |
] do:[ |
|
806 |
|buttonLabels actions| |
|
4675 | 807 |
|
5053 | 808 |
buttonLabels := OrderedCollection new. |
809 |
actions := OrderedCollection new. |
|
810 |
buttonLabels add:'Cancel'. actions add:#abort. |
|
811 |
possibleFixes do:[:each | |
|
812 |
buttonLabels add:(each buttonLabel). actions add:each. |
|
813 |
]. |
|
814 |
buttonLabels add:'Continue'. actions add:#continue. |
|
4675 | 815 |
|
5053 | 816 |
action := OptionBox |
817 |
request:aString |
|
818 |
label:(resources string:'Correctable Error') |
|
819 |
image:(WarningBox iconBitmap) |
|
820 |
buttonLabels:(resources array:buttonLabels) |
|
821 |
values:actions |
|
822 |
default:#continue |
|
823 |
onCancel:#abort. |
|
824 |
]. |
|
201 | 825 |
]. |
826 |
||
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
827 |
sameForAllHolder value ifTrue:[ |
5053 | 828 |
SameForAllNotification notify |
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
829 |
]. |
4691 | 830 |
doNotShowAgainHolder value == true ifTrue:[ |
5053 | 831 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
4691 | 832 |
]. |
833 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
5053 | 834 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
4691 | 835 |
]. |
836 |
||
4675 | 837 |
action == #cancel ifTrue:[ |
5053 | 838 |
^ false |
4675 | 839 |
]. |
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
840 |
|
201 | 841 |
action == #abort ifTrue:[ |
5053 | 842 |
AbortOperationRequest raise. |
843 |
^ false |
|
201 | 844 |
]. |
4675 | 845 |
^ action |
368 | 846 |
|
4386 | 847 |
"Modified: / 28-02-2012 / 10:42:27 / cg" |
201 | 848 |
! |
849 |
||
2104 | 850 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
851 |
"compiler notifies us of a correctable selector warning; |
|
852 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
853 |
this method should return true to the compiler if user wants the error |
|
854 |
to be corrected; false otherwise" |
|
855 |
||
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
856 |
|action doNotShowAgainHolder| |
2104 | 857 |
|
3261 | 858 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
5053 | 859 |
doNotShowAgainHolder := false asValue. |
860 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
|
861 |
MessageNotUnderstood catch:[ |
|
862 |
(aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
|
863 |
ex box addCheckBoxAtBottom:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
|
864 |
]. |
|
865 |
]. |
|
866 |
] do:[ |
|
867 |
action := OptionBox |
|
868 |
request:aString |
|
869 |
label:(resources string:'Warning') |
|
870 |
image:(WarningBox iconBitmap) |
|
871 |
buttonLabels:(resources array:#('Cancel' 'Correct...' 'Generate' 'Continue')) |
|
872 |
values:#(#abort #correct #generate #continue) |
|
873 |
default:#continue |
|
874 |
onCancel:#abort. |
|
875 |
]. |
|
876 |
doNotShowAgainHolder value == true ifTrue:[ |
|
877 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
|
878 |
]. |
|
2104 | 879 |
]. |
880 |
||
2338 | 881 |
action == #generate ifTrue:[ |
5053 | 882 |
^ action |
2338 | 883 |
]. |
884 |
||
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
885 |
(action isNil or:[action == #abort]) ifTrue:[ |
5053 | 886 |
AbortOperationRequest raise. |
887 |
^ false |
|
2104 | 888 |
]. |
889 |
^ action == #correct |
|
890 |
||
4386 | 891 |
"Created: / 19-01-2000 / 16:27:28 / cg" |
892 |
"Modified: / 28-02-2012 / 10:42:37 / cg" |
|
2104 | 893 |
! |
894 |
||
4188
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
895 |
correctableWarning:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
896 |
"compiler notifies us of a correctable warning; |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
897 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
898 |
this method should return true to the compiler if user wants the error |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
899 |
to be corrected; false otherwise" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
900 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
901 |
^ self correctableError:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
902 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
903 |
"Created: / 02-11-2010 / 13:29:01 / cg" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
904 |
! |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
905 |
|
201 | 906 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 907 |
"obsolete - no longer invoked" |
908 |
||
909 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
910 |
! |
|
911 |
||
912 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
5053 | 913 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
914 |
and show a Box asking for continue/abort. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
915 |
Return true for correction, false of not (or not possible)" |
2277 | 916 |
|
917 |
^ self error:aString position:relPos to:relEndPos from:aCompiler asWarning:false |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
918 |
|
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
919 |
"Modified (Comment): / 30-06-2011 / 19:47:36 / cg" |
2277 | 920 |
! |
921 |
||
922 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
3397 | 923 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
201 | 924 |
and show a Box asking for continue/abort." |
925 |
||
3007 | 926 |
|answer fg bg| |
201 | 927 |
|
3007 | 928 |
fg := asWarning ifTrue:[ self warningForegroundColor ] ifFalse:[ self errorForegroundColor ]. |
929 |
bg := asWarning ifTrue:[ self warningBackgroundColor ] ifFalse:[ self errorBackgroundColor ]. |
|
201 | 930 |
|
3397 | 931 |
self |
5053 | 932 |
highlightingErrorPosition:relPos to:relEndPos |
933 |
withForeground:fg andBackground:bg |
|
934 |
do:[ |
|
935 |
|box lbl doNotShowAgainHolder doNotShowAgainForThisMethodHolder l1 y1 y2 l2| |
|
201 | 936 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
937 |
"/ Warning isHandled ifTrue:[ |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
938 |
"/ Warning raiseErrorString:aString. |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
939 |
"/ ^ false |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
940 |
"/ ]. |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
941 |
|
5053 | 942 |
lbl := aCompiler isNil ifTrue:['Compiler'] ifFalse:[aCompiler class name]. |
943 |
asWarning ifTrue:[ |
|
944 |
lbl := lbl , ' Warning' |
|
945 |
] ifFalse:[ |
|
946 |
lbl := lbl , ' Error'. |
|
947 |
]. |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
948 |
|
5053 | 949 |
" |
950 |
ask if we should abort or continue |
|
951 |
" |
|
952 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
|
953 |
|box makeSpace| |
|
4386 | 954 |
|
5053 | 955 |
doNotShowAgainHolder := false asValue. |
956 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
4386 | 957 |
|
5053 | 958 |
box := ex box. |
959 |
box label:lbl. |
|
960 |
box perform:#image: with:(WarningBox iconBitmap) ifNotUnderstood:[]. |
|
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
961 |
|
5053 | 962 |
aCompiler notNil ifTrue:[ |
963 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
964 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
965 |
makeSpace value. |
|
966 |
box verticalPanel |
|
967 |
add:(CheckBox label:'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
968 |
model:doNotShowAgainHolder). |
|
969 |
]. |
|
970 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
971 |
makeSpace value. |
|
972 |
box verticalPanel |
|
973 |
add:(CheckBox label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
|
974 |
model:doNotShowAgainForThisMethodHolder). |
|
975 |
]. |
|
976 |
]. |
|
977 |
] do:[ |
|
978 |
answer := OptionBox |
|
979 |
request:aString |
|
980 |
buttonLabels:(resources array:#('Abort' "'Keep Selected'" 'Continue')) |
|
981 |
values:#(false "#keepSelected" true) |
|
982 |
default:(asWarning ifTrue:true ifFalse:false). |
|
983 |
answer := answer ? false. "/ if escaped |
|
984 |
]. |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
985 |
"/ box := YesNoBox |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
986 |
"/ title:aString |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
987 |
"/ yesText:(resources string:'Continue') |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
988 |
"/ noText:(resources string:'Abort'). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
989 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
990 |
"/ box label:lbl. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
991 |
"/ box image:(WarningBox iconBitmap). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
992 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
993 |
"/ (aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
994 |
"/ doNotShowAgainHolder := false asValue. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
995 |
"/ box addCheckBox:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
996 |
"/ ]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
997 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
998 |
"/ "/ answer := box confirm. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
999 |
"/ answer := box confirm. |
3007 | 1000 |
|
5053 | 1001 |
doNotShowAgainHolder value == true ifTrue:[ |
1002 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
|
1003 |
]. |
|
1004 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
1005 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
1006 |
]. |
|
3007 | 1007 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1008 |
"/ box destroy. |
5053 | 1009 |
]. |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
1010 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1011 |
answer == #keepSelected ifTrue:[ |
5053 | 1012 |
self hideCursor. |
1013 |
"redraw selection in normal color" |
|
1014 |
self invalidate. |
|
1015 |
AbortOperationRequest raise. |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1016 |
]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
1017 |
|
201 | 1018 |
" |
1019 |
do the abort if we have to |
|
1020 |
" |
|
3397 | 1021 |
answer ifFalse:[ |
5053 | 1022 |
"redraw selection in normal color" |
1023 |
self invalidate. |
|
1024 |
AbortOperationRequest raise. |
|
201 | 1025 |
]. |
1026 |
^ false |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
1027 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
1028 |
"Created: / 24-11-1995 / 22:56:34 / cg" |
4398 | 1029 |
"Modified: / 08-03-2012 / 10:24:21 / cg" |
201 | 1030 |
! |
1031 |
||
2663 | 1032 |
highlightingErrorLine:lineNr do:aBlock |
1033 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
1034 |
||
1035 |
|linePosition| |
|
1036 |
||
1037 |
linePosition := self characterPositionOfLine:lineNr col:1. |
|
1038 |
self highlightingErrorPosition:linePosition to:nil do:aBlock |
|
1039 |
! |
|
1040 |
||
59 | 1041 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
1042 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 1043 |
|
5053 | 1044 |
self |
1045 |
highlightingErrorPosition:relPos to:relEndPos |
|
1046 |
withForeground:(self errorForegroundColor) andBackground:(self errorBackgroundColor) |
|
1047 |
do:aBlock |
|
3007 | 1048 |
! |
1049 |
||
1050 |
highlightingErrorPosition:relPos to:relEndPos withForeground:hilightFg andBackground:hilightBg do:aBlock |
|
1051 |
"evaluate aBlock while some selection is shown highlighted with colors passed as args." |
|
1052 |
||
1053 |
|absPosition oldFg oldBg| |
|
0 | 1054 |
|
58 | 1055 |
" |
1056 |
change color of selection & hide cursor |
|
1057 |
" |
|
3007 | 1058 |
oldFg := selectionFgColor. |
1059 |
oldBg := selectionBgColor. |
|
1060 |
selectionBgColor := hilightBg. |
|
1061 |
selectionFgColor := hilightFg. |
|
58 | 1062 |
self hideCursor. |
0 | 1063 |
|
58 | 1064 |
" |
1065 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
1066 |
we have to adjust the positions given by the compiler, since they |
|
1067 |
are relative to the texts start (the compiler did stream-read the code). |
|
1068 |
" |
|
0 | 1069 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
3427 | 1070 |
absPosition := codeStartPosition + (relPos ? 1) - 1. |
0 | 1071 |
relEndPos isNil ifTrue:[ |
5053 | 1072 |
self selectFromCharacterPosition:absPosition. |
1073 |
"/ self selectLineWhereCharacterPosition:absPosition. |
|
0 | 1074 |
] ifFalse:[ |
5053 | 1075 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + (relEndPos ? 1) - 1) |
0 | 1076 |
]. |
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
1077 |
expandingTop := true. "/ hack to make the top of the selection visible |
0 | 1078 |
self makeSelectionVisible. |
1079 |
||
4921 | 1080 |
self flush. |
58 | 1081 |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
1082 |
aBlock ensure:[ |
5053 | 1083 |
" |
1084 |
undo selection color change and show cursor again |
|
1085 |
" |
|
1086 |
selectionFgColor := oldFg. |
|
1087 |
selectionBgColor := oldBg. |
|
1088 |
self showCursor. |
|
0 | 1089 |
]. |
3427 | 1090 |
|
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
1091 |
"Modified: / 30-06-2011 / 17:24:04 / cg" |
0 | 1092 |
! |
1093 |
||
3007 | 1094 |
highlightingWarningPosition:relPos to:relEndPos do:aBlock |
1095 |
"evaluate aBlock while some selection is shown highlighted with warning colors." |
|
1096 |
||
5053 | 1097 |
self |
1098 |
highlightingErrorPosition:relPos to:relEndPos |
|
1099 |
withForeground:(self warningForegroundColor) andBackground:(self warningBackgroundColor) |
|
1100 |
do:aBlock |
|
3007 | 1101 |
! |
1102 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1103 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1104 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1105 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1106 |
this method should return true to the compiler if user wants the error |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1107 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1108 |
|
4386 | 1109 |
|action doNotShowAgainHolder doNotShowAgainForThisMethodHolder| |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1110 |
|
3007 | 1111 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
5053 | 1112 |
doNotShowAgainHolder := false asValue. |
1113 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
1114 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
|
1115 |
|box makeSpace| |
|
4386 | 1116 |
|
5053 | 1117 |
box := ex box. |
1118 |
aCompiler notNil ifTrue:[ |
|
1119 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
1120 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
1121 |
makeSpace value. |
|
1122 |
box verticalPanel |
|
1123 |
add:(CheckBox |
|
1124 |
label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
1125 |
model:doNotShowAgainHolder). |
|
1126 |
]. |
|
1127 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
1128 |
makeSpace value. |
|
1129 |
box verticalPanel |
|
1130 |
add:(CheckBox |
|
1131 |
label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
|
1132 |
model:doNotShowAgainForThisMethodHolder). |
|
1133 |
]. |
|
1134 |
]. |
|
1135 |
] do:[ |
|
1136 |
action := OptionBox |
|
1137 |
request:aString |
|
1138 |
label:(resources string:'Warning') |
|
1139 |
image:(WarningBox iconBitmap) |
|
1140 |
buttonLabels:(resources array:#('Cancel' 'Remove Variable(s)' 'Continue')) |
|
1141 |
values:#(#abort #correct #continue) |
|
1142 |
default:#continue. |
|
1143 |
action isNil ifTrue:[ action := #abort]. |
|
1144 |
]. |
|
1145 |
doNotShowAgainHolder value == true ifTrue:[ |
|
1146 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
|
1147 |
]. |
|
1148 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
1149 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
1150 |
]. |
|
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1151 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1152 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1153 |
action == #abort ifTrue:[ |
5053 | 1154 |
"/ self halt. |
1155 |
AbortOperationRequest raise. |
|
1156 |
^ false |
|
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1157 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1158 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
1159 |
|
4398 | 1160 |
"Modified: / 08-03-2012 / 10:23:58 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1161 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1162 |
|
5053 | 1163 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 1164 |
"compiler notifies us of a warning - same behavior as error" |
0 | 1165 |
|
5053 | 1166 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 1167 |
! ! |
1168 |
||
3396 | 1169 |
!Workspace methodsFor:'drag & drop'! |
1170 |
||
1171 |
canDrop:aDropContext |
|
4090 | 1172 |
"if allowValueDrop is true, any text- or file-object can be dropped into workspace |
1173 |
(printString); otherwise, only ..." |
|
1174 |
||
1175 |
self isReadOnly ifTrue:[^ false]. |
|
3396 | 1176 |
|
4090 | 1177 |
allowValueDrop ifTrue:[^ true]. |
1178 |
^ super canDrop:aDropContext |
|
3428 | 1179 |
|
5053 | 1180 |
"/ ^ aDropContext dropObjects |
4090 | 1181 |
"/ contains:[:someObject| (someObject isTextObject or:[ someObject isFileObject ])]. |
3396 | 1182 |
|
1183 |
"Created: / 16-08-2005 / 22:01:13 / janfrog" |
|
3428 | 1184 |
"Modified: / 28-11-2006 / 16:18:51 / cg" |
3396 | 1185 |
! |
1186 |
||
3414 | 1187 |
doDrop:aDropContext |
4631 | 1188 |
<resource: #obsolete> |
1189 |
self obsoleteMethodWarning:'should no longer be reached'. |
|
3428 | 1190 |
self drop:aDropContext |
3414 | 1191 |
|
3428 | 1192 |
"Modified: / 28-11-2006 / 16:14:51 / cg" |
4386 | 1193 |
"Modified (format): / 28-02-2012 / 11:20:38 / cg" |
3414 | 1194 |
! |
1195 |
||
1196 |
drop:aDropContext |
|
1197 |
"Any object can be dropped into workspace..." |
|
1198 |
||
3870 | 1199 |
|textObjects nonTextObjects answer text| |
1200 |
||
5053 | 1201 |
textObjects := aDropContext dropObjects |
1202 |
select:[:dropObject | dropObject isTextObject |
|
1203 |
or:[ dropObject isFileObject ]]. |
|
1204 |
nonTextObjects := aDropContext dropObjects |
|
1205 |
reject:[:dropObject | dropObject isTextObject |
|
1206 |
or:[ dropObject isFileObject ]]. |
|
3870 | 1207 |
|
1208 |
self dropObjects:textObjects. |
|
3414 | 1209 |
|
3870 | 1210 |
nonTextObjects notEmpty ifTrue:[ |
5053 | 1211 |
answer := Dialog |
1212 |
confirmWithCancel:(resources |
|
1213 |
string:'Drop as textual representation or as object reference ?') |
|
1214 |
labels:(resources array:#('Cancel' 'Reference' 'Name' 'Text')) |
|
1215 |
values:#(nil #ref #name #text) |
|
1216 |
default:4. |
|
1217 |
answer isNil ifTrue:[^ self]. |
|
1218 |
(answer == #text or:[answer == #name]) ifTrue:[ |
|
1219 |
text := String streamContents:[:s | |
|
1220 |
nonTextObjects do:[:dropObject | |
|
1221 |
|obj| |
|
3870 | 1222 |
|
5053 | 1223 |
obj := dropObject theObject. |
1224 |
obj isMethod ifTrue:[ |
|
1225 |
s nextPutAll:(answer == #name ifTrue:[obj selector] ifFalse:[obj source]). |
|
1226 |
] ifFalse:[ |
|
1227 |
obj isClass ifTrue:[ |
|
1228 |
s nextPutAll:(answer == #name ifTrue:[obj name] ifFalse:[obj source asString]) |
|
1229 |
] ifFalse:[ |
|
1230 |
s nextPutAll:(answer == #name ifTrue:[obj className] ifFalse:[obj printString]) . |
|
1231 |
]. |
|
1232 |
]. |
|
1233 |
]. |
|
1234 |
]. |
|
1235 |
self paste:text. |
|
1236 |
] ifFalse:[ |
|
1237 |
nonTextObjects do:[:dropObject | |
|
1238 |
name := Dialog |
|
1239 |
request:(resources |
|
1240 |
string:'Name of the new Workspace Variable (refers to the dropped %1):' |
|
1241 |
with:dropObject theObject class name allBold |
|
1242 |
) |
|
1243 |
initialAnswer:'droppedObject' |
|
1244 |
okLabel:'Add' |
|
1245 |
title:'Enter Variable Name'. |
|
3414 | 1246 |
|
5053 | 1247 |
name notEmptyOrNil ifTrue:[ |
1248 |
Workspace addWorkspaceVariable:name. |
|
1249 |
Workspace workspaceVariableAt:name put:dropObject theObject. |
|
1250 |
self paste:name. |
|
1251 |
]. |
|
1252 |
]. |
|
1253 |
] |
|
3414 | 1254 |
]. |
1255 |
||
1256 |
"Created: / 13-10-2006 / 17:34:07 / cg" |
|
3396 | 1257 |
! ! |
1258 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1259 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1260 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1261 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1262 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1263 |
All lines from line1 to line2 get an end-of-line comment |
5053 | 1264 |
in the first col |
1925 | 1265 |
(if no eol comment is available, a bracketing comment is used)." |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1266 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1267 |
|eolComment opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1268 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1269 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1270 |
eolComment isNil ifTrue:[ |
5053 | 1271 |
opening := (commentStrings at:2) at:1. |
1272 |
closing := (commentStrings at:2) at:2. |
|
1273 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1274 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1275 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1276 |
line1 to:line2 do:[:lineNr | |
5053 | 1277 |
|l| |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1278 |
|
5053 | 1279 |
l := self listAt:lineNr. |
1280 |
l isNil ifTrue:[l := '']. |
|
1281 |
eolComment notNil ifTrue:[ |
|
1282 |
l := eolComment , l |
|
1283 |
] ifFalse:[ |
|
1284 |
l := opening , l , closing |
|
1285 |
]. |
|
1286 |
self replaceLine:lineNr with:l. |
|
1287 |
widthOfWidestLine notNil ifTrue:[ |
|
1288 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1289 |
]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1290 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1291 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1292 |
|
3403 | 1293 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
1294 |
"Modified: / 09-10-2006 / 10:46:44 / cg" |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1295 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1296 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1297 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1298 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1299 |
All lines from line1 to line2 get an end-of-line comment |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1300 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1301 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1302 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1303 |
|
1481 | 1304 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3210 | 1305 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
1306 |
||
5053 | 1307 |
selectionStartLine isNil ifTrue:[ |
1308 |
self |
|
1309 |
undoableDo:[ self commentFrom:cursorLine to:cursorLine ] |
|
1310 |
info:'Comment'. |
|
1311 |
^ self |
|
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1312 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1313 |
|
5053 | 1314 |
self |
1315 |
undoableDo: |
|
1316 |
[ |
|
1317 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1318 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
|
1319 |
] ifFalse:[ |
|
1320 |
commentPair := commentStrings at:2 ifAbsent:nil. |
|
1321 |
commentPair isNil ifTrue:[ |
|
1322 |
self beep. |
|
1323 |
] ifFalse:[ |
|
1324 |
opening := commentPair at:1. |
|
1325 |
closing := commentPair at:2. |
|
1326 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
3129 | 1327 |
|
5053 | 1328 |
e := selectionEndCol. |
3210 | 1329 |
|
5053 | 1330 |
self insertString:closing atLine:selectionEndLine col:e+1. |
1331 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
3129 | 1332 |
|
5053 | 1333 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
1334 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1335 |
toLine:selectionEndLine col:e+closing size. |
|
1336 |
] |
|
1337 |
] |
|
1338 |
] |
|
1339 |
info:'comment' |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1340 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1341 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 1342 |
"Modified: / 5.4.1998 / 16:52:23 / cg" |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1343 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1344 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1345 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1346 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1347 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1348 |
in the first col. |
1349 |
(if no eol comment is available, a bracketing comment is removed)" |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1350 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1351 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1352 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1353 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1354 |
eolComment isNil ifTrue:[ |
5053 | 1355 |
opening := (commentStrings at:2) at:1. |
1356 |
closing := (commentStrings at:2) at:2. |
|
1357 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1358 |
] ifFalse:[ |
5053 | 1359 |
rest := eolComment size + 1. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1360 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1361 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1362 |
line1 to:line2 do:[:lineNr | |
5053 | 1363 |
|l| |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1364 |
|
5053 | 1365 |
l := self listAt:lineNr. |
1366 |
l notNil ifTrue:[ |
|
1367 |
eolComment notNil ifTrue:[ |
|
1368 |
(l startsWith:eolComment) ifTrue:[ |
|
1369 |
l := l copyFrom:rest |
|
1370 |
] |
|
1371 |
] ifFalse:[ |
|
1372 |
((l startsWith:opening) |
|
1373 |
and:[l endsWith:closing]) ifTrue:[ |
|
1374 |
l := l copyFrom:opening size + 1. |
|
1375 |
l := l copyButLast:closing size. |
|
1376 |
] |
|
1377 |
]. |
|
1378 |
self replaceLine:lineNr with:l. |
|
1379 |
] |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1380 |
]. |
3403 | 1381 |
widthOfWidestLine := nil. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1382 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1383 |
|
3403 | 1384 |
"Created: / 09-11-1997 / 01:05:43 / cg" |
1385 |
"Modified: / 09-10-2006 / 10:46:59 / cg" |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1386 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1387 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1388 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1389 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1390 |
All lines from line1 to line2 get an end-of-line comment |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1391 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1392 |
|
4877 | 1393 |
|e commentPair opening closing sz1 sz2 l1 l2 c1 c2| |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1394 |
|
3129 | 1395 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
5053 | 1396 |
selectionStartLine isNil ifTrue:[ |
1397 |
self |
|
1398 |
undoableDo:[ |
|
1399 |
self uncommentFrom:cursorLine to:cursorLine |
|
1400 |
] |
|
1401 |
info:'Uncomment'. |
|
1402 |
^ self |
|
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1403 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1404 |
|
5053 | 1405 |
self |
1406 |
undoableDo: |
|
1407 |
[ |
|
1408 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1409 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
|
1410 |
] ifFalse:[ |
|
1411 |
commentPair := commentStrings at:2. |
|
1412 |
opening := commentPair at:1. |
|
1413 |
closing := commentPair at:2. |
|
1414 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
3129 | 1415 |
|
5053 | 1416 |
sz1 := opening size. |
1417 |
sz2 := closing size. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1418 |
|
5053 | 1419 |
((self |
1420 |
stringAtLine:selectionStartLine |
|
1421 |
from:selectionStartCol |
|
1422 |
to:selectionStartCol+sz1 - 1) = opening |
|
1423 |
and:[(self |
|
1424 |
stringAtLine:selectionEndLine |
|
1425 |
from:selectionEndCol - sz2 + 1 |
|
1426 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1427 |
|
5053 | 1428 |
l2 := selectionEndLine. c2 := selectionEndCol. |
1429 |
l1 := selectionStartLine. c1 := selectionStartCol. |
|
1430 |
self deleteCharsAtLine:l2 fromCol:c2-sz2+1 toCol:c2. |
|
1431 |
self deleteCharsAtLine:l1 fromCol:c1 toCol:c1+sz1-1. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1432 |
|
5053 | 1433 |
e := c2 - sz2. |
1434 |
l1 == l2 ifTrue:[e := e - sz1]. |
|
1435 |
self selectFromLine:l1 col:c1 toLine:l2 col:e. |
|
1436 |
] |
|
1437 |
] |
|
1438 |
] |
|
1439 |
info:'uncomment' |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1440 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1441 |
"Modified: / 7.1.1997 / 20:13:32 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1442 |
"Created: / 9.11.1997 / 01:05:46 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1443 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1444 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1445 |
!Workspace methodsFor:'event handling'! |
3712 | 1446 |
|
0 | 1447 |
keyPress:key x:x y:y |
5053 | 1448 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #ReplaceIt |
1449 |
#BrowseIt #ImplementorsOfIt #ExpandAbbreviation |
|
1450 |
#CommentSelection #UncommentSelection)> |
|
60 | 1451 |
|
3800 | 1452 |
(key == #DoIt) ifTrue:[self doIt. ^ self]. |
1453 |
(key == #InspectIt) ifTrue:[self inspectIt. ^ self]. |
|
1454 |
(key == #PrintIt) ifTrue:[self printIt. ^ self]. |
|
1455 |
(key == #ReplaceIt) ifTrue:[self replaceIt. ^ self]. |
|
1456 |
(key == #BrowseIt) ifTrue:[self browseIt. ^ self]. |
|
1457 |
(key == #ImplementorsOfIt) ifTrue:[self browseImplementorsOfIt. ^ self]. |
|
1458 |
(key == #ExpandAbbreviation) ifTrue:[self expandAbbreviation. ^ self]. |
|
4587 | 1459 |
(key == #CommentSelection) ifTrue:[self commentSelection. ^ self]. |
1460 |
(key == #UncommentSelection) ifTrue:[self uncommentSelection. ^ self]. |
|
38 | 1461 |
|
0 | 1462 |
super keyPress:key x:x y:y |
3511 | 1463 |
|
1464 |
"Modified: / 08-11-2007 / 11:29:45 / cg" |
|
0 | 1465 |
! ! |
201 | 1466 |
|
2143 | 1467 |
!Workspace methodsFor:'executing'! |
201 | 1468 |
|
1501 | 1469 |
do:code withValueDo:aBlock |
5053 | 1470 |
"helper for doIt, printIt and inspectIt. |
1471 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
418 | 1472 |
aBlock with the value. |
1473 |
Most work is in preparing for proper cleanup in case of abort |
|
1474 |
or other exception while the evaluation is performed. |
|
1475 |
(restore cursor, selectionColors etc.)" |
|
201 | 1476 |
|
4149 | 1477 |
|selLine selCol endLine endCol cLine cCol cleanUp executeBlock| |
201 | 1478 |
|
1479 |
code notNil ifTrue:[ |
|
5053 | 1480 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
2408 | 1481 |
|
5053 | 1482 |
codeStartPosition := self characterPositionOfSelection. |
201 | 1483 |
|
5053 | 1484 |
" |
1485 |
remember selection for later - if there is an error, |
|
1486 |
the notification method will highlight it. |
|
1487 |
thus destroying the current selection |
|
1488 |
" |
|
1489 |
selLine := selectionStartLine. |
|
1490 |
selCol := selectionStartCol. |
|
1491 |
endLine := selectionEndLine. |
|
1492 |
endCol := selectionEndCol. |
|
1493 |
cCol := cursorCol. |
|
1494 |
cLine := cursorLine. |
|
201 | 1495 |
|
5053 | 1496 |
" |
1497 |
cleanup: restore previous selection and cursor positions |
|
1498 |
" |
|
1499 |
cleanUp := [ |
|
1500 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
1501 |
cLine notNil ifTrue:[ |
|
1502 |
self cursorLine:cLine col:cCol |
|
1503 |
]. |
|
1504 |
]. |
|
201 | 1505 |
|
5053 | 1506 |
" |
1507 |
perform the action. |
|
1508 |
Be careful to release the reference to the value; |
|
1509 |
otherwise, we could keep lots of garbage from being freed |
|
1510 |
until the view gets closed |
|
1511 |
" |
|
1512 |
executeBlock := [ |
|
1513 |
[ |
|
1514 |
AbortOperationRequest handle:[:ex | |
|
1515 |
"/ aBlock value:'** Abortsignal caught **'. |
|
1516 |
ex return |
|
1517 |
] do:[ |
|
1518 |
|value| |
|
929 | 1519 |
|
5053 | 1520 |
doItAction notNil ifTrue:[ |
1521 |
value := doItAction value:(code asString). |
|
1522 |
cleanUp value. cleanUp := nil. |
|
1523 |
aBlock notNil ifTrue:[ |
|
1524 |
aBlock value:value. |
|
1525 |
]. |
|
1526 |
value := nil. |
|
1527 |
self class rememberDoIt:code. |
|
1528 |
] |
|
1529 |
] |
|
1530 |
] ensure:[ |
|
1531 |
cleanUp notNil ifTrue:[ |
|
1532 |
cleanUp value. cleanUp := nil |
|
1533 |
]. |
|
1534 |
] |
|
1535 |
]. |
|
1536 |
aBlock isNil ifTrue:[ |
|
1537 |
"no action is performed with the result - give the user a visible |
|
1538 |
feedback, that something has been done" |
|
1539 |
self topView withVisibleCursor:Cursor execute do:executeBlock. |
|
1540 |
] ifFalse:[ |
|
1541 |
self topView withCursor:Cursor execute do:executeBlock. |
|
1542 |
]. |
|
201 | 1543 |
] |
257 | 1544 |
|
1501 | 1545 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
1546 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
2409 | 1547 |
"Modified: / 26.9.2001 / 17:32:59 / cg" |
4677 | 1548 |
! |
201 | 1549 |
|
2733 | 1550 |
executeDoIt:theCode |
4391 | 1551 |
"the core of doIt, printIt, inspectIt, browseIt actions" |
1552 |
||
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1553 |
| result compiler | |
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1554 |
|
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1555 |
"JV@2012-03-19: Changed to reflect value of autoDefineVariables" |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1556 |
[ |
5053 | 1557 |
result := ( compiler := (self compilerClass ? Compiler) new ) |
1558 |
currentNameSpace:namespaceForDoits; |
|
1559 |
moreSharedPools:poolsConsideredInDoIts; |
|
1560 |
evaluate:theCode |
|
1561 |
in:nil |
|
1562 |
receiver:simulatedSelf |
|
1563 |
notifying:self |
|
1564 |
logged:true |
|
1565 |
ifFail:nil |
|
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1566 |
] on: Parser undefinedVariableNotification do:[:ex| |
5053 | 1567 |
(ex parser == compiler and:[autoDefineVariables notNil]) ifTrue:[ |
1568 |
ex proceedWith: #declare |
|
1569 |
] ifFalse:[ |
|
1570 |
ex proceedWith: nil |
|
1571 |
]. |
|
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1572 |
] on: Parser askForVariableTypeOfUndeclaredQuery do:[:ex| |
5053 | 1573 |
autoDefineVariables == #workspace ifTrue:[ |
1574 |
ex proceedWith:#WorkspaceVariable |
|
1575 |
]. |
|
1576 |
autoDefineVariables == #doIt ifTrue:[ |
|
1577 |
ex proceedWith:#DoItTemporary |
|
1578 |
]. |
|
1579 |
ex pass. |
|
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1580 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1581 |
^result |
4391 | 1582 |
|
4438 | 1583 |
"Modified: / 27-07-2012 / 09:33:39 / cg" |
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1584 |
"Modified: / 24-06-2013 / 15:31:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4677 | 1585 |
! ! |
1586 |
||
1587 |
!Workspace methodsFor:'initialization & release'! |
|
2733 | 1588 |
|
201 | 1589 |
initStyle |
966 | 1590 |
"setup viewStyle specifics" |
1591 |
||
201 | 1592 |
super initStyle. |
1593 |
||
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1594 |
DefaultViewBackground notNil ifTrue:[ |
5053 | 1595 |
viewBackground := DefaultViewBackground. |
1596 |
self backgroundColor:viewBackground. |
|
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1597 |
]. |
201 | 1598 |
! |
1599 |
||
1600 |
initialize |
|
1601 |
super initialize. |
|
1602 |
||
5105 | 1603 |
autoIndent := UserPreferences current autoIndentInCodeView. |
2775 | 1604 |
scrollWhenUpdating := #beginOfText. |
201 | 1605 |
showMatchingParenthesis := true. |
3428 | 1606 |
allowValueDrop := true. |
1607 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1608 |
commentStrings := #( |
5103 | 1609 |
'"/' |
1610 |
('"' '"') |
|
1611 |
). |
|
201 | 1612 |
|
1613 |
self initializeDoITAction. |
|
3396 | 1614 |
self initializeDragAndDrop. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1615 |
|
3428 | 1616 |
"Modified: / 28-11-2006 / 16:11:55 / cg" |
201 | 1617 |
! |
1618 |
||
1619 |
initializeDoITAction |
|
1620 |
"set up the block to be evaluated for doIts. |
|
1621 |
This is done here in a separate method to allow easier |
|
1622 |
redefinition in subclasses" |
|
1623 |
||
2733 | 1624 |
doItAction := [:theCode | self executeDoIt:theCode]. |
3396 | 1625 |
! |
1626 |
||
1627 |
initializeDragAndDrop |
|
1628 |
|target| |
|
1629 |
||
5053 | 1630 |
target := DropTarget |
1631 |
receiver:self |
|
1632 |
argument:nil |
|
1633 |
dropSelector:#drop: |
|
1634 |
canDropSelector:#canDrop:. |
|
3396 | 1635 |
self dropTarget:target |
1636 |
||
1637 |
"Created: / 16-08-2005 / 22:03:36 / janfrog" |
|
3411 | 1638 |
"Modified: / 13-10-2006 / 12:37:18 / cg" |
201 | 1639 |
! ! |
1640 |
||
418 | 1641 |
!Workspace methodsFor:'menu & menu actions'! |
1642 |
||
2285 | 1643 |
browseClass |
1644 |
"user selected 'browseClass' from menu; evaluate the code |
|
1645 |
and open a browser on the resulting class (if it evaluates to one)" |
|
1646 |
||
5053 | 1647 |
^ self |
1648 |
do:(self selectionAsString) |
|
1649 |
withValueDo:[:result | |
|
1650 |
result isBehavior ifTrue:[ |
|
1651 |
result browserClass openInClass:result selector:nil |
|
1652 |
] ifFalse:[ |
|
1653 |
self warn:'Selection does not evaluate to a class' |
|
1654 |
] |
|
1655 |
]. |
|
2285 | 1656 |
|
2410 | 1657 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 1658 |
! |
1659 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1660 |
browseImplementorsOfIt |
4617 | 1661 |
"open a browser on the implementors of the selected text, |
1662 |
or - if I support syntax elements, on the syntax element at the cursor position" |
|
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1663 |
|
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1664 |
|selectedText selector browserClass na| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1665 |
|
4617 | 1666 |
selectedText := self selectedTextOrSyntaxElement. |
1667 |
selectedText notEmptyOrNil ifTrue:[ |
|
5053 | 1668 |
self windowGroup withWaitCursorDo:[ |
1669 |
"/ hack, for now and expecco; must ask the Parser eventually... |
|
1670 |
(compilerClass notNil and:[compilerClass includesBehavior:JavaScriptParser]) ifTrue:[ |
|
1671 |
"/ selector is in one piece anyway |
|
1672 |
(selectedText includes:$_) ifFalse:[ |
|
1673 |
"/ zero or one args - sigh (need to parse more to figure this out) |
|
1674 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:1. |
|
1675 |
selectedText := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:0. |
|
1676 |
] ifTrue:[ |
|
1677 |
"/ count _#s plus one arg - sigh |
|
1678 |
na := (selectedText occurrencesOf:$_) + 1. |
|
1679 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:na |
|
1680 |
]. |
|
1681 |
] ifFalse:[ |
|
1682 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
|
1683 |
]. |
|
1684 |
browserClass := UserPreferences systemBrowserClass. |
|
2714 | 1685 |
|
5053 | 1686 |
(selector notNil and:[selector ~= selectedText]) ifTrue:[ |
1687 |
(SystemBrowser |
|
1688 |
findImplementorsOfAny:(Array with:selectedText) |
|
1689 |
in:(Smalltalk allClasses) |
|
1690 |
ignoreCase:false) isEmpty ifTrue:[ |
|
1691 |
browserClass browseImplementorsOf:selector |
|
1692 |
] ifFalse:[ |
|
1693 |
browserClass browseImplementorsOfAny:(Set with:selector with:selectedText) |
|
1694 |
]. |
|
1695 |
] ifFalse:[ |
|
1696 |
browserClass browseImplementorsOf:(selector ? selectedText) |
|
1697 |
] |
|
1698 |
] |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1699 |
]. |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1700 |
|
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1701 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1702 |
"Modified: / 19.11.2001 / 22:15:17 / cg" |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1703 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1704 |
|
2307 | 1705 |
browseIt |
1706 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
2713 | 1707 |
or the class of the resulting object (if it does not evaluate to a class). |
1708 |
||
1709 |
Added feature: if selection is of the form class >> selector, immediately switch to that selector." |
|
1710 |
||
4617 | 1711 |
|codeToEvaluate el idx selector evaluatedValue classToBrowse gotResult| |
2713 | 1712 |
|
5053 | 1713 |
(self selection isEmptyOrNil |
5072 | 1714 |
and:[ self supportsSyntaxElements |
1715 |
and:[ (el := self syntaxElementForVariableUnderCursor) notNil ]]) |
|
5053 | 1716 |
ifTrue:[ |
5072 | 1717 |
codeToEvaluate := el name |
4617 | 1718 |
] ifFalse:[ |
5072 | 1719 |
codeToEvaluate := (self selectionOrTextOfCursorLine ? '') withoutSeparators. |
4617 | 1720 |
]. |
2713 | 1721 |
idx := codeToEvaluate indexOfSubCollection:'>>'. |
1722 |
idx ~~ 0 ifTrue:[ |
|
5072 | 1723 |
selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string. |
1724 |
(selector startsWith:'#') ifTrue:[ |
|
1725 |
selector := Symbol readFrom:selector. |
|
1726 |
]. |
|
1727 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
|
2713 | 1728 |
]. |
2307 | 1729 |
|
4997 | 1730 |
(Parser parseErrorSignal , MessageNotUnderstood) handle:[:ex | |
5072 | 1731 |
|className words| |
1732 |
||
1733 |
(classToBrowse := Smalltalk classNamed:codeToEvaluate) isNil ifTrue:[ |
|
1734 |
"/ handle className selector (for example from messageTally list) |
|
1735 |
codeToEvaluate includesSeparator ifTrue:[ |
|
1736 |
words := codeToEvaluate asCollectionOfWords. |
|
1737 |
classToBrowse := Smalltalk classNamed:words first. |
|
1738 |
classToBrowse notNil ifTrue:[ |
|
1739 |
selector := (words copyFrom:2) asStringWith:''. |
|
1740 |
((words size > 1) and:[words second = 'class']) ifTrue:[ |
|
1741 |
classToBrowse := classToBrowse theMetaclass. |
|
1742 |
selector := (words copyFrom:3) asStringWith:''. |
|
1743 |
]. |
|
1744 |
classToBrowse browserClass openInClass:classToBrowse selector:selector. |
|
1745 |
^ self. |
|
1746 |
]. |
|
1747 |
]. |
|
1748 |
||
1749 |
"/ fallback, if garbage is selected, look for matching classes. |
|
1750 |
className := SystemBrowser |
|
1751 |
askForClassNameMatching:codeToEvaluate |
|
1752 |
inEnvironment:nil |
|
1753 |
for:nil. |
|
1754 |
||
1755 |
className isNil ifTrue:[^ self]. |
|
1756 |
classToBrowse := Smalltalk classNamed:className. |
|
1757 |
] |
|
3910 | 1758 |
] do:[ |
5072 | 1759 |
gotResult := false. |
1760 |
||
1761 |
self |
|
1762 |
do:codeToEvaluate |
|
1763 |
withValueDo:[:result | evaluatedValue := result. gotResult := true.]. |
|
1764 |
||
1765 |
gotResult ifFalse:[^ self]. |
|
1766 |
||
1767 |
evaluatedValue isNil ifTrue:[ |
|
1768 |
codeToEvaluate asCollectionOfWords size == 1 ifTrue:[ |
|
1769 |
codeToEvaluate isUppercaseFirst ifTrue:[ |
|
1770 |
Dialog information:(codeToEvaluate allBold , ' is unbound or nil'). |
|
1771 |
^ self. |
|
1772 |
]. |
|
1773 |
] |
|
1774 |
]. |
|
1775 |
classToBrowse := evaluatedValue isBehavior |
|
1776 |
ifTrue:[ evaluatedValue ] |
|
1777 |
ifFalse:[ evaluatedValue class ]. |
|
3910 | 1778 |
]. |
1779 |
||
1780 |
classToBrowse browserClass openInClass:classToBrowse selector:selector |
|
4386 | 1781 |
|
1782 |
"Modified: / 28-02-2012 / 11:23:06 / cg" |
|
2307 | 1783 |
! |
1784 |
||
2285 | 1785 |
browseItsClass |
1786 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
1787 |
and open a browser on the results class" |
|
1788 |
||
5053 | 1789 |
^ self |
1790 |
do:(self selectionAsString) |
|
1791 |
withValueDo:[:result | |
|
1792 |
result class browserClass openInClass:result class selector:nil |
|
1793 |
] |
|
2285 | 1794 |
|
2410 | 1795 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 1796 |
! |
1797 |
||
2454 | 1798 |
browseReferencesToIt |
5003 | 1799 |
"open a browser on all references to the selected global, poolvar or namespace class" |
2454 | 1800 |
|
5066 | 1801 |
|nameOfVariable browserClass sym| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1802 |
|
5065 | 1803 |
nameOfVariable := self selectedTextOrSyntaxElement. |
1804 |
nameOfVariable notEmptyOrNil ifTrue:[ |
|
1805 |
browserClass := UserPreferences systemBrowserClass. |
|
1806 |
self windowGroup withWaitCursorDo:[ |
|
1807 |
|cls privateClass| |
|
4675 | 1808 |
|
5066 | 1809 |
(nameOfVariable startsWith:'#') ifTrue:[ |
1810 |
sym := (nameOfVariable copyFrom:2) asSymbolIfInterned. |
|
1811 |
browserClass browseForSymbol:sym. |
|
5065 | 1812 |
] ifFalse:[ |
5066 | 1813 |
"/ is it a class variable? |
1814 |
((cls := self editedClass) notNil |
|
1815 |
and:[ (cls theNonMetaclass allClassVarNames includes:nameOfVariable) ]) ifTrue:[ |
|
1816 |
browserClass |
|
1817 |
browseRefsTo:nameOfVariable |
|
1818 |
classVars:true |
|
5116 | 1819 |
in:(cls theNonMetaclass whichClassDefinesClassVar:nameOfVariable) withAllSubclasses |
5066 | 1820 |
modificationsOnly:false. |
5065 | 1821 |
] ifFalse:[ |
5066 | 1822 |
"/ is it a private class? |
1823 |
(cls notNil |
|
1824 |
and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfVariable) notNil ]) ifTrue:[ |
|
1825 |
browserClass browseReferendsOf:(privateClass name) |
|
5065 | 1826 |
] ifFalse:[ |
5066 | 1827 |
|pool nsClass| |
1828 |
||
1829 |
"/ is it a pool variable? |
|
1830 |
cls notNil ifTrue:[ |
|
1831 |
pool := cls theNonMetaclass sharedPools |
|
1832 |
detect:[:pool | pool classVarNames includes:nameOfVariable] |
|
1833 |
ifNone:nil. |
|
1834 |
]. |
|
1835 |
pool notNil ifTrue:[ |
|
1836 |
browserClass browseReferendsOf:(pool name,':',nameOfVariable) |
|
5065 | 1837 |
] ifFalse:[ |
5066 | 1838 |
(cls notNil |
1839 |
and:[ cls nameSpace notNil |
|
1840 |
and:[ nameOfVariable knownAsSymbol |
|
1841 |
and:[ (nsClass := cls nameSpace at:nameOfVariable asSymbol) notNil |
|
1842 |
]]]) ifTrue:[ |
|
1843 |
"/ a namespace class? |
|
1844 |
browserClass browseReferendsOf:nsClass name |
|
5065 | 1845 |
] ifFalse:[ |
5066 | 1846 |
"/ an instvar? |
5250 | 1847 |
(cls notNil and:[cls allInstVarNames includes:nameOfVariable]) ifTrue:[ |
5066 | 1848 |
browserClass |
1849 |
browseInstRefsTo:nameOfVariable |
|
1850 |
under:(cls whichClassDefinesInstVar:nameOfVariable) |
|
1851 |
modificationsOnly:false |
|
1852 |
] ifFalse:[ |
|
1853 |
"/ no, assume global |
|
1854 |
browserClass browseReferendsOf:nameOfVariable |
|
1855 |
] |
|
5065 | 1856 |
] |
1857 |
] |
|
1858 |
] |
|
1859 |
] |
|
1860 |
] |
|
1861 |
]. |
|
2454 | 1862 |
]. |
1863 |
||
1864 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
1865 |
"Modified: / 5.11.2001 / 17:32:38 / cg" |
|
1866 |
! |
|
1867 |
||
2462 | 1868 |
browseSendersOfIt |
1869 |
"open a browser on the senders of the selected text" |
|
1870 |
||
2715 | 1871 |
|selectedText selector| |
2462 | 1872 |
|
4617 | 1873 |
selectedText := self selectedTextOrSyntaxElement. |
1874 |
selectedText notEmptyOrNil ifTrue:[ |
|
5053 | 1875 |
self windowGroup withWaitCursorDo:[ |
1876 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
|
1877 |
(UserPreferences systemBrowserClass) |
|
1878 |
browseAllCallsOn:(selector ? selectedText) |
|
1879 |
] |
|
2462 | 1880 |
]. |
1881 |
||
1882 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1883 |
"Modified: / 19.11.2001 / 22:15:27 / cg" |
2462 | 1884 |
! |
1885 |
||
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1886 |
browseSharedPoolOfIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1887 |
"open a browser on the shared pool in which the selected variable is" |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1888 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1889 |
|sel| |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1890 |
|
4617 | 1891 |
sel := self selectedTextOrSyntaxElement. |
1892 |
sel notEmptyOrNil ifTrue:[ |
|
5053 | 1893 |
sel := sel asSymbol. |
1894 |
self windowGroup withWaitCursorDo:[ |
|
1895 |
SharedPool allSubclassesDo:[:eachPool | |
|
1896 |
(eachPool includesKey:sel) ifTrue:[ |
|
1897 |
(UserPreferences systemBrowserClass) |
|
1898 |
openInClass:eachPool class selector:#initialize |
|
1899 |
]. |
|
1900 |
]. |
|
1901 |
]. |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1902 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1903 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1904 |
"Created: / 15-01-2011 / 14:01:39 / cg" |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1905 |
! |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1906 |
|
418 | 1907 |
doIt |
1908 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
1909 |
and finally restore cursor; return result of evaluation" |
|
1910 |
||
5053 | 1911 |
^ self |
1912 |
do:(self selectionOrTextOfCursorLine) |
|
1913 |
withValueDo:nil |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1914 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1915 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 1916 |
! |
1917 |
||
1918 |
editMenu |
|
1107 | 1919 |
"return my popUpMenu; thats the superclasses menu |
1920 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
|
1921 |
||
5053 | 1922 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
5065 | 1923 |
#CommentSelection #UncommentSelection |
1924 |
#BrowseIt #ImplementorsOfIt |
|
1925 |
)> |
|
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
1926 |
<resource: #programMenu> |
489 | 1927 |
|
4998 | 1928 |
|m sub subsub idx sensor sel2 sel selectedSymbol| |
418 | 1929 |
|
1930 |
m := super editMenu. |
|
3252 | 1931 |
((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
5065 | 1932 |
sub := m. |
1933 |
m := nil. |
|
2459 | 1934 |
] ifFalse:[ |
5065 | 1935 |
sub := m subMenuAt:#others. |
2459 | 1936 |
]. |
418 | 1937 |
|
2459 | 1938 |
sub notNil ifTrue:[ |
5065 | 1939 |
" |
1940 |
workspaces support #browse, implementors etc. add them after paste. |
|
1941 |
" |
|
1942 |
sub |
|
1943 |
addItemList:#( |
|
1944 |
('-' ) |
|
1945 |
('Browse' browseIt BrowseIt ) |
|
1946 |
('Browse Pool' browseSharedPoolOfIt ) |
|
1947 |
('Senders of It' browseSendersOfIt ) |
|
1948 |
('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
|
1949 |
('References to It' browseReferencesToIt ) |
|
3910 | 1950 |
"/ ('Classes Containing It in Name' browseClassesContainingItInName ) |
1951 |
"/ ('Methods Contaníning It in Name' browseMethodsContainingItInName ) |
|
1952 |
"/ ('Methods Contaníning It in Source' browseMethodsContainingItInSource ) |
|
5065 | 1953 |
('-' ) |
1954 |
('TimeIt' timeIt ) |
|
1955 |
('SpyOnIt' spyOnIt )) |
|
1956 |
resources:resources |
|
1957 |
after:#gotoLine. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1958 |
|
5065 | 1959 |
subsub := sub subMenuAt:#tools. |
1960 |
subsub notNil ifTrue:[ |
|
1961 |
subsub |
|
1962 |
addItemList:#( |
|
1963 |
('-' ) |
|
1964 |
('CommentIt' commentSelection CommentSelection ) |
|
1965 |
('UncommentIt' uncommentSelection UncommentSelection )) |
|
1966 |
resources:resources |
|
1967 |
after:#'indent'. |
|
1968 |
]. |
|
2867 | 1969 |
|
5065 | 1970 |
self hasSelection ifFalse:[ |
1971 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt |
|
1972 |
browseReferencesToIt timeIt spyOnIt |
|
1973 |
browseSharedPoolOfIt browseIt). |
|
1974 |
self supportsSyntaxElements ifTrue:[ |
|
1975 |
self syntaxElementForSelectorUnderCursor notNil ifTrue:[ |
|
1976 |
sub enableAll:#(browseImplementorsOfIt browseSendersOfIt ) |
|
1977 |
] ifFalse:[ |
|
1978 |
|el| |
|
4617 | 1979 |
|
5065 | 1980 |
(el := self syntaxElementForVariableUnderCursor) notNil ifTrue:[ |
1981 |
(el isGlobal or:[el isInstanceVariable]) ifTrue:[ |
|
1982 |
sub enable: #browseReferencesToIt |
|
1983 |
]. |
|
1984 |
el isClass ifTrue:[ |
|
1985 |
sub enable:#browseIt |
|
1986 |
] |
|
1987 |
] |
|
1988 |
] |
|
1989 |
]. |
|
1990 |
] ifTrue:[ |
|
1991 |
sel := self selectionAsString. |
|
1992 |
sel notNil ifTrue:[ |
|
1993 |
sel asSymbolIfInterned isNil ifTrue:[ |
|
1994 |
sel2 := SystemBrowser extractSelectorFrom:sel. |
|
1995 |
sel2 notNil ifTrue:[ |
|
1996 |
sel2 := sel2 asSymbolIfInterned. |
|
1997 |
]. |
|
1998 |
]. |
|
1999 |
]. |
|
2000 |
(sel2 isNil and:[sel isNil]) ifTrue:[ |
|
2001 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
|
2002 |
]. |
|
2003 |
"/ a global or namespace-var selected ? |
|
2004 |
sel isNil ifTrue:[ |
|
2005 |
sub disable:#browseReferencesToIt. |
|
2006 |
] ifFalse:[ |
|
5066 | 2007 |
(sel startsWith:'#') ifTrue:[ |
2008 |
"/ a symbol selected - can search references |
|
5065 | 2009 |
] ifFalse:[ |
5066 | 2010 |
selectedSymbol := sel asSymbolIfInterned. |
2011 |
(selectedSymbol notNil |
|
2012 |
and:[(Smalltalk includesKey:selectedSymbol) |
|
2013 |
or:[(NameSpace allNameSpaces contains:[:ns | ns includesKey:selectedSymbol]) ]] |
|
2014 |
) ifTrue:[ |
|
2015 |
"/ a global or namespace var selected |
|
2016 |
] ifFalse:[ |
|
2017 |
|cls| |
|
2018 |
||
2019 |
cls := self editedClass. |
|
2020 |
cls notNil ifTrue:[ |
|
2021 |
cls := cls theNonMetaclass. |
|
2022 |
((cls allClassVarNames includes:sel) |
|
2023 |
or:[ (cls theNonMetaclass privateClassNamed:sel) notNil]) ifTrue:[ |
|
2024 |
"/ a classvar or private class |
|
2025 |
] ifFalse:[ |
|
2026 |
|pool| |
|
2027 |
"/ is it a pool variable? |
|
2028 |
pool := cls sharedPools |
|
2029 |
detect:[:pool | pool classVarNames includes:sel] |
|
2030 |
ifNone:nil. |
|
2031 |
pool isNil ifTrue:[ |
|
2032 |
"/ todo: an instvar selected? |
|
2033 |
(cls allInstVarNames includes:sel) ifFalse:[ |
|
2034 |
sub disable:#browseReferencesToIt. |
|
2035 |
]. |
|
5065 | 2036 |
]. |
2037 |
]. |
|
5066 | 2038 |
] ifFalse:[ |
2039 |
sub disable:#browseReferencesToIt. |
|
5065 | 2040 |
]. |
2041 |
]. |
|
2042 |
]. |
|
2043 |
]. |
|
2044 |
(selectedSymbol notNil |
|
2045 |
and:[SharedPool allSubclasses contains:[:pool | pool includesKey:selectedSymbol]]) ifFalse:[ |
|
2046 |
sub disable:#browseSharedPoolOfIt. |
|
2047 |
]. |
|
2048 |
]. |
|
2049 |
self isReadOnly ifTrue:[ |
|
2050 |
sub disableAll:#(commentSelection uncommentSelection) |
|
2051 |
]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
2052 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
2053 |
|
2459 | 2054 |
m notNil ifTrue:[ |
5065 | 2055 |
" |
2056 |
workspaces support #doIt, #printIt and #inspectIt |
|
2057 |
add them after paste. |
|
2058 |
" |
|
2059 |
idx := m indexOf:#paste. |
|
2060 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
2061 |
idx ~~ 0 ifTrue:[ |
|
2062 |
m |
|
2063 |
addItemList:#( |
|
2064 |
('-' ) |
|
2065 |
('DoIt' doIt DoIt ) |
|
2066 |
('PrintIt' printIt PrintIt ) |
|
2067 |
('InspectIt' inspectIt InspectIt)) |
|
2068 |
resources:resources |
|
2069 |
after:idx. |
|
4998 | 2070 |
|
5065 | 2071 |
]. |
2459 | 2072 |
|
5065 | 2073 |
(self hasSelectionOrTextInCursorLine) ifFalse:[ |
2074 |
|lNr line| |
|
3272 | 2075 |
|
5065 | 2076 |
lNr := self cursorLine. |
2077 |
line := self listAt:lNr. |
|
2078 |
line isEmptyOrNil ifTrue:[ |
|
2079 |
m disableAll:#(printIt doIt inspectIt browseIt) |
|
2080 |
]. |
|
2081 |
]. |
|
2082 |
self isReadOnly ifTrue:[ |
|
2083 |
m disable:#printIt |
|
2084 |
]. |
|
418 | 2085 |
]. |
2086 |
||
2459 | 2087 |
^ m ? sub. |
430 | 2088 |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
2089 |
"Modified: / 22-04-1998 / 21:49:06 / ca" |
4342 | 2090 |
"Modified: / 20-12-2011 / 11:22:20 / cg" |
418 | 2091 |
! |
2092 |
||
2093 |
inspectIt |
|
2094 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
2095 |
and start an inspector on the result" |
|
2096 |
||
2981
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2097 |
|shifted| |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2098 |
|
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2099 |
shifted := self sensor shiftDown. |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
2100 |
|
5053 | 2101 |
^ self |
2102 |
do:(self selectionOrTextOfCursorLine) |
|
2103 |
withValueDo:[:result | shifted ifTrue:[result basicInspect] ifFalse:[result inspect] ] |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
2104 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
2105 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 2106 |
! |
2107 |
||
2108 |
printIt |
|
2109 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
2110 |
and insert result of evaluation into my text. |
|
2111 |
If the text is readOnly, do nothing." |
|
2112 |
||
1734 | 2113 |
self isReadOnly ifTrue:[ |
5148 | 2114 |
self beep. |
2115 |
^ self. |
|
3511 | 2116 |
]. |
5053 | 2117 |
self |
5148 | 2118 |
undoableDo:[ |
2119 |
self |
|
2120 |
do:(self selectionOrTextOfCursorLine) |
|
2121 |
withValueDo:[:result | |
|
2122 |
|s printer| |
|
2123 |
||
2124 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
|
2125 |
(self editedLanguage notNil |
|
2126 |
and:[(printer := self editedLanguage valuePrinterClass) notNil]) ifTrue:[ |
|
2127 |
s := printer printStringForPrintItOf:result |
|
2128 |
] ifFalse:[ |
|
2129 |
(result isInteger |
|
2130 |
and:[ result > 10 |
|
2131 |
and:[ InspectorView defaultIntegerDisplayRadix ~= 10 ]]) ifTrue:[ |
|
2132 |
s := result displayString , ' "',(result radixPrintStringRadix: InspectorView defaultIntegerDisplayRadix),'"'. |
|
2133 |
] ifFalse:[ |
|
2134 |
s := result printStringForPrintIt "old: displayString" "very old: printString" |
|
2135 |
]. |
|
2136 |
]. |
|
2137 |
self withAutoIndent:false do:[ self insertSelectedStringAtCursor:s ] |
|
2138 |
] |
|
2139 |
] |
|
2140 |
info:'PrintIt' |
|
3511 | 2141 |
|
4401 | 2142 |
"Modified: / 08-03-2012 / 16:14:34 / cg" |
3511 | 2143 |
! |
418 | 2144 |
|
4471 | 2145 |
profileIt |
2146 |
"user selected 'profileIt' from menu; show a wait-cursor, profile the code |
|
4472 | 2147 |
and finally restore the cursor. Open a visual profiler on the sample data." |
4471 | 2148 |
|
4472 | 2149 |
self spyOnItUsing:Tools::Profiler |
4471 | 2150 |
! |
2151 |
||
3511 | 2152 |
replaceIt |
2153 |
"like printIt, but replace the selection with the result, instead of |
|
2154 |
pasting it after the selection." |
|
2155 |
||
2156 |
self isReadOnly ifTrue:[ |
|
5053 | 2157 |
self beep. |
2158 |
^ self |
|
3511 | 2159 |
]. |
2160 |
||
5053 | 2161 |
self |
2162 |
undoableDo:[ |
|
2163 |
self |
|
2164 |
do:(self selectionOrTextOfCursorLine) |
|
2165 |
withValueDo:[:result | |
|
2166 |
self replaceSelectionBy:(result displayString "printString") |
|
2167 |
]. |
|
2168 |
undoSupport actionInfo:'ReplaceIt'. |
|
2169 |
] |
|
2170 |
info:'ReplaceIt' |
|
3511 | 2171 |
|
2172 |
"Created: / 08-11-2007 / 11:31:54 / cg" |
|
1501 | 2173 |
! |
2174 |
||
2175 |
spyOnIt |
|
2176 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
4472 | 2177 |
and finally restore the cursor. Show profile data on the Transcript" |
2178 |
||
2179 |
self spyOnItUsing:MessageTally |
|
2180 |
! |
|
2181 |
||
2182 |
spyOnItUsing:aProfiler |
|
2183 |
"common code for spyOnIt / profileIt. |
|
2184 |
Show a wait-cursor, evaluate the code with profier on it, |
|
2185 |
and finally restore the cursor. Show profile data as per profiler" |
|
1501 | 2186 |
|
2187 |
|code| |
|
2188 |
||
4427 | 2189 |
compilerClass == Smalltalk::Compiler ifFalse:[ |
5053 | 2190 |
"sigh - this measurement will include the time to compile - sigh" |
2191 |
aProfiler spyDetailedOn:[ self doIt ]. |
|
2192 |
^ self. |
|
4427 | 2193 |
]. |
2194 |
||
4929 | 2195 |
code := aProfiler name,' spyDetailedOn:[' , (self selectionOrTextOfCursorLine), ']'. |
4149 | 2196 |
self do:code withValueDo:[:value| ]. |
1501 | 2197 |
! |
2198 |
||
2199 |
timeIt |
|
2200 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
2201 |
and finally restore cursor; return result of evaluation" |
|
2202 |
||
5135 | 2203 |
|code| |
4427 | 2204 |
|
2205 |
compilerClass == Smalltalk::Compiler ifFalse:[ |
|
5135 | 2206 |
"sigh - this measurement will include the time to compile - sigh" |
2207 |
[ self doIt ] benchmark:'execution time: '. |
|
2208 |
^ self. |
|
4427 | 2209 |
]. |
1501 | 2210 |
|
5135 | 2211 |
code := '[' , self selectionAsString, '] benchmark:''execution time: '''. |
4149 | 2212 |
self do:code withValueDo:[:value | ]. |
1501 | 2213 |
|
4427 | 2214 |
"Modified: / 22-04-1998 / 22:03:51 / ca" |
2215 |
"Modified (format): / 02-06-2012 / 00:38:51 / cg" |
|
418 | 2216 |
! ! |
2217 |
||
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2218 |
!Workspace methodsFor:'misc'! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2219 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2220 |
expandAbbreviation |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2221 |
"after receiving an Alt-shift key-event, look for the string before the |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2222 |
cursor, find an abbrev for it and expand." |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2223 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2224 |
|expandedString abortExpandAction oldSelectionStartLine oldSelectionStartCol oldSelectionEndLine oldSelectionEndCol oldCursorLine oldCursorCol |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2225 |
newCursorPos replStartCol| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2226 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2227 |
oldCursorLine := self cursorLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2228 |
oldCursorCol := self cursorCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2229 |
oldSelectionStartLine := self selectionStartLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2230 |
oldSelectionStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2231 |
oldSelectionEndLine := self selectionEndLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2232 |
oldSelectionEndCol := self selectionEndCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2233 |
|
5053 | 2234 |
abortExpandAction := |
2235 |
[ |
|
2236 |
self |
|
2237 |
selectFromLine:oldSelectionStartLine col:oldSelectionStartCol |
|
2238 |
toLine:oldSelectionEndLine col:oldSelectionEndCol. |
|
2239 |
self cursorLine:oldCursorLine col:oldCursorCol. |
|
2240 |
]. |
|
4706 | 2241 |
|
2242 |
expandedString := self selectAbbreviationKeyBeforeCursor. "/ returns the new string AND selects the key |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2243 |
expandedString isNil ifTrue:[ |
5053 | 2244 |
abortExpandAction value. |
2245 |
^ self |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2246 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2247 |
newCursorPos := expandedString indexOf:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2248 |
newCursorPos ~~ 0 ifTrue:[ |
5053 | 2249 |
expandedString := expandedString copyWithout:$!!. |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2250 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2251 |
replStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2252 |
self |
5053 | 2253 |
undoableDo:[ |
2254 |
self replaceSelectionBy: expandedString |
|
2255 |
] |
|
2256 |
info:'Replace'. |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2257 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2258 |
newCursorPos == 0 ifTrue:[ |
5053 | 2259 |
"/ cursor already fine (at the end) |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2260 |
] ifFalse:[ |
5053 | 2261 |
self cursorCol:replStartCol+newCursorPos-1 |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2262 |
] |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2263 |
! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2264 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2265 |
findAbbreviationKeyBeforeCursor |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2266 |
"after receiving an Alt-shift key-event, look for the string before the |
5053 | 2267 |
cursor, find an abbrev for it, return the key and the abbreviation for it. |
4706 | 2268 |
If none is found, return nil" |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2269 |
|
4745 | 2270 |
|snippets keys minMax maxKeyLen minKeyLen stringBeforeCursor| |
2271 |
||
5144 | 2272 |
snippets := self class snippets. |
4745 | 2273 |
keys := snippets keys. |
4714 | 2274 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2275 |
minMax := (keys collect:[:k | k size]) minMax. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2276 |
minKeyLen := minMax first. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2277 |
maxKeyLen := minMax second. |
4714 | 2278 |
|
2279 |
stringBeforeCursor := self lineStringBeforeCursor. |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2280 |
maxKeyLen := maxKeyLen min:stringBeforeCursor size. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2281 |
|
4706 | 2282 |
maxKeyLen to:minKeyLen by:-1 do:[:keyLen | |
5144 | 2283 |
|lCharactersBeforeCursor expandedString| |
2284 |
||
2285 |
lCharactersBeforeCursor := stringBeforeCursor last:keyLen. |
|
2286 |
expandedString := snippets at:lCharactersBeforeCursor ifAbsent:nil. |
|
2287 |
expandedString notNil ifTrue:[ |
|
2288 |
^ { lCharactersBeforeCursor . expandedString withCRs } |
|
2289 |
]. |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2290 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2291 |
^ nil. |
4185 | 2292 |
|
2293 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
4617 | 2294 |
! |
2295 |
||
4706 | 2296 |
selectAbbreviationKeyBeforeCursor |
2297 |
"after receiving an Alt-shift key-event, look for the string before the |
|
5053 | 2298 |
cursor, find an abbrev for it, select it and return the abbreviation for it. |
4706 | 2299 |
If none is found, do not select and return nil" |
2300 |
||
4745 | 2301 |
|keyAndSnippet snippet key| |
2302 |
||
2303 |
(keyAndSnippet := self findAbbreviationKeyBeforeCursor) notNil ifTrue:[ |
|
5053 | 2304 |
key := keyAndSnippet first. |
2305 |
snippet := keyAndSnippet second. |
|
2306 |
self selectFromLine:cursorLine col:cursorCol-key size toLine:cursorLine col:cursorCol-1. |
|
2307 |
^ snippet |
|
4706 | 2308 |
]. |
2309 |
^ nil. |
|
2310 |
||
2311 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
2312 |
! |
|
2313 |
||
4617 | 2314 |
selectedTextOrSyntaxElement |
2315 |
|selectedText el| |
|
2316 |
||
2317 |
selectedText := self selectionAsString. |
|
2318 |
selectedText isEmptyOrNil ifTrue:[ |
|
5065 | 2319 |
el := self syntaxElementUnderCursor. |
2320 |
el notNil ifTrue:[ selectedText := el value ]. |
|
4617 | 2321 |
]. |
5053 | 2322 |
^ selectedText |
4998 | 2323 |
! |
2324 |
||
2325 |
syntaxElementForSelectorUnderCursor |
|
5065 | 2326 |
"we do not support syntax elements, but subclasses may do" |
2327 |
||
2328 |
^ nil |
|
2329 |
! |
|
2330 |
||
2331 |
syntaxElementUnderCursor |
|
2332 |
"we do not support syntax elements, but subclasses may do" |
|
4998 | 2333 |
|
2334 |
^ nil |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2335 |
! ! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2336 |
|
2646 | 2337 |
!Workspace methodsFor:'queries'! |
2338 |
||
2339 |
isWorkspace |
|
4395 | 2340 |
"back-query from the compiler to ask if this is an interactive view |
2341 |
(for error feedback)" |
|
2342 |
||
2646 | 2343 |
^ true |
4395 | 2344 |
|
2345 |
"Modified (comment): / 07-03-2012 / 17:52:59 / cg" |
|
2646 | 2346 |
! ! |
2347 |
||
206 | 2348 |
!Workspace class methodsFor:'documentation'! |
2349 |
||
4402 | 2350 |
version |
5250 | 2351 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.340 2015-02-06 13:50:52 cg Exp $' |
4402 | 2352 |
! |
2353 |
||
3959 | 2354 |
version_CVS |
5250 | 2355 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.340 2015-02-06 13:50:52 cg Exp $' |
858 | 2356 |
! ! |
5065 | 2357 |