author | Claus Gittinger <cg@exept.de> |
Tue, 14 Oct 2008 10:32:45 +0200 | |
changeset 3728 | 5bbf7c4a0231 |
parent 3726 | a95a68928876 |
child 3735 | 3b616f1c9f9b |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
2277 | 12 |
"{ Package: 'stx:libwidg' }" |
13 |
||
0 | 14 |
TextCollector subclass:#Workspace |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
15 |
instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor |
2679 | 16 |
commentStrings autoDefineWorkspaceVariables simulatedSelf |
3537 | 17 |
autoDefineVariables compilerClass allowValueDrop |
18 |
poolsConsideredInDoIts' |
|
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
19 |
classVariableNames:'DefaultViewBackground DefaultErrorForegroundColor |
3007 | 20 |
DefaultErrorBackgroundColor DefaultWarningBackgroundColor |
3712 | 21 |
DefaultWarningForegroundColor WorkspaceVariables DoItHistory |
22 |
Sniplets' |
|
257 | 23 |
poolDictionaries:'' |
2097 | 24 |
category:'Interface-Smalltalk' |
0 | 25 |
! |
26 |
||
3155 | 27 |
Workspace comment:'declared from: ..\..\..\stx\libwidg\abbrev.stc' |
28 |
! |
|
29 |
||
32 | 30 |
!Workspace class methodsFor:'documentation'! |
31 |
||
38 | 32 |
copyright |
33 |
" |
|
34 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 35 |
All Rights Reserved |
38 | 36 |
|
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
! |
|
45 |
||
32 | 46 |
documentation |
47 |
" |
|
48 |
a view for editable text which can evaluate expressions. |
|
38 | 49 |
I.e. its basically a view for editable text, with added |
50 |
'doIt', 'printIt' and 'inspectIt' functions on the popup-menu. |
|
125 | 51 |
|
38 | 52 |
The action to be performed on doIt is defined by a block, |
58 | 53 |
which can be defined by the owner of this view. |
60 | 54 |
(thus you can put a workspace into more complex widgets, and |
55 |
control what should happen on 'doIt'). |
|
58 | 56 |
|
578 | 57 |
A useful default action is automatically defined, which simply |
58 |
evaluates the selection as a smalltalk expression. |
|
59 |
(but, a lisp or prolog workspace would define its own action, |
|
60 |
to call for another compiler/interpreter ...) |
|
32 | 61 |
|
123 | 62 |
|
63 |
Caveat: |
|
418 | 64 |
in this version, Workspace does not yet support doIt in MVC setups. |
65 |
For now, simulate this by setting the doItAction, to notify the |
|
66 |
model manually about the doIt. |
|
123 | 67 |
|
68 |
||
578 | 69 |
[instance variables:] |
32 | 70 |
|
121 | 71 |
doItAction <Block> block to evaluate for doIt |
123 | 72 |
|
121 | 73 |
errorFgColor <Color> fg-Color to be used when highlighting errors |
74 |
||
75 |
errorBgColor <Color> bg-Color to be used when highlighting errors |
|
58 | 76 |
|
578 | 77 |
codeStartPosition private temporary |
121 | 78 |
|
578 | 79 |
|
80 |
[styleSheet values:] |
|
121 | 81 |
|
82 |
codeErrorSelectionForegroundColor fg color to highlight errors |
|
418 | 83 |
(default: selection fg) |
84 |
||
121 | 85 |
codeErrorSelectionBackgroundColor bg color to highlight errors |
418 | 86 |
(default: selection bg) |
578 | 87 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
88 |
[start with:] |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
89 |
Workspace open |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
90 |
|
578 | 91 |
[see also:] |
92 |
Workspace EditTextView |
|
93 |
Parser ByteCodeCompiler |
|
583 | 94 |
|
95 |
[author:] |
|
96 |
Claus Gittinger |
|
32 | 97 |
" |
201 | 98 |
! ! |
99 |
||
3712 | 100 |
!Workspace class methodsFor:'accessing'! |
101 |
||
102 |
sniplets |
|
103 |
Sniplets isNil ifTrue:[ |
|
104 |
Sniplets := Dictionary new. |
|
3713 | 105 |
self initializeDefaultAbbreviations. |
3712 | 106 |
]. |
107 |
^ Sniplets |
|
3713 | 108 |
|
109 |
" |
|
110 |
Sniplets := nil |
|
111 |
" |
|
3712 | 112 |
! |
113 |
||
114 |
sniplets:something |
|
115 |
Sniplets := something. |
|
116 |
! ! |
|
117 |
||
201 | 118 |
!Workspace class methodsFor:'defaults'! |
119 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
120 |
defaultLabel |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
121 |
"my default window label" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
122 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
123 |
^ 'Workspace' |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
124 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
125 |
"Created: / 16.5.1998 / 16:53:37 / cg" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
126 |
! |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
127 |
|
3716 | 128 |
initializeDefaultAbbreviations |
3728 | 129 |
"default sniplets/abbreviations" |
130 |
||
3716 | 131 |
Sniplets |
132 |
at: 'in' put: 'isNil '; |
|
133 |
at: 'nn' put: 'notNil '; |
|
134 |
at: 'it' put: 'ifTrue: [!!]'; |
|
135 |
at: 'if' put: 'ifFalse: [!!]'; |
|
136 |
at: 'itf' put: 'ifTrue: [!!] ifFalse: []'; |
|
137 |
at: 'int' put: 'isNil ifTrue: [!!]'; |
|
138 |
at: 'inf' put: 'isNil ifFalse: [!!]'; |
|
139 |
at: 'ints' put: 'isNil ifTrue: [^self]'; |
|
140 |
at: 'infs' put: 'isNil ifFalse: [^self]'; |
|
3728 | 141 |
at: 'iftrue' put: 'ifTrue'; |
142 |
at: 'iffalse' put: 'ifFalse'; |
|
143 |
at: 'iftrue:' put: 'ifTrue:'; |
|
144 |
at: 'iffalse:' put: 'ifFalse:'; |
|
3716 | 145 |
at: 'wt' put: 'whileTrue: [!!]'; |
146 |
at: 'wf' put: 'whileFalse: [!!]'; |
|
147 |
at: 'do' put: 'do: [:each | !!]'; |
|
148 |
at: 'dt' put: 'detect: [:each | !!]'; |
|
149 |
at: 'de' put: 'detect: [:each | !!]'; |
|
150 |
at: 'det' put: 'detect: [:each | !!]'; |
|
151 |
at: 'dtn' put: 'detect: [:each | !!] ifNone: []'; |
|
152 |
at: 'cl' put: 'collect: [:each | !!]'; |
|
153 |
at: 'co' put: 'collect: [:each | !!]'; |
|
154 |
at: 'col' put: 'collect: [:each | !!]'; |
|
155 |
at: 'sl' put: 'select: [:each | !!]'; |
|
156 |
at: 'se' put: 'select: [:each | !!]'; |
|
157 |
at: 'sel' put: 'select: [:each | !!]'; |
|
158 |
at: 'rj' put: 'reject: [:each | !!]'; |
|
159 |
at: 're' put: 'reject: [:each | !!]'; |
|
160 |
at: 'rej' put: 'reject: [:each | !!]'; |
|
3728 | 161 |
at: 'inj' put: 'inject: !! into:[:pValue :each | ]'; |
162 |
at: 'ex' put: 'Error handle:[ex | !!] do:[]'; |
|
3716 | 163 |
at: 'np' put: 'nextPut: '; |
164 |
at: 'npa' put: 'nextPutAll: '; |
|
165 |
at: 'y' put: 'yourself.'; |
|
3728 | 166 |
at: 's' put: 'self '; |
3716 | 167 |
at: 'sh' put: 'self halt.'; |
168 |
at: 'ps' put: 'printString'; |
|
169 |
at: 'sr' put: 'self subclassResponsibility'; |
|
170 |
at: 'st' put: 'Smalltalk'; |
|
171 |
at: 'ts' put: 'Transcript showCR: '; |
|
172 |
at: 'trs' put: 'Transcript showCR: '; |
|
173 |
at: 'ik' put: 'includesKey: #'; |
|
174 |
at: 'abb' put: 'Workspace sniplets inspect'; |
|
175 |
at: 'ws' put: 'Delay waitForSeconds: 1'; |
|
176 |
at: 'wfs' put: 'Delay waitForSeconds: 1'; |
|
177 |
at: 'wfm' put: 'Delay waitForMilliseconds: 1000'; |
|
3728 | 178 |
at: 'eslf' put: 'self'; |
3716 | 179 |
at: 'slef' put: 'self'; |
3728 | 180 |
at: 'sefl' put: 'self'; |
3716 | 181 |
at: 'ati' put: 'at:!! ifAbsent: '; |
3728 | 182 |
at: 'ini' put: 'initialize', String lf,' super initialize.', String lf, ' '; |
183 |
at: 'newi' put: 'new', String lf,' ^ super new initialize.'; |
|
3716 | 184 |
at: 'A' put: 'Array'; |
185 |
at: 'An' put: 'Array new:'; |
|
186 |
at: 'OC' put: 'OrderedCollection'; |
|
187 |
at: 'Di' put: 'Dictionary'; |
|
188 |
at: 'ID' put: 'IdentityDictionary'; |
|
189 |
at: 'Id' put: 'IdentityDictionary'; |
|
3717 | 190 |
at: 'OCn' put: 'OrderedCollection new.'; |
191 |
at: 'Aw' put: 'Array with:'; |
|
192 |
at: 'Aww' put: 'Array with:!! with:'; |
|
193 |
at: 'Awww' put: 'Array with:!! with: with:'; |
|
3728 | 194 |
at: '0' put: '(0.0 @ 0.0)'; |
195 |
at: '[' put: '[:!! ] '; |
|
3716 | 196 |
yourself |
197 |
! |
|
198 |
||
201 | 199 |
updateStyleCache |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
200 |
"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
|
201 |
|
1354 | 202 |
<resource: #style (#'codeErrorSelection.foregroundColor' |
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
203 |
#'codeErrorSelection.backgroundColor' |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
204 |
#'codeView.backgroundColor' )> |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
205 |
|
1354 | 206 |
DefaultErrorForegroundColor := StyleSheet colorAt:'codeErrorSelection.foregroundColor'. |
207 |
DefaultErrorBackgroundColor := StyleSheet colorAt:'codeErrorSelection.backgroundColor'. |
|
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
208 |
DefaultViewBackground := StyleSheet colorAt:'codeView.backgroundColor'. |
32 | 209 |
! ! |
210 |
||
2776 | 211 |
!Workspace class methodsFor:'getting a new Workspace'! |
0 | 212 |
|
32 | 213 |
open |
0 | 214 |
"launch a new workspace" |
215 |
||
418 | 216 |
|scr topView workspace f| |
0 | 217 |
|
418 | 218 |
topView := StandardSystemView |
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
219 |
label:(self classResources string:(self defaultLabel)) |
1901
b3556ff49778
removed minExtent - let topView decide.
Claus Gittinger <cg@exept.de>
parents:
1738
diff
changeset
|
220 |
" minExtent:(100 @ 100)". |
23 | 221 |
|
418 | 222 |
scr := HVScrollableView for:self in:topView. |
223 |
scr origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
224 |
workspace := scr scrolledView. |
|
0 | 225 |
|
418 | 226 |
"/ adjust topViews extent according to my font |
227 |
||
0 | 228 |
f := workspace font. |
229 |
topView extent:((f widthOf:'x') * 40) @ (f height * 10). |
|
7 | 230 |
topView open. |
131 | 231 |
^ workspace |
0 | 232 |
|
58 | 233 |
" |
234 |
Workspace open |
|
235 |
" |
|
418 | 236 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
237 |
"Modified: / 16.5.1998 / 16:53:53 / cg" |
857 | 238 |
! |
239 |
||
240 |
openForRemote:hostName |
|
241 |
"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
|
242 |
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
|
243 |
and the result is shown here. |
857 | 244 |
This requires the RemoteObjects package to be loaded." |
245 |
||
246 |
|server remoteCompiler workspace| |
|
247 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
248 |
RemoteObjectServer isNil ifTrue:[ |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
249 |
self warn:'no remoteObjectServer available'. |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
250 |
^ nil |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
251 |
]. |
857 | 252 |
|
253 |
server := RemoteObjectServer on:hostName. |
|
254 |
remoteCompiler := server get:#Compiler. |
|
255 |
||
256 |
workspace := self open. |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
257 |
workspace topView |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
258 |
label:(self classResources string:'Remote Workspace {%1}' with:hostName). |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
259 |
|
857 | 260 |
workspace doItAction: |
261 |
[:theCode | |
|
262 |
remoteCompiler |
|
263 |
evaluate:theCode |
|
264 |
in:nil |
|
265 |
receiver:nil |
|
266 |
notifying:workspace |
|
267 |
logged:true |
|
268 |
ifFail:nil |
|
269 |
] |
|
270 |
" |
|
271 |
Workspace openForRemote:'andi' |
|
272 |
" |
|
273 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
274 |
"Modified: / 16.5.1998 / 16:57:38 / cg" |
2686 | 275 |
! |
276 |
||
2794 | 277 |
openWith:initialText selected:selectedBoolean |
2686 | 278 |
"launch a new workspace with some initial contents" |
279 |
||
280 |
|workspace| |
|
281 |
||
282 |
workspace := self open. |
|
2794 | 283 |
workspace contents:initialText selected:selectedBoolean. |
2686 | 284 |
^ workspace |
285 |
||
286 |
" |
|
287 |
Workspace openWith:'Transcript showCR:''hello world''' |
|
288 |
" |
|
0 | 289 |
! ! |
290 |
||
2657 | 291 |
!Workspace class methodsFor:'history'! |
292 |
||
293 |
clearDoItHistory |
|
294 |
DoItHistory := nil |
|
295 |
! |
|
296 |
||
297 |
doItHistory |
|
298 |
^ DoItHistory |
|
299 |
! |
|
300 |
||
301 |
doItHistorySize |
|
302 |
"the number of remembered doIts" |
|
303 |
||
304 |
^ 20 |
|
305 |
! |
|
306 |
||
307 |
rememberDoIt:aString |
|
308 |
|string| |
|
309 |
||
310 |
string := aString asString string withoutSeparators. |
|
2726 | 311 |
(string asCollectionOfWords size <= 1) ifTrue:[ |
312 |
((Scanner new scanTokens:string) size <= 1) ifTrue:[ |
|
313 |
"its a variable only" |
|
314 |
^ self |
|
315 |
] |
|
316 |
]. |
|
2657 | 317 |
|
318 |
DoItHistory isNil ifTrue:[ |
|
319 |
DoItHistory := OrderedCollection new. |
|
320 |
]. |
|
321 |
DoItHistory remove:string ifAbsent:nil. |
|
322 |
DoItHistory addFirst:string. |
|
323 |
DoItHistory size > self doItHistorySize ifTrue:[ |
|
324 |
DoItHistory removeLast |
|
325 |
]. |
|
2726 | 326 |
|
327 |
Scanner |
|
2657 | 328 |
! ! |
329 |
||
1523
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
330 |
!Workspace class methodsFor:'queries'! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
331 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
332 |
isVisualStartable |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
333 |
"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
|
334 |
(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
|
335 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
336 |
^ self == Workspace |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
337 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
338 |
"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
|
339 |
"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
|
340 |
! ! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
341 |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
342 |
!Workspace class methodsFor:'workspace variables'! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
343 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
344 |
addWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
345 |
"create a new workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
346 |
|
1933 | 347 |
|holder| |
348 |
||
3325 | 349 |
holder := self workspaceVariables at:name ifAbsentPut:[ ValueHolder new ]. |
1933 | 350 |
^ holder |
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
351 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
352 |
|
3157 | 353 |
anyWorkspaceVariableIsDefined |
354 |
^ WorkspaceVariables notEmptyOrNil |
|
355 |
||
356 |
"Created: / 20-04-2005 / 11:57:53 / cg" |
|
357 |
! |
|
358 |
||
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
359 |
removeAllWorkspaceVariables |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
360 |
"delete all workspace variables" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
361 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
362 |
WorkspaceVariables := nil |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
363 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
364 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
365 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
366 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
367 |
removeWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
368 |
"delete a workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
369 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
370 |
WorkspaceVariables notNil ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
371 |
WorkspaceVariables removeKey:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
372 |
WorkspaceVariables isEmpty ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
373 |
WorkspaceVariables := nil |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
374 |
] |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
375 |
]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
376 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
377 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
378 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
379 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
380 |
workspaceVariableAt:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
381 |
"retrieve a workspace variable (actually, a holder onto it)" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
382 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
383 |
WorkspaceVariables isNil ifTrue:[^ nil]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
384 |
^ WorkspaceVariables at:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
385 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
386 |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
387 |
! |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
388 |
|
3157 | 389 |
workspaceVariableNames |
390 |
"retrieve the collection of workspace variable names" |
|
391 |
||
392 |
WorkspaceVariables isNil ifTrue:[^ #()]. |
|
393 |
^ WorkspaceVariables keys |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
394 |
|
3157 | 395 |
"Created: / 20-04-2005 / 11:42:45 / cg" |
396 |
! |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
397 |
|
3157 | 398 |
workspaceVariables |
399 |
"retrieve the collection of workspace variables. |
|
400 |
That is a dictionary associating names to values." |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
401 |
|
3325 | 402 |
WorkspaceVariables isNil ifTrue:[ |
403 |
WorkspaceVariables := Dictionary new. |
|
404 |
]. |
|
405 |
^ WorkspaceVariables |
|
3157 | 406 |
|
407 |
"Modified: / 20-04-2005 / 11:43:14 / cg" |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
408 |
! ! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
409 |
|
201 | 410 |
!Workspace methodsFor:'accessing'! |
0 | 411 |
|
3428 | 412 |
allowValueDrop:aBoolean |
413 |
"if on (the default), any smalltalk value can be dropped and leads to a workspace variable |
|
414 |
holding on to that being defined. Can be turned off, if youdont like this (for standAlone apps)" |
|
415 |
||
416 |
allowValueDrop := aBoolean. |
|
417 |
||
418 |
"Created: / 28-11-2006 / 16:13:02 / cg" |
|
419 |
! |
|
420 |
||
2679 | 421 |
autoDefineVariables |
422 |
^ autoDefineVariables |
|
2535 | 423 |
! |
424 |
||
2679 | 425 |
autoDefineVariables:nilOrSymbol |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
426 |
"undefined variables handling: |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
427 |
are automatically defined as workspace variable if nilOrSymbol is #workspace. |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
428 |
are automatically defined as doit variable if nilOrSymbol is #doit. |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
429 |
are left undefined if nilOrSymbol is nil." |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
430 |
|
2679 | 431 |
autoDefineVariables := nilOrSymbol. |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
432 |
|
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
433 |
"Modified: / 28-11-2006 / 16:21:01 / cg" |
2679 | 434 |
! |
2535 | 435 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
436 |
commentStrings:anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
437 |
"define the comment strings" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
438 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
439 |
commentStrings := anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
440 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
441 |
"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
|
442 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
443 |
|
201 | 444 |
doItAction |
445 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 446 |
|
201 | 447 |
^ doItAction |
0 | 448 |
! |
449 |
||
3007 | 450 |
errorBackgroundColor |
451 |
errorBgColor notNil ifTrue:[ ^ errorBgColor ]. |
|
452 |
DefaultErrorBackgroundColor notNil ifTrue:[ ^ DefaultErrorBackgroundColor ]. |
|
453 |
device hasColors ifTrue:[ ^ Color red ]. |
|
454 |
||
455 |
^ selectionBgColor |
|
456 |
! |
|
457 |
||
458 |
errorForegroundColor |
|
459 |
errorFgColor notNil ifTrue:[ ^ errorFgColor ]. |
|
460 |
DefaultErrorForegroundColor notNil ifTrue:[ ^ DefaultErrorForegroundColor ]. |
|
461 |
^ selectionFgColor |
|
462 |
! |
|
463 |
||
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
464 |
hasSelectionOrTextInCursorLine |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
465 |
^ (self selectionOrTextOfCursorLine:false) notNil |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
466 |
! |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
467 |
|
3537 | 468 |
poolsConsideredInDoIts:something |
469 |
poolsConsideredInDoIts := something. |
|
470 |
! |
|
471 |
||
2727 | 472 |
selectAll |
473 |
super selectAll |
|
474 |
! |
|
475 |
||
3272 | 476 |
selectionOrTextOfCursorLine |
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
477 |
^ self selectionOrTextOfCursorLine:true |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
478 |
! |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
479 |
|
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
480 |
selectionOrTextOfCursorLine:doSelect |
3272 | 481 |
|sel lNr line| |
482 |
||
483 |
sel := self selectionAsString. |
|
484 |
sel notNil ifTrue:[^ sel]. |
|
485 |
||
486 |
lNr := self cursorLine. |
|
487 |
line := self listAt:lNr. |
|
488 |
line notEmptyOrNil ifTrue:[ |
|
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
489 |
doSelect ifTrue:[ |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
490 |
self selectLine:lNr. |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
491 |
]. |
3272 | 492 |
^ line |
493 |
]. |
|
494 |
||
495 |
^ nil |
|
496 |
! |
|
497 |
||
2601 | 498 |
simulatedSelf:anObject |
499 |
"define what self is in an evaluation" |
|
500 |
||
501 |
simulatedSelf := anObject |
|
3007 | 502 |
! |
503 |
||
504 |
warningBackgroundColor |
|
505 |
DefaultWarningBackgroundColor notNil ifTrue:[ ^ DefaultWarningBackgroundColor ]. |
|
506 |
device hasColors ifTrue:[ ^ Color orange ]. |
|
507 |
||
508 |
^ selectionBgColor |
|
509 |
! |
|
510 |
||
511 |
warningForegroundColor |
|
512 |
DefaultWarningForegroundColor notNil ifTrue:[ ^ DefaultWarningForegroundColor ]. |
|
513 |
^ selectionFgColor |
|
201 | 514 |
! ! |
515 |
||
516 |
!Workspace methodsFor:'compiler interface'! |
|
517 |
||
2303 | 518 |
compilerClass |
2980 | 519 |
^ compilerClass ? Compiler |
520 |
! |
|
521 |
||
522 |
compilerClass:aCompilerClass |
|
523 |
compilerClass := aCompilerClass |
|
2303 | 524 |
! |
525 |
||
201 | 526 |
currentSourceCode |
527 |
"special interface to compiler - called by parser |
|
528 |
to get the updated source code after a corrected error" |
|
529 |
||
530 |
^ self contents |
|
0 | 531 |
! |
532 |
||
201 | 533 |
wantChangeLog |
534 |
"sent by the compiler to ask if a changeLog entry should |
|
535 |
be written. Return true here." |
|
0 | 536 |
|
201 | 537 |
^ true |
0 | 538 |
! ! |
539 |
||
2754 | 540 |
!Workspace methodsFor:'compiler interface-error handling'! |
0 | 541 |
|
201 | 542 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
543 |
"compiler notifies us of a correctable error; |
|
544 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
545 |
this method should return true to the compiler if user wants the error |
|
546 |
to be corrected; false otherwise" |
|
547 |
||
548 |
|action| |
|
549 |
||
550 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
3383 | 551 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
552 |
|box declareButton| |
|
553 |
||
554 |
box := ex parameter. |
|
555 |
declareButton := box buttons at:2. |
|
556 |
declareButton pressAction:declareButton controller releaseAction. |
|
557 |
declareButton controller beTriggerOnDown. |
|
558 |
ex proceed. |
|
559 |
] do:[ |
|
560 |
action := OptionBox |
|
561 |
request:aString |
|
3592
cb6f9f060e62
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3579
diff
changeset
|
562 |
label:(resources string:'Correctable Error') |
3383 | 563 |
image:(WarningBox iconBitmap) |
3592
cb6f9f060e62
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3579
diff
changeset
|
564 |
buttonLabels:(resources array:#('Cancel' 'Declare as...' 'Correct...' 'Continue')) |
3383 | 565 |
values:#(#abort #declare #correct #continue) |
566 |
default:#continue |
|
567 |
onCancel:#abort. |
|
568 |
]. |
|
201 | 569 |
]. |
570 |
||
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
571 |
action == #declare ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
572 |
^ action |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
573 |
]. |
201 | 574 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
575 |
AbortOperationRequest raise. |
368 | 576 |
^ false |
201 | 577 |
]. |
368 | 578 |
^ action == #correct |
579 |
||
3383 | 580 |
"Modified: / 05-09-2006 / 12:20:42 / cg" |
201 | 581 |
! |
582 |
||
2104 | 583 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
584 |
"compiler notifies us of a correctable selector warning; |
|
585 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
586 |
this method should return true to the compiler if user wants the error |
|
587 |
to be corrected; false otherwise" |
|
588 |
||
589 |
|action| |
|
590 |
||
3261 | 591 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
2104 | 592 |
action := OptionBox |
593 |
request:aString |
|
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
594 |
label:(resources string:'Warning') |
2983
910b4d5f7b1b
dont send obsolete message (OptionBox request:..form:..)
Claus Gittinger <cg@exept.de>
parents:
2982
diff
changeset
|
595 |
image:(WarningBox iconBitmap) |
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
596 |
buttonLabels:(resources array:#('Cancel' 'Correct...' 'Generate' 'Continue')) |
2338 | 597 |
values:#(#abort #correct #generate #continue) |
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
598 |
default:#continue |
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
599 |
onCancel:#abort. |
2104 | 600 |
]. |
601 |
||
2338 | 602 |
action == #generate ifTrue:[ |
603 |
^ action |
|
604 |
]. |
|
605 |
||
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
606 |
(action isNil or:[action == #abort]) ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
607 |
AbortOperationRequest raise. |
2104 | 608 |
^ false |
609 |
]. |
|
610 |
^ action == #correct |
|
611 |
||
612 |
"Created: / 19.1.2000 / 16:27:28 / cg" |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
613 |
"Modified: / 16.11.2001 / 17:39:29 / cg" |
2104 | 614 |
! |
615 |
||
201 | 616 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 617 |
"obsolete - no longer invoked" |
618 |
||
619 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
620 |
! |
|
621 |
||
622 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
623 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
|
624 |
and show a Box asking for continue/abort." |
|
625 |
||
626 |
^ self error:aString position:relPos to:relEndPos from:aCompiler asWarning:false |
|
627 |
! |
|
628 |
||
629 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
3397 | 630 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
201 | 631 |
and show a Box asking for continue/abort." |
632 |
||
3007 | 633 |
|answer fg bg| |
201 | 634 |
|
3007 | 635 |
fg := asWarning ifTrue:[ self warningForegroundColor ] ifFalse:[ self errorForegroundColor ]. |
636 |
bg := asWarning ifTrue:[ self warningBackgroundColor ] ifFalse:[ self errorBackgroundColor ]. |
|
201 | 637 |
|
3397 | 638 |
self |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
639 |
highlightingErrorPosition:relPos to:relEndPos |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
640 |
withForeground:fg andBackground:bg |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
641 |
do:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
642 |
|box lbl doNotShowAgainHolder l1 y1 y2 l2| |
201 | 643 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
644 |
Warning isHandled ifTrue:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
645 |
Warning raiseErrorString:aString. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
646 |
^ false |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
647 |
]. |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
648 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
649 |
" |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
650 |
ask if we should abort or continue |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
651 |
" |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
652 |
box := YesNoBox |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
653 |
title:aString |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
654 |
yesText:(resources string:'Continue') |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
655 |
noText:(resources string:'Abort'). |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
656 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
657 |
lbl := aCompiler isNil ifTrue:['Compiler'] ifFalse:[aCompiler class name]. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
658 |
asWarning ifTrue:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
659 |
lbl := lbl , ' Warning' |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
660 |
] ifFalse:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
661 |
lbl := lbl , ' Error'. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
662 |
]. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
663 |
box label:lbl. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
664 |
box image:(WarningBox iconBitmap). |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
665 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
666 |
(aCompiler notNil and:[aCompiler class doNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
667 |
doNotShowAgainHolder := false asValue. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
668 |
box addCheckBox:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
669 |
]. |
3007 | 670 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
671 |
answer := box confirm. |
3007 | 672 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
673 |
doNotShowAgainHolder value == true ifTrue:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
674 |
aCompiler class doNotShowCompilerWarningAgainActionQuery actionQuery value |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
675 |
]. |
3007 | 676 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
677 |
box destroy. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
678 |
]. |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
679 |
|
201 | 680 |
" |
681 |
do the abort if we have to |
|
682 |
" |
|
3397 | 683 |
answer ifFalse:[ |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
684 |
AbortOperationRequest raise. |
201 | 685 |
]. |
686 |
^ 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
|
687 |
|
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
688 |
"Created: / 24.11.1995 / 22:56:34 / cg" |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
689 |
"Modified: / 16.11.2001 / 17:39:31 / cg" |
201 | 690 |
! |
691 |
||
2663 | 692 |
highlightingErrorLine:lineNr do:aBlock |
693 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
694 |
||
695 |
|linePosition| |
|
696 |
||
697 |
linePosition := self characterPositionOfLine:lineNr col:1. |
|
698 |
self highlightingErrorPosition:linePosition to:nil do:aBlock |
|
699 |
! |
|
700 |
||
59 | 701 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
702 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 703 |
|
3007 | 704 |
self |
705 |
highlightingErrorPosition:relPos to:relEndPos |
|
706 |
withForeground:(self errorForegroundColor) andBackground:(self errorBackgroundColor) |
|
707 |
do:aBlock |
|
708 |
! |
|
709 |
||
710 |
highlightingErrorPosition:relPos to:relEndPos withForeground:hilightFg andBackground:hilightBg do:aBlock |
|
711 |
"evaluate aBlock while some selection is shown highlighted with colors passed as args." |
|
712 |
||
713 |
|absPosition oldFg oldBg| |
|
0 | 714 |
|
58 | 715 |
" |
716 |
change color of selection & hide cursor |
|
717 |
" |
|
3007 | 718 |
oldFg := selectionFgColor. |
719 |
oldBg := selectionBgColor. |
|
720 |
selectionBgColor := hilightBg. |
|
721 |
selectionFgColor := hilightFg. |
|
58 | 722 |
self hideCursor. |
0 | 723 |
|
58 | 724 |
" |
725 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
726 |
we have to adjust the positions given by the compiler, since they |
|
727 |
are relative to the texts start (the compiler did stream-read the code). |
|
728 |
" |
|
0 | 729 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
3427 | 730 |
absPosition := codeStartPosition + (relPos ? 1) - 1. |
0 | 731 |
relEndPos isNil ifTrue:[ |
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
732 |
self selectLineWhereCharacterPosition:absPosition |
0 | 733 |
] ifFalse:[ |
3427 | 734 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + (relEndPos ? 1) - 1) |
0 | 735 |
]. |
736 |
self makeSelectionVisible. |
|
737 |
||
155 | 738 |
device flush. |
58 | 739 |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
740 |
aBlock ensure:[ |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
741 |
" |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
742 |
undo selection color change and show cursor again |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
743 |
" |
3007 | 744 |
selectionFgColor := oldFg. |
745 |
selectionBgColor := oldBg. |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
746 |
self showCursor. |
0 | 747 |
]. |
3427 | 748 |
|
749 |
"Modified: / 16-11-2006 / 16:37:34 / cg" |
|
0 | 750 |
! |
751 |
||
3007 | 752 |
highlightingWarningPosition:relPos to:relEndPos do:aBlock |
753 |
"evaluate aBlock while some selection is shown highlighted with warning colors." |
|
754 |
||
755 |
self |
|
756 |
highlightingErrorPosition:relPos to:relEndPos |
|
757 |
withForeground:(self warningForegroundColor) andBackground:(self warningBackgroundColor) |
|
758 |
do:aBlock |
|
759 |
! |
|
760 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
761 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
762 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
763 |
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
|
764 |
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
|
765 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
766 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
767 |
|action| |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
768 |
|
3007 | 769 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
770 |
action := OptionBox |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
771 |
request:aString |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
772 |
label:(resources string:'Warning') |
2990
1373f301a694
dont send obsolete message to OptionBox
Claus Gittinger <cg@exept.de>
parents:
2983
diff
changeset
|
773 |
image:(WarningBox iconBitmap) |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
774 |
buttonLabels:(resources array:#('Cancel' 'Remove Variable(s)' 'Continue')) |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
775 |
values:#(#abort #correct #continue) |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
776 |
default:#continue. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
777 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
778 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
779 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
780 |
AbortOperationRequest raise. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
781 |
^ false |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
782 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
783 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
784 |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
785 |
"Modified: / 16.11.2001 / 17:39:34 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
786 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
787 |
|
116 | 788 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 789 |
"compiler notifies us of a warning - same behavior as error" |
0 | 790 |
|
2277 | 791 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 792 |
! ! |
793 |
||
3396 | 794 |
!Workspace methodsFor:'drag & drop'! |
795 |
||
796 |
canDrop:aDropContext |
|
797 |
"Any object can be dropped into workspace..." |
|
798 |
||
3428 | 799 |
allowValueDrop ifFalse:[ |
800 |
self isReadOnly ifTrue:[^ false]. |
|
801 |
^ aDropContext dropObjects |
|
802 |
contains:[:someObject| (someObject isTextObject or:[ someObject isFileObject ])]. |
|
803 |
]. |
|
804 |
||
3396 | 805 |
^ true |
806 |
||
807 |
"Created: / 16-08-2005 / 22:01:13 / janfrog" |
|
3428 | 808 |
"Modified: / 28-11-2006 / 16:18:51 / cg" |
3396 | 809 |
! |
810 |
||
3414 | 811 |
doDrop:aDropContext |
3428 | 812 |
self halt. |
813 |
self drop:aDropContext |
|
3414 | 814 |
|
3428 | 815 |
"Modified: / 28-11-2006 / 16:14:51 / cg" |
3414 | 816 |
! |
817 |
||
818 |
drop:aDropContext |
|
819 |
"Any object can be dropped into workspace..." |
|
820 |
||
821 |
|textObjects| |
|
822 |
||
823 |
aDropContext dropObjects do:[:dropObject| |
|
824 |
(dropObject isTextObject or:[ dropObject isFileObject ]) ifTrue:[ |
|
825 |
self dropObjects:(Array with:dropObject) |
|
826 |
"/ self paste:dropObject theObject asStringWithoutFinalCR |
|
827 |
] ifFalse:[ |
|
828 |
name := Dialog |
|
829 |
request:(resources |
|
830 |
string:'Name of new Workspace Variable (refers to the dropped %1):' |
|
831 |
with:dropObject theObject class name allBold |
|
832 |
) |
|
833 |
initialAnswer:'droppedObject' |
|
834 |
okLabel:'Add' |
|
835 |
title:'Enter Variable Name'. |
|
836 |
||
837 |
name notEmptyOrNil ifTrue:[ |
|
838 |
Workspace addWorkspaceVariable:name. |
|
839 |
(Workspace workspaceVariableAt:name) value:dropObject theObject. |
|
840 |
]. |
|
841 |
]. |
|
842 |
]. |
|
843 |
||
844 |
"Created: / 13-10-2006 / 17:34:07 / cg" |
|
3396 | 845 |
! ! |
846 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
847 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
848 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
849 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
850 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
851 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 852 |
in the first col |
853 |
(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
|
854 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
855 |
|eolComment opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
856 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
857 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
858 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
859 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
860 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
861 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
862 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
863 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
864 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
865 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
866 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
867 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
868 |
l isNil ifTrue:[l := '']. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
869 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
870 |
l := eolComment , l |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
871 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
872 |
l := opening , l , closing |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
873 |
]. |
3403 | 874 |
self replaceLine:lineNr with:l. |
875 |
widthOfWidestLine notNil ifTrue:[ |
|
876 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
877 |
]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
878 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
879 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
880 |
|
3403 | 881 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
882 |
"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
|
883 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
884 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
885 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
886 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
887 |
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
|
888 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
889 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
890 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
891 |
|
1481 | 892 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3210 | 893 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
894 |
||
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
895 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
896 |
self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
897 |
undoableDo:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
898 |
self commentFrom:cursorLine to:cursorLine |
3543 | 899 |
] |
900 |
info:'Comment'. |
|
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
901 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
902 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
903 |
|
3129 | 904 |
self |
905 |
undoableDo: |
|
906 |
[ |
|
907 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
908 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
|
909 |
] ifFalse:[ |
|
3210 | 910 |
commentPair := commentStrings at:2 ifAbsent:nil. |
911 |
commentPair isNil ifTrue:[ |
|
912 |
self beep. |
|
913 |
] ifFalse:[ |
|
914 |
opening := commentPair at:1. |
|
915 |
closing := commentPair at:2. |
|
916 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
3129 | 917 |
|
3210 | 918 |
e := selectionEndCol. |
919 |
||
920 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
921 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
3129 | 922 |
|
3210 | 923 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
924 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
925 |
toLine:selectionEndLine col:e+closing size. |
|
926 |
] |
|
3129 | 927 |
] |
928 |
] |
|
929 |
info:'comment' |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
930 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
931 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 932 |
"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
|
933 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
934 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
935 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
936 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
937 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 938 |
in the first col. |
939 |
(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
|
940 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
941 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
942 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
943 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
944 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
945 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
946 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
947 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
948 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
949 |
rest := eolComment size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
950 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
951 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
952 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
953 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
954 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
955 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
956 |
l notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
957 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
958 |
(l startsWith:eolComment) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
959 |
l := l copyFrom:rest |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
960 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
961 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
962 |
((l startsWith:opening) |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
963 |
and:[l endsWith:closing]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
964 |
l := l copyFrom:opening size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
965 |
l := l copyWithoutLast:closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
966 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
967 |
]. |
3403 | 968 |
self replaceLine:lineNr with:l. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
969 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
970 |
]. |
3403 | 971 |
widthOfWidestLine := nil. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
972 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
973 |
|
3403 | 974 |
"Created: / 09-11-1997 / 01:05:43 / cg" |
975 |
"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
|
976 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
977 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
978 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
979 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
980 |
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
|
981 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
982 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
983 |
|e commentPair opening closing sz1 sz2| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
984 |
|
3129 | 985 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
986 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
987 |
self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
988 |
undoableDo:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
989 |
self uncommentFrom:cursorLine to:cursorLine |
3543 | 990 |
] |
991 |
info:'Uncomment'. |
|
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
992 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
993 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
994 |
|
3129 | 995 |
self |
996 |
undoableDo: |
|
997 |
[ |
|
998 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
999 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
|
1000 |
] ifFalse:[ |
|
1001 |
commentPair := commentStrings at:2. |
|
1002 |
opening := commentPair at:1. |
|
1003 |
closing := commentPair at:2. |
|
1004 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1005 |
||
1006 |
sz1 := opening size. |
|
1007 |
sz2 := closing size. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1008 |
|
3129 | 1009 |
((self |
1010 |
stringAtLine:selectionStartLine |
|
1011 |
from:selectionStartCol |
|
1012 |
to:selectionStartCol+sz1 - 1) = opening |
|
1013 |
and:[(self |
|
1014 |
stringAtLine:selectionEndLine |
|
1015 |
from:selectionEndCol - sz2 + 1 |
|
1016 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1017 |
|
3129 | 1018 |
self deleteCharsAtLine:selectionEndLine fromCol:selectionEndCol-sz2+1 toCol:selectionEndCol. |
1019 |
self deleteCharsAtLine:selectionStartLine fromCol:selectionStartCol toCol:selectionStartCol+sz1-1. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1020 |
|
3129 | 1021 |
e := selectionEndCol - sz2. |
1022 |
selectionStartLine == selectionEndLine ifTrue:[e := e - sz1]. |
|
1023 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1024 |
toLine:selectionEndLine col:e. |
|
1025 |
] |
|
1026 |
] |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1027 |
] |
3129 | 1028 |
info:'uncomment' |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1029 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1030 |
"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
|
1031 |
"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
|
1032 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1033 |
|
0 | 1034 |
!Workspace methodsFor:'events'! |
1035 |
||
3712 | 1036 |
expandAbbreviation |
3713 | 1037 |
|expandedString abortExpandAction oldSelectionStartLine oldSelectionStartCol oldSelectionEndLine oldSelectionEndCol oldCursorLine oldCursorCol |
1038 |
newCursorPos replStartCol| |
|
3712 | 1039 |
|
3713 | 1040 |
oldCursorLine := self cursorLine. |
1041 |
oldCursorCol := self cursorCol. |
|
1042 |
oldSelectionStartLine := self selectionStartLine. |
|
1043 |
oldSelectionStartCol := self selectionStartCol. |
|
1044 |
oldSelectionEndLine := self selectionEndLine. |
|
1045 |
oldSelectionEndCol := self selectionEndCol. |
|
1046 |
||
1047 |
abortExpandAction := [ |
|
1048 |
self selectFromLine:oldSelectionStartLine |
|
1049 |
col:oldSelectionStartCol |
|
1050 |
toLine:oldSelectionEndLine |
|
1051 |
col:oldSelectionEndCol. |
|
1052 |
self cursorLine: oldCursorLine col: oldCursorCol. |
|
1053 |
]. |
|
1054 |
||
1055 |
expandedString := self findAbbreviationKeyBeforeCursor. |
|
1056 |
expandedString isNil ifTrue:[ |
|
1057 |
abortExpandAction value. |
|
1058 |
^ self |
|
1059 |
]. |
|
1060 |
newCursorPos := expandedString indexOf:$!!. |
|
1061 |
newCursorPos ~~ 0 ifTrue:[ |
|
1062 |
expandedString := expandedString copyWithout:$!!. |
|
1063 |
]. |
|
1064 |
replStartCol := self selectionStartCol. |
|
3714 | 1065 |
self |
1066 |
undoableDo:[ |
|
1067 |
self replaceSelectionWith: expandedString. |
|
1068 |
] info:'Replace'. |
|
3713 | 1069 |
|
1070 |
newCursorPos == 0 ifTrue:[ |
|
1071 |
"/ cursor already fine (at the end) |
|
1072 |
] ifFalse:[ |
|
1073 |
self cursorCol:replStartCol+newCursorPos-1 |
|
1074 |
] |
|
1075 |
! |
|
1076 |
||
1077 |
findAbbreviationKeyBeforeCursor |
|
3726
a95a68928876
abbrevs: start checking for longer sequences first.
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
1078 |
|maxKeyLen minKeyLen line stringBeforeCursor| |
3713 | 1079 |
|
1080 |
maxKeyLen := (self class sniplets keys collect:[:k | k size]) max. |
|
3726
a95a68928876
abbrevs: start checking for longer sequences first.
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
1081 |
minKeyLen := (self class sniplets keys collect:[:k | k size]) min. |
a95a68928876
abbrevs: start checking for longer sequences first.
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
1082 |
line := (self at:cursorLine) ? ''. |
a95a68928876
abbrevs: start checking for longer sequences first.
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
1083 |
stringBeforeCursor := line string copyTo:((cursorCol-1) min:line size). |
3713 | 1084 |
|
3726
a95a68928876
abbrevs: start checking for longer sequences first.
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
1085 |
maxKeyLen := maxKeyLen min:stringBeforeCursor size. |
a95a68928876
abbrevs: start checking for longer sequences first.
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
1086 |
|
a95a68928876
abbrevs: start checking for longer sequences first.
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
1087 |
(maxKeyLen to:minKeyLen by:-1) do:[:l | |
a95a68928876
abbrevs: start checking for longer sequences first.
Claus Gittinger <cg@exept.de>
parents:
3720
diff
changeset
|
1088 |
|lCharactersBeforeCursor expandedString| |
3713 | 1089 |
|
1090 |
lCharactersBeforeCursor := stringBeforeCursor last:l. |
|
1091 |
expandedString := self class sniplets at:lCharactersBeforeCursor ifAbsent:nil. |
|
1092 |
expandedString notNil ifTrue:[ |
|
1093 |
self selectFromLine:cursorLine col:cursorCol-l toLine:cursorLine col:cursorCol-1. |
|
1094 |
^ expandedString |
|
1095 |
]. |
|
1096 |
]. |
|
1097 |
^ nil. |
|
3712 | 1098 |
! |
1099 |
||
0 | 1100 |
keyPress:key x:x y:y |
3712 | 1101 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #ReplaceIt #BrowseIt #ExpandIt)> |
60 | 1102 |
|
32 | 1103 |
(key == #DoIt) ifTrue:[^ self doIt]. |
23 | 1104 |
(key == #InspectIt) ifTrue:[^ self inspectIt]. |
418 | 1105 |
(key == #PrintIt) ifTrue:[^ self printIt]. |
3511 | 1106 |
(key == #ReplaceIt) ifTrue:[^ self replaceIt]. |
2307 | 1107 |
(key == #BrowseIt) ifTrue:[^ self browseIt]. |
3712 | 1108 |
(key == #ImplementorsOfIt) ifTrue:[^ self browseImplementorsOfIt]. |
1109 |
(key == #ExpandAbbreviation) ifTrue:[^ self expandAbbreviation]. |
|
38 | 1110 |
|
0 | 1111 |
super keyPress:key x:x y:y |
3511 | 1112 |
|
1113 |
"Modified: / 08-11-2007 / 11:29:45 / cg" |
|
0 | 1114 |
! ! |
201 | 1115 |
|
2143 | 1116 |
!Workspace methodsFor:'executing'! |
201 | 1117 |
|
1501 | 1118 |
do:code withValueDo:aBlock |
418 | 1119 |
"helper for doIt, printIt and inspectIt. |
1120 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
1121 |
aBlock with the value. |
|
1122 |
Most work is in preparing for proper cleanup in case of abort |
|
1123 |
or other exception while the evaluation is performed. |
|
1124 |
(restore cursor, selectionColors etc.)" |
|
201 | 1125 |
|
1501 | 1126 |
|selLine selCol endLine endCol cLine cCol cleanUp| |
201 | 1127 |
|
1128 |
code notNil ifTrue:[ |
|
2409 | 1129 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
2408 | 1130 |
|
257 | 1131 |
codeStartPosition := self characterPositionOfSelection. |
201 | 1132 |
|
257 | 1133 |
" |
1134 |
remember selection for later - if there is an error, |
|
1135 |
the notification method will highlight it. |
|
1136 |
thus destroying the current selection |
|
1137 |
" |
|
1138 |
selLine := selectionStartLine. |
|
1139 |
selCol := selectionStartCol. |
|
1140 |
endLine := selectionEndLine. |
|
1141 |
endCol := selectionEndCol. |
|
1142 |
cCol := cursorCol. |
|
1143 |
cLine := cursorLine. |
|
201 | 1144 |
|
257 | 1145 |
" |
1146 |
cleanup: restore previous selection and cursor positions |
|
1147 |
" |
|
1148 |
cleanUp := [ |
|
1149 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
1150 |
cLine notNil ifTrue:[ |
|
1151 |
self cursorLine:cLine col:cCol |
|
1152 |
]. |
|
1153 |
]. |
|
201 | 1154 |
|
257 | 1155 |
" |
1156 |
perform the action. |
|
1157 |
Be careful to release the reference to the value; |
|
1158 |
otherwise, we could keep lots of garbage from being freed |
|
1159 |
until the view gets closed |
|
1160 |
" |
|
1161 |
self topView withExecuteCursorDo:[ |
|
1162 |
[ |
|
3008 | 1163 |
AbortOperationRequest handle:[:ex | |
257 | 1164 |
ex return |
1165 |
] do:[ |
|
929 | 1166 |
|value| |
1167 |
||
257 | 1168 |
doItAction notNil ifTrue:[ |
929 | 1169 |
value := doItAction value:(code asString). |
257 | 1170 |
cleanUp value. cleanUp := nil. |
1171 |
aBlock value:value. |
|
2726 | 1172 |
value := nil. |
2657 | 1173 |
self class rememberDoIt:code. |
257 | 1174 |
] |
1175 |
] |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
1176 |
] ensure:[ |
929 | 1177 |
cleanUp notNil ifTrue:[ |
1178 |
cleanUp value. cleanUp := nil |
|
1179 |
]. |
|
257 | 1180 |
] |
1181 |
]. |
|
201 | 1182 |
] |
257 | 1183 |
|
1501 | 1184 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
1185 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
2409 | 1186 |
"Modified: / 26.9.2001 / 17:32:59 / cg" |
201 | 1187 |
! ! |
1188 |
||
2751 | 1189 |
!Workspace methodsFor:'initialization & release'! |
201 | 1190 |
|
2733 | 1191 |
doItAction:aOneArgBlock |
1192 |
"define the action to be performed when 'doIt' is selected. |
|
1193 |
The block will be evaluated, passing the selection as a String argument. |
|
1194 |
A default doItAction is set for you in the initialize method." |
|
1195 |
||
1196 |
doItAction := aOneArgBlock |
|
1197 |
||
1198 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
1199 |
! |
|
1200 |
||
1201 |
executeDoIt:theCode |
|
3537 | 1202 |
^ (self compilerClass new) moreSharedPools:poolsConsideredInDoIts; |
2733 | 1203 |
evaluate:theCode |
1204 |
in:nil |
|
1205 |
receiver:simulatedSelf |
|
1206 |
notifying:self |
|
1207 |
logged:true |
|
1208 |
ifFail:nil |
|
1209 |
! |
|
1210 |
||
201 | 1211 |
initStyle |
966 | 1212 |
"setup viewStyle specifics" |
1213 |
||
201 | 1214 |
super initStyle. |
1215 |
||
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1216 |
DefaultViewBackground notNil ifTrue:[ |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1217 |
viewBackground := DefaultViewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1218 |
self backgroundColor:viewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1219 |
]. |
201 | 1220 |
! |
1221 |
||
1222 |
initialize |
|
1223 |
super initialize. |
|
1224 |
||
2775 | 1225 |
scrollWhenUpdating := #beginOfText. |
201 | 1226 |
showMatchingParenthesis := true. |
3428 | 1227 |
allowValueDrop := true. |
1228 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1229 |
commentStrings := #( |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1230 |
'"/' |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1231 |
('"' '"') |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1232 |
). |
201 | 1233 |
|
1234 |
self initializeDoITAction. |
|
3396 | 1235 |
self initializeDragAndDrop. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1236 |
|
3428 | 1237 |
"Modified: / 28-11-2006 / 16:11:55 / cg" |
201 | 1238 |
! |
1239 |
||
1240 |
initializeDoITAction |
|
1241 |
"set up the block to be evaluated for doIts. |
|
1242 |
This is done here in a separate method to allow easier |
|
1243 |
redefinition in subclasses" |
|
1244 |
||
2733 | 1245 |
doItAction := [:theCode | self executeDoIt:theCode]. |
3396 | 1246 |
! |
1247 |
||
1248 |
initializeDragAndDrop |
|
1249 |
|target| |
|
1250 |
||
1251 |
target := DropTarget |
|
1252 |
receiver:self |
|
1253 |
argument:nil |
|
3411 | 1254 |
dropSelector:#drop: |
3396 | 1255 |
canDropSelector:#canDrop:. |
1256 |
self dropTarget:target |
|
1257 |
||
1258 |
"Created: / 16-08-2005 / 22:03:36 / janfrog" |
|
3411 | 1259 |
"Modified: / 13-10-2006 / 12:37:18 / cg" |
201 | 1260 |
! ! |
1261 |
||
418 | 1262 |
!Workspace methodsFor:'menu & menu actions'! |
1263 |
||
2285 | 1264 |
browseClass |
1265 |
"user selected 'browseClass' from menu; evaluate the code |
|
1266 |
and open a browser on the resulting class (if it evaluates to one)" |
|
1267 |
||
1268 |
^ self |
|
3272 | 1269 |
do:(self selectionAsString) |
2285 | 1270 |
withValueDo:[:result | result isBehavior ifTrue:[ |
2410 | 1271 |
result browserClass openInClass:result selector:nil |
2285 | 1272 |
] ifFalse:[ |
1273 |
self warn:'Selection does not evaluate to a class' |
|
1274 |
] |
|
1275 |
]. |
|
1276 |
||
2410 | 1277 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 1278 |
! |
1279 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1280 |
browseImplementorsOfIt |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1281 |
"open a browser on the implementors of the selected text" |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1282 |
|
2714 | 1283 |
|selectedText selector browserClass| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1284 |
|
2714 | 1285 |
selectedText := self selectionAsString. |
1286 |
selectedText size > 0 ifTrue:[ |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1287 |
self windowGroup withWaitCursorDo:[ |
3287 | 1288 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
2714 | 1289 |
|
1290 |
browserClass := UserPreferences current systemBrowserClass. |
|
1291 |
||
3287 | 1292 |
(selector notNil and:[selector ~= selectedText]) ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1293 |
(SystemBrowser |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1294 |
findImplementorsOfAny:(Array with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1295 |
in:(Smalltalk allClasses) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1296 |
ignoreCase:false) isEmpty ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1297 |
browserClass browseImplementorsOf:selector |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1298 |
] ifFalse:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1299 |
browserClass browseImplementorsOfAny:(Set with:selector with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1300 |
]. |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1301 |
] ifFalse:[ |
2714 | 1302 |
browserClass browseImplementorsOf:(selector ? selectedText) |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1303 |
] |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1304 |
] |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1305 |
]. |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1306 |
|
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1307 |
"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
|
1308 |
"Modified: / 19.11.2001 / 22:15:17 / cg" |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1309 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1310 |
|
2307 | 1311 |
browseIt |
1312 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
2713 | 1313 |
or the class of the resulting object (if it does not evaluate to a class). |
1314 |
||
1315 |
Added feature: if selection is of the form class >> selector, immediately switch to that selector." |
|
1316 |
||
1317 |
|codeToEvaluate idx selector| |
|
1318 |
||
3596 | 1319 |
codeToEvaluate := (self selectionOrTextOfCursorLine ? '') withoutSeparators. |
2713 | 1320 |
idx := codeToEvaluate indexOfSubCollection:'>>'. |
1321 |
idx ~~ 0 ifTrue:[ |
|
2717 | 1322 |
selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string. |
3155 | 1323 |
(selector startsWith:'#') ifTrue:[ |
1324 |
selector := Symbol readFrom:selector. |
|
1325 |
]. |
|
2713 | 1326 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
1327 |
]. |
|
2307 | 1328 |
|
1329 |
^ self |
|
2713 | 1330 |
do:codeToEvaluate |
3284
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1331 |
withValueDo:[:result | |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1332 |
result isNil ifTrue:[ |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1333 |
codeToEvaluate asCollectionOfWords size == 1 ifTrue:[ |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1334 |
codeToEvaluate isUppercaseFirst ifTrue:[ |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1335 |
Dialog information:(codeToEvaluate allBold , ' is unbound or nil'). |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1336 |
^ self. |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1337 |
]. |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1338 |
] |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1339 |
]. |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1340 |
result isBehavior ifTrue:[ |
2713 | 1341 |
result browserClass openInClass:result selector:selector |
2307 | 1342 |
] ifFalse:[ |
2410 | 1343 |
result class browserClass openInClass:(result class) selector:nil |
2307 | 1344 |
] |
1345 |
]. |
|
2410 | 1346 |
|
1347 |
"Modified: / 26.9.2001 / 17:37:50 / cg" |
|
2307 | 1348 |
! |
1349 |
||
2285 | 1350 |
browseItsClass |
1351 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
1352 |
and open a browser on the results class" |
|
1353 |
||
1354 |
^ self |
|
3272 | 1355 |
do:(self selectionAsString) |
2410 | 1356 |
withValueDo:[:result | |
1357 |
result class browserClass openInClass:result class selector:nil |
|
1358 |
] |
|
2285 | 1359 |
|
2410 | 1360 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 1361 |
! |
1362 |
||
2454 | 1363 |
browseReferencesToIt |
1364 |
"open a browser on all references to the selected global" |
|
1365 |
||
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1366 |
|sel| |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1367 |
|
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1368 |
sel := self selectionAsString. |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1369 |
sel size > 0 ifTrue:[ |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1370 |
self windowGroup withWaitCursorDo:[ |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1371 |
(UserPreferences current systemBrowserClass) |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1372 |
browseReferendsOf:sel |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1373 |
]. |
2454 | 1374 |
]. |
1375 |
||
1376 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
1377 |
"Modified: / 5.11.2001 / 17:32:38 / cg" |
|
1378 |
! |
|
1379 |
||
2462 | 1380 |
browseSendersOfIt |
1381 |
"open a browser on the senders of the selected text" |
|
1382 |
||
2715 | 1383 |
|selectedText selector| |
2462 | 1384 |
|
2715 | 1385 |
selectedText := self selectionAsString. |
1386 |
selectedText size > 0 ifTrue:[ |
|
2462 | 1387 |
self windowGroup withWaitCursorDo:[ |
3287 | 1388 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
2462 | 1389 |
(UserPreferences current systemBrowserClass) |
2715 | 1390 |
browseAllCallsOn:(selector ? selectedText) |
2462 | 1391 |
] |
1392 |
]. |
|
1393 |
||
1394 |
"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
|
1395 |
"Modified: / 19.11.2001 / 22:15:27 / cg" |
2462 | 1396 |
! |
1397 |
||
418 | 1398 |
doIt |
1399 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
1400 |
and finally restore cursor; return result of evaluation" |
|
1401 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1402 |
^ self |
3272 | 1403 |
do:(self selectionOrTextOfCursorLine) |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1404 |
withValueDo:[:result | ] |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1405 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1406 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 1407 |
! |
1408 |
||
1409 |
editMenu |
|
1107 | 1410 |
"return my popUpMenu; thats the superclasses menu |
1411 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
|
1412 |
||
2459 | 1413 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
1414 |
#CommentSelection #UncommentSelection |
|
2573
52c995a1ea78
accelerators for browseIt and implementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
2571
diff
changeset
|
1415 |
#BrowseIt #ImplementorsOfIt |
2459 | 1416 |
)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
1417 |
<resource: #programMenu> |
489 | 1418 |
|
2867 | 1419 |
|m sub subsub idx sensor s s2| |
418 | 1420 |
|
1421 |
m := super editMenu. |
|
3252 | 1422 |
((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
2459 | 1423 |
sub := m. |
1424 |
m := nil. |
|
1425 |
] ifFalse:[ |
|
1426 |
sub := m subMenuAt:#others. |
|
1427 |
]. |
|
418 | 1428 |
|
2459 | 1429 |
sub notNil ifTrue:[ |
2867 | 1430 |
|
2459 | 1431 |
" |
2867 | 1432 |
workspaces support #browse, implementors etc. add them after paste. |
2459 | 1433 |
" |
2867 | 1434 |
sub |
1435 |
addItemList:#( |
|
1436 |
('-' ) |
|
1437 |
('Browse' browseIt BrowseIt ) |
|
1438 |
('Senders of It' browseSendersOfIt ) |
|
1439 |
('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
|
1440 |
('References to It' browseReferencesToIt ) |
|
1441 |
('-' ) |
|
1442 |
('TimeIt' timeIt ) |
|
1443 |
('SpyOnIt' spyOnIt )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1444 |
resources:resources |
2459 | 1445 |
after:#gotoLine. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1446 |
|
2867 | 1447 |
subsub := sub subMenuAt:#tools. |
1448 |
subsub notNil ifTrue:[ |
|
1449 |
subsub |
|
1450 |
addItemList:#( |
|
1451 |
('-' ) |
|
1452 |
('Comment' commentSelection CommentSelection ) |
|
1453 |
('Uncomment' uncommentSelection UncommentSelection )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1454 |
resources:resources |
2867 | 1455 |
after:#'indent'. |
1456 |
]. |
|
1457 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1458 |
self hasSelection ifFalse:[ |
3272 | 1459 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt browseReferencesToIt timeIt spyOnIt |
1460 |
commentSelection uncommentSelection ) |
|
2454 | 1461 |
] ifTrue:[ |
1462 |
s := self selectionAsString. |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1463 |
s notNil ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1464 |
s asSymbolIfInterned isNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1465 |
s2 := SystemBrowser extractSelectorFrom:s. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1466 |
s2 notNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1467 |
s2 := s2 asSymbolIfInterned. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1468 |
]. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1469 |
]. |
2454 | 1470 |
]. |
2487
47e0a1faf544
disabling of impl/senders menu
Claus Gittinger <cg@exept.de>
parents:
2485
diff
changeset
|
1471 |
(s2 isNil and:[s isNil]) ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1472 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1473 |
]. |
3606
9676ce5098cb
Do not look up large strings in Smalltalk
Stefan Vogel <sv@exept.de>
parents:
3596
diff
changeset
|
1474 |
(s isNil or:[s asSymbolIfInterned isNil |
9676ce5098cb
Do not look up large strings in Smalltalk
Stefan Vogel <sv@exept.de>
parents:
3596
diff
changeset
|
1475 |
or:[(Smalltalk includesKey:s asSymbol) not]]) |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1476 |
ifTrue:[ |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1477 |
sub disable:#browseReferencesToIt. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1478 |
]. |
2595 | 1479 |
self isReadOnly ifTrue:[ |
2641 | 1480 |
sub disableAll:#(commentSelection uncommentSelection) |
2595 | 1481 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1482 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1483 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1484 |
|
2459 | 1485 |
m notNil ifTrue:[ |
1486 |
" |
|
1487 |
workspaces support #doIt, #printIt and #inspectIt |
|
1488 |
add them after paste. |
|
1489 |
" |
|
1490 |
idx := m indexOf:#paste. |
|
1491 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
1492 |
idx ~~ 0 ifTrue:[ |
|
2867 | 1493 |
m |
1494 |
addItemList:#( |
|
1495 |
('-' ) |
|
1496 |
('DoIt' doIt DoIt ) |
|
1497 |
('PrintIt' printIt PrintIt ) |
|
1498 |
('InspectIt' inspectIt InspectIt)) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1499 |
resources:resources |
2459 | 1500 |
after:idx. |
1501 |
||
1502 |
]. |
|
1503 |
||
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
1504 |
(self hasSelectionOrTextInCursorLine) ifFalse:[ |
3272 | 1505 |
|lNr line| |
1506 |
||
1507 |
lNr := self cursorLine. |
|
1508 |
line := self listAt:lNr. |
|
1509 |
line isEmptyOrNil ifTrue:[ |
|
1510 |
m disableAll:#(printIt doIt inspectIt browseIt) |
|
1511 |
]. |
|
2459 | 1512 |
]. |
2595 | 1513 |
self isReadOnly ifTrue:[ |
1514 |
m disable:#printIt |
|
1515 |
]. |
|
418 | 1516 |
]. |
1517 |
||
2459 | 1518 |
^ m ? sub. |
430 | 1519 |
|
1501 | 1520 |
"Modified: / 22.4.1998 / 21:49:06 / ca" |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1521 |
"Modified: / 19.11.2001 / 23:12:01 / cg" |
418 | 1522 |
! |
1523 |
||
1524 |
inspectIt |
|
1525 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
1526 |
and start an inspector on the result" |
|
1527 |
||
2981
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1528 |
|shifted| |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1529 |
|
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1530 |
shifted := self sensor shiftDown. |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1531 |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1532 |
^ self |
3272 | 1533 |
do:(self selectionOrTextOfCursorLine) |
2982
9a831ab53acc
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2981
diff
changeset
|
1534 |
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
|
1535 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1536 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 1537 |
! |
1538 |
||
1539 |
printIt |
|
1540 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
1541 |
and insert result of evaluation into my text. |
|
1542 |
If the text is readOnly, do nothing." |
|
1543 |
||
1734 | 1544 |
self isReadOnly ifTrue:[ |
3511 | 1545 |
self beep. |
1546 |
^ self. |
|
1547 |
]. |
|
1548 |
self |
|
1549 |
undoableDo:[ |
|
1550 |
self |
|
1551 |
do:(self selectionOrTextOfCursorLine) |
|
1552 |
withValueDo:[:result | |
|
1553 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
|
1554 |
self insertSelectedStringAtCursor:(result displayString "printString") |
|
1555 |
] |
|
1556 |
] |
|
1557 |
info:'PrintIt' |
|
1558 |
||
1559 |
"Modified: / 08-11-2007 / 11:35:31 / cg" |
|
1560 |
! |
|
418 | 1561 |
|
3511 | 1562 |
replaceIt |
1563 |
"like printIt, but replace the selection with the result, instead of |
|
1564 |
pasting it after the selection." |
|
1565 |
||
1566 |
self isReadOnly ifTrue:[ |
|
1567 |
self beep. |
|
1568 |
^ self |
|
1569 |
]. |
|
1570 |
||
1571 |
self |
|
1572 |
undoableDo:[ |
|
1573 |
self |
|
1574 |
do:(self selectionOrTextOfCursorLine) |
|
1575 |
withValueDo:[:result | |
|
1576 |
self replaceSelectionBy:(result displayString "printString") |
|
1577 |
]. |
|
1578 |
undoSupport actionInfo:'ReplaceIt'. |
|
1579 |
] |
|
1580 |
info:'ReplaceIt' |
|
1581 |
||
1582 |
"Created: / 08-11-2007 / 11:31:54 / cg" |
|
1501 | 1583 |
! |
1584 |
||
1585 |
spyOnIt |
|
1586 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
1587 |
and finally restore cursor; return result of evaluation" |
|
1588 |
||
1589 |
|code| |
|
1590 |
||
3511 | 1591 |
code := 'MessageTally spyDetailOn:[' , self selectionAsString, ']'. |
1501 | 1592 |
self do:code withValueDo:[:result | ] |
1593 |
||
3511 | 1594 |
"Modified: / 22-04-1998 / 22:03:53 / ca" |
1595 |
"Modified: / 08-11-2007 / 11:36:38 / cg" |
|
1501 | 1596 |
! |
1597 |
||
1598 |
timeIt |
|
1599 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
1600 |
and finally restore cursor; return result of evaluation" |
|
1601 |
||
1602 |
|code| |
|
1603 |
||
3272 | 1604 |
code := '|t| t := Time millisecondsToRun:[' , self selectionAsString, ']. |
3141 | 1605 |
|
1606 |
Transcript showCR:''execution time: '' , t printString , '' ms''.'. |
|
1501 | 1607 |
self do:code withValueDo:[:result | ] |
1608 |
||
1609 |
"Modified: / 22.4.1998 / 22:03:51 / ca" |
|
418 | 1610 |
! ! |
1611 |
||
2646 | 1612 |
!Workspace methodsFor:'queries'! |
1613 |
||
1614 |
isWorkspace |
|
1615 |
^ true |
|
1616 |
! ! |
|
1617 |
||
206 | 1618 |
!Workspace class methodsFor:'documentation'! |
1619 |
||
1620 |
version |
|
3728 | 1621 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.190 2008-10-14 08:32:45 cg Exp $' |
858 | 1622 |
! ! |