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