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