author | Claus Gittinger <cg@exept.de> |
Thu, 31 Mar 2005 14:03:28 +0200 | |
changeset 3141 | 2e8015ff554a |
parent 3129 | c42ad1ea2e9c |
child 3155 | 15d43d2ea850 |
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 |
" |
|
12 |
||
2277 | 13 |
"{ Package: 'stx:libwidg' }" |
14 |
||
0 | 15 |
TextCollector subclass:#Workspace |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
16 |
instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor |
2679 | 17 |
commentStrings autoDefineWorkspaceVariables simulatedSelf |
2980 | 18 |
autoDefineVariables compilerClass' |
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 |
21 |
DefaultWarningForegroundColor WorkspaceVariables DoItHistory' |
|
257 | 22 |
poolDictionaries:'' |
2097 | 23 |
category:'Interface-Smalltalk' |
0 | 24 |
! |
25 |
||
32 | 26 |
!Workspace class methodsFor:'documentation'! |
27 |
||
38 | 28 |
copyright |
29 |
" |
|
30 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 31 |
All Rights Reserved |
38 | 32 |
|
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
! |
|
41 |
||
32 | 42 |
documentation |
43 |
" |
|
44 |
a view for editable text which can evaluate expressions. |
|
38 | 45 |
I.e. its basically a view for editable text, with added |
46 |
'doIt', 'printIt' and 'inspectIt' functions on the popup-menu. |
|
125 | 47 |
|
38 | 48 |
The action to be performed on doIt is defined by a block, |
58 | 49 |
which can be defined by the owner of this view. |
60 | 50 |
(thus you can put a workspace into more complex widgets, and |
51 |
control what should happen on 'doIt'). |
|
58 | 52 |
|
578 | 53 |
A useful default action is automatically defined, which simply |
54 |
evaluates the selection as a smalltalk expression. |
|
55 |
(but, a lisp or prolog workspace would define its own action, |
|
56 |
to call for another compiler/interpreter ...) |
|
32 | 57 |
|
123 | 58 |
|
59 |
Caveat: |
|
418 | 60 |
in this version, Workspace does not yet support doIt in MVC setups. |
61 |
For now, simulate this by setting the doItAction, to notify the |
|
62 |
model manually about the doIt. |
|
123 | 63 |
|
64 |
||
578 | 65 |
[instance variables:] |
32 | 66 |
|
121 | 67 |
doItAction <Block> block to evaluate for doIt |
123 | 68 |
|
121 | 69 |
errorFgColor <Color> fg-Color to be used when highlighting errors |
70 |
||
71 |
errorBgColor <Color> bg-Color to be used when highlighting errors |
|
58 | 72 |
|
578 | 73 |
codeStartPosition private temporary |
121 | 74 |
|
578 | 75 |
|
76 |
[styleSheet values:] |
|
121 | 77 |
|
78 |
codeErrorSelectionForegroundColor fg color to highlight errors |
|
418 | 79 |
(default: selection fg) |
80 |
||
121 | 81 |
codeErrorSelectionBackgroundColor bg color to highlight errors |
418 | 82 |
(default: selection bg) |
578 | 83 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
84 |
[start with:] |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
85 |
Workspace open |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
86 |
|
578 | 87 |
[see also:] |
88 |
Workspace EditTextView |
|
89 |
Parser ByteCodeCompiler |
|
583 | 90 |
|
91 |
[author:] |
|
92 |
Claus Gittinger |
|
32 | 93 |
" |
201 | 94 |
! ! |
95 |
||
96 |
!Workspace class methodsFor:'defaults'! |
|
97 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
98 |
defaultLabel |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
99 |
"my default window label" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
100 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
101 |
^ 'Workspace' |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
102 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
103 |
"Created: / 16.5.1998 / 16:53:37 / cg" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
104 |
! |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
105 |
|
201 | 106 |
updateStyleCache |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
107 |
"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
|
108 |
|
1354 | 109 |
<resource: #style (#'codeErrorSelection.foregroundColor' |
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
110 |
#'codeErrorSelection.backgroundColor' |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
111 |
#'codeView.backgroundColor' )> |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
112 |
|
1354 | 113 |
DefaultErrorForegroundColor := StyleSheet colorAt:'codeErrorSelection.foregroundColor'. |
114 |
DefaultErrorBackgroundColor := StyleSheet colorAt:'codeErrorSelection.backgroundColor'. |
|
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
115 |
DefaultViewBackground := StyleSheet colorAt:'codeView.backgroundColor'. |
32 | 116 |
! ! |
117 |
||
2776 | 118 |
!Workspace class methodsFor:'getting a new Workspace'! |
0 | 119 |
|
32 | 120 |
open |
0 | 121 |
"launch a new workspace" |
122 |
||
418 | 123 |
|scr topView workspace f| |
0 | 124 |
|
418 | 125 |
topView := StandardSystemView |
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
126 |
label:(self classResources string:(self defaultLabel)) |
1901
b3556ff49778
removed minExtent - let topView decide.
Claus Gittinger <cg@exept.de>
parents:
1738
diff
changeset
|
127 |
" minExtent:(100 @ 100)". |
23 | 128 |
|
418 | 129 |
scr := HVScrollableView for:self in:topView. |
130 |
scr origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
131 |
workspace := scr scrolledView. |
|
0 | 132 |
|
418 | 133 |
"/ adjust topViews extent according to my font |
134 |
||
0 | 135 |
f := workspace font. |
136 |
topView extent:((f widthOf:'x') * 40) @ (f height * 10). |
|
7 | 137 |
topView open. |
131 | 138 |
^ workspace |
0 | 139 |
|
58 | 140 |
" |
141 |
Workspace open |
|
142 |
" |
|
418 | 143 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
144 |
"Modified: / 16.5.1998 / 16:53:53 / cg" |
857 | 145 |
! |
146 |
||
147 |
openForRemote:hostName |
|
148 |
"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
|
149 |
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
|
150 |
and the result is shown here. |
857 | 151 |
This requires the RemoteObjects package to be loaded." |
152 |
||
153 |
|server remoteCompiler workspace| |
|
154 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
155 |
RemoteObjectServer isNil ifTrue:[ |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
156 |
self warn:'no remoteObjectServer available'. |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
157 |
^ nil |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
158 |
]. |
857 | 159 |
|
160 |
server := RemoteObjectServer on:hostName. |
|
161 |
remoteCompiler := server get:#Compiler. |
|
162 |
||
163 |
workspace := self open. |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
164 |
workspace topView |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
165 |
label:(self classResources string:'Remote Workspace {%1}' with:hostName). |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
166 |
|
857 | 167 |
workspace doItAction: |
168 |
[:theCode | |
|
169 |
remoteCompiler |
|
170 |
evaluate:theCode |
|
171 |
in:nil |
|
172 |
receiver:nil |
|
173 |
notifying:workspace |
|
174 |
logged:true |
|
175 |
ifFail:nil |
|
176 |
] |
|
177 |
" |
|
178 |
Workspace openForRemote:'andi' |
|
179 |
" |
|
180 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
181 |
"Modified: / 16.5.1998 / 16:57:38 / cg" |
2686 | 182 |
! |
183 |
||
2794 | 184 |
openWith:initialText selected:selectedBoolean |
2686 | 185 |
"launch a new workspace with some initial contents" |
186 |
||
187 |
|workspace| |
|
188 |
||
189 |
workspace := self open. |
|
2794 | 190 |
workspace contents:initialText selected:selectedBoolean. |
2686 | 191 |
^ workspace |
192 |
||
193 |
" |
|
194 |
Workspace openWith:'Transcript showCR:''hello world''' |
|
195 |
" |
|
0 | 196 |
! ! |
197 |
||
2657 | 198 |
!Workspace class methodsFor:'history'! |
199 |
||
200 |
clearDoItHistory |
|
201 |
DoItHistory := nil |
|
202 |
! |
|
203 |
||
204 |
doItHistory |
|
205 |
^ DoItHistory |
|
206 |
! |
|
207 |
||
208 |
doItHistorySize |
|
209 |
"the number of remembered doIts" |
|
210 |
||
211 |
^ 20 |
|
212 |
! |
|
213 |
||
214 |
rememberDoIt:aString |
|
215 |
|string| |
|
216 |
||
217 |
string := aString asString string withoutSeparators. |
|
2726 | 218 |
(string asCollectionOfWords size <= 1) ifTrue:[ |
219 |
((Scanner new scanTokens:string) size <= 1) ifTrue:[ |
|
220 |
"its a variable only" |
|
221 |
^ self |
|
222 |
] |
|
223 |
]. |
|
2657 | 224 |
|
225 |
DoItHistory isNil ifTrue:[ |
|
226 |
DoItHistory := OrderedCollection new. |
|
227 |
]. |
|
228 |
DoItHistory remove:string ifAbsent:nil. |
|
229 |
DoItHistory addFirst:string. |
|
230 |
DoItHistory size > self doItHistorySize ifTrue:[ |
|
231 |
DoItHistory removeLast |
|
232 |
]. |
|
2726 | 233 |
|
234 |
Scanner |
|
2657 | 235 |
! ! |
236 |
||
1523
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
237 |
!Workspace class methodsFor:'queries'! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
238 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
239 |
isVisualStartable |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
240 |
"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
|
241 |
(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
|
242 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
243 |
^ self == Workspace |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
244 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
245 |
"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
|
246 |
"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
|
247 |
! ! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
248 |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
249 |
!Workspace class methodsFor:'workspace variables'! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
250 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
251 |
addWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
252 |
"create a new workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
253 |
|
1933 | 254 |
|holder| |
255 |
||
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
256 |
WorkspaceVariables isNil ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
257 |
WorkspaceVariables := Dictionary new. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
258 |
]. |
2536 | 259 |
holder := WorkspaceVariables at:name ifAbsentPut:[ ValueHolder new ]. |
1933 | 260 |
^ holder |
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
261 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
262 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
263 |
removeAllWorkspaceVariables |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
264 |
"delete all workspace variables" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
265 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
266 |
WorkspaceVariables := nil |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
267 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
268 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
269 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
270 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
271 |
removeWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
272 |
"delete a workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
273 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
274 |
WorkspaceVariables notNil ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
275 |
WorkspaceVariables removeKey:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
276 |
WorkspaceVariables isEmpty ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
277 |
WorkspaceVariables := nil |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
278 |
] |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
279 |
]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
280 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
281 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
282 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
283 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
284 |
workspaceVariableAt:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
285 |
"retrieve a workspace variable (actually, a holder onto it)" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
286 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
287 |
WorkspaceVariables isNil ifTrue:[^ nil]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
288 |
^ WorkspaceVariables at:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
289 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
290 |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
291 |
! |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
292 |
|
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
293 |
workspaceVariables |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
294 |
"retrieve the collection of workspace variables" |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
295 |
|
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
296 |
^ WorkspaceVariables |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
297 |
|
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
298 |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
299 |
! ! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
300 |
|
201 | 301 |
!Workspace methodsFor:'accessing'! |
0 | 302 |
|
2679 | 303 |
autoDefineVariables |
304 |
^ autoDefineVariables |
|
2535 | 305 |
! |
306 |
||
2679 | 307 |
autoDefineVariables:nilOrSymbol |
308 |
autoDefineVariables := nilOrSymbol. |
|
309 |
! |
|
2535 | 310 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
311 |
commentStrings:anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
312 |
"define the comment strings" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
313 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
314 |
commentStrings := anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
315 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
316 |
"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
|
317 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
318 |
|
201 | 319 |
doItAction |
320 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 321 |
|
201 | 322 |
^ doItAction |
0 | 323 |
! |
324 |
||
3007 | 325 |
errorBackgroundColor |
326 |
errorBgColor notNil ifTrue:[ ^ errorBgColor ]. |
|
327 |
DefaultErrorBackgroundColor notNil ifTrue:[ ^ DefaultErrorBackgroundColor ]. |
|
328 |
device hasColors ifTrue:[ ^ Color red ]. |
|
329 |
||
330 |
^ selectionBgColor |
|
331 |
! |
|
332 |
||
333 |
errorForegroundColor |
|
334 |
errorFgColor notNil ifTrue:[ ^ errorFgColor ]. |
|
335 |
DefaultErrorForegroundColor notNil ifTrue:[ ^ DefaultErrorForegroundColor ]. |
|
336 |
^ selectionFgColor |
|
337 |
! |
|
338 |
||
2727 | 339 |
selectAll |
340 |
super selectAll |
|
341 |
! |
|
342 |
||
2601 | 343 |
simulatedSelf:anObject |
344 |
"define what self is in an evaluation" |
|
345 |
||
346 |
simulatedSelf := anObject |
|
3007 | 347 |
! |
348 |
||
349 |
warningBackgroundColor |
|
350 |
DefaultWarningBackgroundColor notNil ifTrue:[ ^ DefaultWarningBackgroundColor ]. |
|
351 |
device hasColors ifTrue:[ ^ Color orange ]. |
|
352 |
||
353 |
^ selectionBgColor |
|
354 |
! |
|
355 |
||
356 |
warningForegroundColor |
|
357 |
DefaultWarningForegroundColor notNil ifTrue:[ ^ DefaultWarningForegroundColor ]. |
|
358 |
^ selectionFgColor |
|
201 | 359 |
! ! |
360 |
||
361 |
!Workspace methodsFor:'compiler interface'! |
|
362 |
||
2303 | 363 |
compilerClass |
2980 | 364 |
^ compilerClass ? Compiler |
365 |
! |
|
366 |
||
367 |
compilerClass:aCompilerClass |
|
368 |
compilerClass := aCompilerClass |
|
2303 | 369 |
! |
370 |
||
201 | 371 |
currentSourceCode |
372 |
"special interface to compiler - called by parser |
|
373 |
to get the updated source code after a corrected error" |
|
374 |
||
375 |
^ self contents |
|
0 | 376 |
! |
377 |
||
201 | 378 |
wantChangeLog |
379 |
"sent by the compiler to ask if a changeLog entry should |
|
380 |
be written. Return true here." |
|
0 | 381 |
|
201 | 382 |
^ true |
0 | 383 |
! ! |
384 |
||
2754 | 385 |
!Workspace methodsFor:'compiler interface-error handling'! |
0 | 386 |
|
201 | 387 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
388 |
"compiler notifies us of a correctable error; |
|
389 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
390 |
this method should return true to the compiler if user wants the error |
|
391 |
to be corrected; false otherwise" |
|
392 |
||
393 |
|action| |
|
394 |
||
395 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
368 | 396 |
action := OptionBox |
397 |
request:aString |
|
2549 | 398 |
label:'Correctable Error' |
2983
910b4d5f7b1b
dont send obsolete message (OptionBox request:..form:..)
Claus Gittinger <cg@exept.de>
parents:
2982
diff
changeset
|
399 |
image:(WarningBox iconBitmap) |
2440 | 400 |
buttonLabels:#('Cancel' 'Declare as...' 'Correct...' 'Continue') |
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
401 |
values:#(#abort #declare #correct #continue) |
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
402 |
default:#continue |
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
403 |
onCancel:#abort. |
201 | 404 |
]. |
405 |
||
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
406 |
action == #declare ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
407 |
^ action |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
408 |
]. |
201 | 409 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
410 |
AbortOperationRequest raise. |
368 | 411 |
^ false |
201 | 412 |
]. |
368 | 413 |
^ action == #correct |
414 |
||
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
415 |
"Modified: / 16.11.2001 / 17:39:26 / cg" |
201 | 416 |
! |
417 |
||
2104 | 418 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
419 |
"compiler notifies us of a correctable selector warning; |
|
420 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
421 |
this method should return true to the compiler if user wants the error |
|
422 |
to be corrected; false otherwise" |
|
423 |
||
424 |
|action| |
|
425 |
||
426 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
427 |
action := OptionBox |
|
428 |
request:aString |
|
429 |
label:'Warning' |
|
2983
910b4d5f7b1b
dont send obsolete message (OptionBox request:..form:..)
Claus Gittinger <cg@exept.de>
parents:
2982
diff
changeset
|
430 |
image:(WarningBox iconBitmap) |
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
431 |
buttonLabels:(resources array:#('Cancel' 'Correct...' 'Generate' 'Continue')) |
2338 | 432 |
values:#(#abort #correct #generate #continue) |
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
433 |
default:#continue |
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
434 |
onCancel:#abort. |
2104 | 435 |
]. |
436 |
||
2338 | 437 |
action == #generate ifTrue:[ |
438 |
^ action |
|
439 |
]. |
|
440 |
||
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
441 |
(action isNil or:[action == #abort]) ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
442 |
AbortOperationRequest raise. |
2104 | 443 |
^ false |
444 |
]. |
|
445 |
^ action == #correct |
|
446 |
||
447 |
"Created: / 19.1.2000 / 16:27:28 / cg" |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
448 |
"Modified: / 16.11.2001 / 17:39:29 / cg" |
2104 | 449 |
! |
450 |
||
201 | 451 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 452 |
"obsolete - no longer invoked" |
453 |
||
454 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
455 |
! |
|
456 |
||
457 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
458 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
|
459 |
and show a Box asking for continue/abort." |
|
460 |
||
461 |
^ self error:aString position:relPos to:relEndPos from:aCompiler asWarning:false |
|
462 |
! |
|
463 |
||
464 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
201 | 465 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
466 |
and show a Box asking for continue/abort." |
|
467 |
||
3007 | 468 |
|answer fg bg| |
201 | 469 |
|
3007 | 470 |
fg := asWarning ifTrue:[ self warningForegroundColor ] ifFalse:[ self errorForegroundColor ]. |
471 |
bg := asWarning ifTrue:[ self warningBackgroundColor ] ifFalse:[ self errorBackgroundColor ]. |
|
201 | 472 |
|
3007 | 473 |
self |
474 |
highlightingErrorPosition:relPos to:relEndPos |
|
475 |
withForeground:fg andBackground:bg |
|
476 |
do:[ |
|
477 |
|box lbl doNotShowAgainHolder l1 y1 y2 l2| |
|
201 | 478 |
|
3007 | 479 |
WarningSignal isHandled ifTrue:[ |
480 |
WarningSignal raiseErrorString:aString. |
|
481 |
^ false |
|
482 |
]. |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
483 |
|
3007 | 484 |
" |
485 |
ask if we should abort or continue |
|
486 |
" |
|
487 |
box := YesNoBox |
|
488 |
title:aString |
|
489 |
yesText:(resources string:'Continue') |
|
490 |
noText:(resources string:'Abort'). |
|
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
491 |
|
3007 | 492 |
lbl := aCompiler isNil ifTrue:['Compiler'] ifFalse:[aCompiler class name]. |
493 |
asWarning ifTrue:[ |
|
494 |
lbl := lbl , ' Warning' |
|
495 |
] ifFalse:[ |
|
496 |
lbl := lbl , ' Error'. |
|
497 |
]. |
|
498 |
box label:lbl. |
|
499 |
box image:(WarningBox iconBitmap). |
|
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
500 |
|
3007 | 501 |
aCompiler class doNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
502 |
doNotShowAgainHolder := false asValue. |
|
503 |
box addCheckBox:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
|
504 |
]. |
|
505 |
||
506 |
answer := box confirm. |
|
507 |
||
508 |
doNotShowAgainHolder value == true ifTrue:[ |
|
509 |
aCompiler class doNotShowCompilerWarningAgainActionQuery actionQuery value |
|
510 |
]. |
|
511 |
||
512 |
box destroy. |
|
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
513 |
]. |
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
514 |
|
201 | 515 |
" |
516 |
do the abort if we have to |
|
517 |
" |
|
518 |
answer ifFalse:[ |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
519 |
AbortOperationRequest raise. |
201 | 520 |
]. |
521 |
^ 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
|
522 |
|
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
523 |
"Created: / 24.11.1995 / 22:56:34 / cg" |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
524 |
"Modified: / 16.11.2001 / 17:39:31 / cg" |
201 | 525 |
! |
526 |
||
2663 | 527 |
highlightingErrorLine:lineNr do:aBlock |
528 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
529 |
||
530 |
|linePosition| |
|
531 |
||
532 |
linePosition := self characterPositionOfLine:lineNr col:1. |
|
533 |
self highlightingErrorPosition:linePosition to:nil do:aBlock |
|
534 |
! |
|
535 |
||
59 | 536 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
537 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 538 |
|
3007 | 539 |
self |
540 |
highlightingErrorPosition:relPos to:relEndPos |
|
541 |
withForeground:(self errorForegroundColor) andBackground:(self errorBackgroundColor) |
|
542 |
do:aBlock |
|
543 |
! |
|
544 |
||
545 |
highlightingErrorPosition:relPos to:relEndPos withForeground:hilightFg andBackground:hilightBg do:aBlock |
|
546 |
"evaluate aBlock while some selection is shown highlighted with colors passed as args." |
|
547 |
||
548 |
|absPosition oldFg oldBg| |
|
0 | 549 |
|
58 | 550 |
" |
551 |
change color of selection & hide cursor |
|
552 |
" |
|
3007 | 553 |
oldFg := selectionFgColor. |
554 |
oldBg := selectionBgColor. |
|
555 |
selectionBgColor := hilightBg. |
|
556 |
selectionFgColor := hilightFg. |
|
58 | 557 |
self hideCursor. |
0 | 558 |
|
58 | 559 |
" |
560 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
561 |
we have to adjust the positions given by the compiler, since they |
|
562 |
are relative to the texts start (the compiler did stream-read the code). |
|
563 |
" |
|
0 | 564 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
565 |
absPosition := codeStartPosition + relPos - 1. |
|
566 |
relEndPos isNil ifTrue:[ |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
567 |
self selectLineWhereCharacterPosition:absPosition |
0 | 568 |
] ifFalse:[ |
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
569 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + relEndPos - 1) |
0 | 570 |
]. |
571 |
self makeSelectionVisible. |
|
572 |
||
155 | 573 |
device flush. |
58 | 574 |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
575 |
aBlock ensure:[ |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
576 |
" |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
577 |
undo selection color change and show cursor again |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
578 |
" |
3007 | 579 |
selectionFgColor := oldFg. |
580 |
selectionBgColor := oldBg. |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
581 |
self showCursor. |
0 | 582 |
]. |
583 |
! |
|
584 |
||
3007 | 585 |
highlightingWarningPosition:relPos to:relEndPos do:aBlock |
586 |
"evaluate aBlock while some selection is shown highlighted with warning colors." |
|
587 |
||
588 |
self |
|
589 |
highlightingErrorPosition:relPos to:relEndPos |
|
590 |
withForeground:(self warningForegroundColor) andBackground:(self warningBackgroundColor) |
|
591 |
do:aBlock |
|
592 |
! |
|
593 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
594 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
595 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
596 |
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
|
597 |
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
|
598 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
599 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
600 |
|action| |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
601 |
|
3007 | 602 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
603 |
action := OptionBox |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
604 |
request:aString |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
605 |
label:'Warning' |
2990
1373f301a694
dont send obsolete message to OptionBox
Claus Gittinger <cg@exept.de>
parents:
2983
diff
changeset
|
606 |
image:(WarningBox iconBitmap) |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
607 |
buttonLabels:#('Cancel' 'Remove Variable(s)' 'Continue') |
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
608 |
values:#(#abort #correct #continue) |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
609 |
default:#continue. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
610 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
611 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
612 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
613 |
AbortOperationRequest raise. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
614 |
^ false |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
615 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
616 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
617 |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
618 |
"Modified: / 16.11.2001 / 17:39:34 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
619 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
620 |
|
116 | 621 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 622 |
"compiler notifies us of a warning - same behavior as error" |
0 | 623 |
|
2277 | 624 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 625 |
! ! |
626 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
627 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
628 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
629 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
630 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
631 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 632 |
in the first col |
633 |
(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
|
634 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
635 |
|eolComment opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
636 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
637 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
638 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
639 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
640 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
641 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
642 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
643 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
644 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
645 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
646 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
647 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
648 |
l isNil ifTrue:[l := '']. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
649 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
650 |
l := eolComment , l |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
651 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
652 |
l := opening , l , closing |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
653 |
]. |
1903
86d3493c6a59
when commenting, do all without change notifications,
Claus Gittinger <cg@exept.de>
parents:
1901
diff
changeset
|
654 |
self at:lineNr basicPut:l |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
655 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
656 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
657 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
658 |
"Modified: / 7.1.1997 / 20:15:06 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
659 |
"Created: / 9.11.1997 / 01:05:35 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
660 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
661 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
662 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
663 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
664 |
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
|
665 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
666 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
667 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
668 |
|
1481 | 669 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3129 | 670 |
selectionStartLine isNil ifTrue:[ ^ self]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
671 |
|
3129 | 672 |
self |
673 |
undoableDo: |
|
674 |
[ |
|
675 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
676 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
|
677 |
] ifFalse:[ |
|
678 |
commentPair := commentStrings at:2. |
|
679 |
opening := commentPair at:1. |
|
680 |
closing := commentPair at:2. |
|
681 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
682 |
|
3129 | 683 |
e := selectionEndCol. |
684 |
||
685 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
686 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
687 |
||
688 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
|
689 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
690 |
toLine:selectionEndLine col:e+closing size. |
|
691 |
] |
|
692 |
] |
|
693 |
info:'comment' |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
694 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
695 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 696 |
"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
|
697 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
698 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
699 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
700 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
701 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 702 |
in the first col. |
703 |
(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
|
704 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
705 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
706 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
707 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
708 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
709 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
710 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
711 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
712 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
713 |
rest := eolComment size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
714 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
715 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
716 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
717 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
718 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
719 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
720 |
l notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
721 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
722 |
(l startsWith:eolComment) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
723 |
l := l copyFrom:rest |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
724 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
725 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
726 |
((l startsWith:opening) |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
727 |
and:[l endsWith:closing]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
728 |
l := l copyFrom:opening size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
729 |
l := l copyWithoutLast:closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
730 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
731 |
]. |
1903
86d3493c6a59
when commenting, do all without change notifications,
Claus Gittinger <cg@exept.de>
parents:
1901
diff
changeset
|
732 |
self at:lineNr basicPut:l |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
733 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
734 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
735 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
736 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
737 |
"Modified: / 7.1.1997 / 20:17:44 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
738 |
"Created: / 9.11.1997 / 01:05:43 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
739 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
740 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
741 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
742 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
743 |
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
|
744 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
745 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
746 |
|e commentPair opening closing sz1 sz2| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
747 |
|
3129 | 748 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
749 |
selectionStartLine isNil ifTrue:[ ^ self]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
750 |
|
3129 | 751 |
self |
752 |
undoableDo: |
|
753 |
[ |
|
754 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
755 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
|
756 |
] ifFalse:[ |
|
757 |
commentPair := commentStrings at:2. |
|
758 |
opening := commentPair at:1. |
|
759 |
closing := commentPair at:2. |
|
760 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
761 |
||
762 |
sz1 := opening size. |
|
763 |
sz2 := closing size. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
764 |
|
3129 | 765 |
((self |
766 |
stringAtLine:selectionStartLine |
|
767 |
from:selectionStartCol |
|
768 |
to:selectionStartCol+sz1 - 1) = opening |
|
769 |
and:[(self |
|
770 |
stringAtLine:selectionEndLine |
|
771 |
from:selectionEndCol - sz2 + 1 |
|
772 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
773 |
|
3129 | 774 |
self deleteCharsAtLine:selectionEndLine fromCol:selectionEndCol-sz2+1 toCol:selectionEndCol. |
775 |
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
|
776 |
|
3129 | 777 |
e := selectionEndCol - sz2. |
778 |
selectionStartLine == selectionEndLine ifTrue:[e := e - sz1]. |
|
779 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
780 |
toLine:selectionEndLine col:e. |
|
781 |
] |
|
782 |
] |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
783 |
] |
3129 | 784 |
info:'uncomment' |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
785 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
786 |
"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
|
787 |
"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
|
788 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
789 |
|
0 | 790 |
!Workspace methodsFor:'events'! |
791 |
||
792 |
keyPress:key x:x y:y |
|
2418
bd16446247c5
lifted keyboardMacro handling to editTextView
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
793 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #BrowseIt)> |
60 | 794 |
|
32 | 795 |
(key == #DoIt) ifTrue:[^ self doIt]. |
23 | 796 |
(key == #InspectIt) ifTrue:[^ self inspectIt]. |
418 | 797 |
(key == #PrintIt) ifTrue:[^ self printIt]. |
2307 | 798 |
(key == #BrowseIt) ifTrue:[^ self browseIt]. |
38 | 799 |
|
0 | 800 |
super keyPress:key x:x y:y |
801 |
! ! |
|
201 | 802 |
|
2143 | 803 |
!Workspace methodsFor:'executing'! |
201 | 804 |
|
1501 | 805 |
do:code withValueDo:aBlock |
418 | 806 |
"helper for doIt, printIt and inspectIt. |
807 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
808 |
aBlock with the value. |
|
809 |
Most work is in preparing for proper cleanup in case of abort |
|
810 |
or other exception while the evaluation is performed. |
|
811 |
(restore cursor, selectionColors etc.)" |
|
201 | 812 |
|
1501 | 813 |
|selLine selCol endLine endCol cLine cCol cleanUp| |
201 | 814 |
|
815 |
code notNil ifTrue:[ |
|
2409 | 816 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
2408 | 817 |
|
257 | 818 |
codeStartPosition := self characterPositionOfSelection. |
201 | 819 |
|
257 | 820 |
" |
821 |
remember selection for later - if there is an error, |
|
822 |
the notification method will highlight it. |
|
823 |
thus destroying the current selection |
|
824 |
" |
|
825 |
selLine := selectionStartLine. |
|
826 |
selCol := selectionStartCol. |
|
827 |
endLine := selectionEndLine. |
|
828 |
endCol := selectionEndCol. |
|
829 |
cCol := cursorCol. |
|
830 |
cLine := cursorLine. |
|
201 | 831 |
|
257 | 832 |
" |
833 |
cleanup: restore previous selection and cursor positions |
|
834 |
" |
|
835 |
cleanUp := [ |
|
836 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
837 |
cLine notNil ifTrue:[ |
|
838 |
self cursorLine:cLine col:cCol |
|
839 |
]. |
|
840 |
]. |
|
201 | 841 |
|
257 | 842 |
" |
843 |
perform the action. |
|
844 |
Be careful to release the reference to the value; |
|
845 |
otherwise, we could keep lots of garbage from being freed |
|
846 |
until the view gets closed |
|
847 |
" |
|
848 |
self topView withExecuteCursorDo:[ |
|
849 |
[ |
|
3008 | 850 |
AbortOperationRequest handle:[:ex | |
257 | 851 |
ex return |
852 |
] do:[ |
|
929 | 853 |
|value| |
854 |
||
257 | 855 |
doItAction notNil ifTrue:[ |
929 | 856 |
value := doItAction value:(code asString). |
257 | 857 |
cleanUp value. cleanUp := nil. |
858 |
aBlock value:value. |
|
2726 | 859 |
value := nil. |
2657 | 860 |
self class rememberDoIt:code. |
257 | 861 |
] |
862 |
] |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
863 |
] ensure:[ |
929 | 864 |
cleanUp notNil ifTrue:[ |
865 |
cleanUp value. cleanUp := nil |
|
866 |
]. |
|
257 | 867 |
] |
868 |
]. |
|
201 | 869 |
] |
257 | 870 |
|
1501 | 871 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
872 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
2409 | 873 |
"Modified: / 26.9.2001 / 17:32:59 / cg" |
201 | 874 |
! ! |
875 |
||
2751 | 876 |
!Workspace methodsFor:'initialization & release'! |
201 | 877 |
|
2733 | 878 |
doItAction:aOneArgBlock |
879 |
"define the action to be performed when 'doIt' is selected. |
|
880 |
The block will be evaluated, passing the selection as a String argument. |
|
881 |
A default doItAction is set for you in the initialize method." |
|
882 |
||
883 |
doItAction := aOneArgBlock |
|
884 |
||
885 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
886 |
! |
|
887 |
||
888 |
executeDoIt:theCode |
|
889 |
^ self compilerClass |
|
890 |
evaluate:theCode |
|
891 |
in:nil |
|
892 |
receiver:simulatedSelf |
|
893 |
notifying:self |
|
894 |
logged:true |
|
895 |
ifFail:nil |
|
896 |
! |
|
897 |
||
201 | 898 |
initStyle |
966 | 899 |
"setup viewStyle specifics" |
900 |
||
201 | 901 |
super initStyle. |
902 |
||
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
903 |
DefaultViewBackground notNil ifTrue:[ |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
904 |
viewBackground := DefaultViewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
905 |
self backgroundColor:viewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
906 |
]. |
201 | 907 |
! |
908 |
||
909 |
initialize |
|
910 |
super initialize. |
|
911 |
||
2775 | 912 |
scrollWhenUpdating := #beginOfText. |
201 | 913 |
showMatchingParenthesis := true. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
914 |
commentStrings := #( |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
915 |
'"/' |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
916 |
('"' '"') |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
917 |
). |
201 | 918 |
|
919 |
self initializeDoITAction. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
920 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
921 |
"Modified: / 9.11.1997 / 01:10:18 / cg" |
201 | 922 |
! |
923 |
||
924 |
initializeDoITAction |
|
925 |
"set up the block to be evaluated for doIts. |
|
926 |
This is done here in a separate method to allow easier |
|
927 |
redefinition in subclasses" |
|
928 |
||
2733 | 929 |
doItAction := [:theCode | self executeDoIt:theCode]. |
201 | 930 |
! ! |
931 |
||
418 | 932 |
!Workspace methodsFor:'menu & menu actions'! |
933 |
||
2285 | 934 |
browseClass |
935 |
"user selected 'browseClass' from menu; evaluate the code |
|
936 |
and open a browser on the resulting class (if it evaluates to one)" |
|
937 |
||
938 |
^ self |
|
939 |
do:(self selection) |
|
940 |
withValueDo:[:result | result isBehavior ifTrue:[ |
|
2410 | 941 |
result browserClass openInClass:result selector:nil |
2285 | 942 |
] ifFalse:[ |
943 |
self warn:'Selection does not evaluate to a class' |
|
944 |
] |
|
945 |
]. |
|
946 |
||
2410 | 947 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 948 |
! |
949 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
950 |
browseImplementorsOfIt |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
951 |
"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
|
952 |
|
2714 | 953 |
|selectedText selector browserClass| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
954 |
|
2714 | 955 |
selectedText := self selectionAsString. |
956 |
selectedText size > 0 ifTrue:[ |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
957 |
self windowGroup withWaitCursorDo:[ |
2714 | 958 |
selector := Parser selectorInExpression:selectedText. |
959 |
||
960 |
browserClass := UserPreferences current systemBrowserClass. |
|
961 |
||
962 |
(selector notNil and:[selector ~~ selectedText]) ifTrue:[ |
|
963 |
browserClass browseImplementorsOfAny:(Set with:selector with:selectedText) |
|
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
964 |
] ifFalse:[ |
2714 | 965 |
browserClass browseImplementorsOf:(selector ? selectedText) |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
966 |
] |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
967 |
] |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
968 |
]. |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
969 |
|
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
970 |
"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
|
971 |
"Modified: / 19.11.2001 / 22:15:17 / cg" |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
972 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
973 |
|
2307 | 974 |
browseIt |
975 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
2713 | 976 |
or the class of the resulting object (if it does not evaluate to a class). |
977 |
||
978 |
Added feature: if selection is of the form class >> selector, immediately switch to that selector." |
|
979 |
||
980 |
|codeToEvaluate idx selector| |
|
981 |
||
982 |
codeToEvaluate := self selection asString withoutSeparators. |
|
983 |
idx := codeToEvaluate indexOfSubCollection:'>>'. |
|
984 |
idx ~~ 0 ifTrue:[ |
|
2717 | 985 |
selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string. |
2713 | 986 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
987 |
]. |
|
2307 | 988 |
|
989 |
^ self |
|
2713 | 990 |
do:codeToEvaluate |
2307 | 991 |
withValueDo:[:result | result isBehavior ifTrue:[ |
2713 | 992 |
result browserClass openInClass:result selector:selector |
2307 | 993 |
] ifFalse:[ |
2410 | 994 |
result class browserClass openInClass:(result class) selector:nil |
2307 | 995 |
] |
996 |
]. |
|
2410 | 997 |
|
998 |
"Modified: / 26.9.2001 / 17:37:50 / cg" |
|
2307 | 999 |
! |
1000 |
||
2285 | 1001 |
browseItsClass |
1002 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
1003 |
and open a browser on the results class" |
|
1004 |
||
1005 |
^ self |
|
1006 |
do:(self selection) |
|
2410 | 1007 |
withValueDo:[:result | |
1008 |
result class browserClass openInClass:result class selector:nil |
|
1009 |
] |
|
2285 | 1010 |
|
2410 | 1011 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 1012 |
! |
1013 |
||
2454 | 1014 |
browseReferencesToIt |
1015 |
"open a browser on all references to the selected global" |
|
1016 |
||
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1017 |
|sel| |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1018 |
|
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1019 |
sel := self selectionAsString. |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1020 |
sel size > 0 ifTrue:[ |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1021 |
self windowGroup withWaitCursorDo:[ |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1022 |
(UserPreferences current systemBrowserClass) |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1023 |
browseReferendsOf:sel |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1024 |
]. |
2454 | 1025 |
]. |
1026 |
||
1027 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
1028 |
"Modified: / 5.11.2001 / 17:32:38 / cg" |
|
1029 |
! |
|
1030 |
||
2462 | 1031 |
browseSendersOfIt |
1032 |
"open a browser on the senders of the selected text" |
|
1033 |
||
2715 | 1034 |
|selectedText selector| |
2462 | 1035 |
|
2715 | 1036 |
selectedText := self selectionAsString. |
1037 |
selectedText size > 0 ifTrue:[ |
|
2462 | 1038 |
self windowGroup withWaitCursorDo:[ |
2715 | 1039 |
selector := Parser selectorInExpression:selectedText. |
2462 | 1040 |
(UserPreferences current systemBrowserClass) |
2715 | 1041 |
browseAllCallsOn:(selector ? selectedText) |
2462 | 1042 |
] |
1043 |
]. |
|
1044 |
||
1045 |
"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
|
1046 |
"Modified: / 19.11.2001 / 22:15:27 / cg" |
2462 | 1047 |
! |
1048 |
||
418 | 1049 |
doIt |
1050 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
1051 |
and finally restore cursor; return result of evaluation" |
|
1052 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1053 |
^ self |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1054 |
do:(self selection) |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1055 |
withValueDo:[:result | ] |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1056 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1057 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 1058 |
! |
1059 |
||
1060 |
editMenu |
|
1107 | 1061 |
"return my popUpMenu; thats the superclasses menu |
1062 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
|
1063 |
||
2459 | 1064 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
1065 |
#CommentSelection #UncommentSelection |
|
2573
52c995a1ea78
accelerators for browseIt and implementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
2571
diff
changeset
|
1066 |
#BrowseIt #ImplementorsOfIt |
2459 | 1067 |
)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
1068 |
<resource: #programMenu> |
489 | 1069 |
|
2867 | 1070 |
|m sub subsub idx sensor s s2| |
418 | 1071 |
|
1072 |
m := super editMenu. |
|
2459 | 1073 |
((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[ |
1074 |
sub := m. |
|
1075 |
m := nil. |
|
1076 |
] ifFalse:[ |
|
1077 |
sub := m subMenuAt:#others. |
|
1078 |
]. |
|
418 | 1079 |
|
2459 | 1080 |
sub notNil ifTrue:[ |
2867 | 1081 |
|
2459 | 1082 |
" |
2867 | 1083 |
workspaces support #browse, implementors etc. add them after paste. |
2459 | 1084 |
" |
2867 | 1085 |
sub |
1086 |
addItemList:#( |
|
1087 |
('-' ) |
|
1088 |
('Browse' browseIt BrowseIt ) |
|
1089 |
('Senders of It' browseSendersOfIt ) |
|
1090 |
('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
|
1091 |
('References to It' browseReferencesToIt ) |
|
1092 |
('-' ) |
|
1093 |
('TimeIt' timeIt ) |
|
1094 |
('SpyOnIt' spyOnIt )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1095 |
resources:resources |
2459 | 1096 |
after:#gotoLine. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1097 |
|
2867 | 1098 |
subsub := sub subMenuAt:#tools. |
1099 |
subsub notNil ifTrue:[ |
|
1100 |
subsub |
|
1101 |
addItemList:#( |
|
1102 |
('-' ) |
|
1103 |
('Comment' commentSelection CommentSelection ) |
|
1104 |
('Uncomment' uncommentSelection UncommentSelection )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1105 |
resources:resources |
2867 | 1106 |
after:#'indent'. |
1107 |
]. |
|
1108 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1109 |
self hasSelection ifFalse:[ |
2461 | 1110 |
sub disableAll:#(browseIt browseImplementorsOfIt browseSendersOfIt browseReferencesToIt timeIt spyOnIt |
1111 |
commentSelection uncommentSelection ) |
|
2454 | 1112 |
] ifTrue:[ |
1113 |
s := self selectionAsString. |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1114 |
s2 := Parser selectorInExpression:s. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1115 |
s2 notNil ifTrue:[ |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1116 |
s2 := s2 asSymbolIfInterned. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1117 |
]. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1118 |
s notNil ifTrue:[ |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1119 |
s := s asSymbolIfInterned. |
2454 | 1120 |
]. |
2487
47e0a1faf544
disabling of impl/senders menu
Claus Gittinger <cg@exept.de>
parents:
2485
diff
changeset
|
1121 |
(s2 isNil and:[s isNil]) ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1122 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1123 |
]. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1124 |
(s isNil |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1125 |
or:[(Smalltalk includesKey:s) not]) |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1126 |
ifTrue:[ |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1127 |
sub disable:#browseReferencesToIt. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1128 |
]. |
2595 | 1129 |
self isReadOnly ifTrue:[ |
2641 | 1130 |
sub disableAll:#(commentSelection uncommentSelection) |
2595 | 1131 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1132 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1133 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1134 |
|
2459 | 1135 |
m notNil ifTrue:[ |
1136 |
" |
|
1137 |
workspaces support #doIt, #printIt and #inspectIt |
|
1138 |
add them after paste. |
|
1139 |
" |
|
1140 |
idx := m indexOf:#paste. |
|
1141 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
1142 |
idx ~~ 0 ifTrue:[ |
|
2867 | 1143 |
m |
1144 |
addItemList:#( |
|
1145 |
('-' ) |
|
1146 |
('DoIt' doIt DoIt ) |
|
1147 |
('PrintIt' printIt PrintIt ) |
|
1148 |
('InspectIt' inspectIt InspectIt)) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1149 |
resources:resources |
2459 | 1150 |
after:idx. |
1151 |
||
1152 |
]. |
|
1153 |
||
1154 |
self hasSelection ifFalse:[ |
|
1155 |
m disableAll:#(printIt doIt inspectIt) |
|
1156 |
]. |
|
2595 | 1157 |
self isReadOnly ifTrue:[ |
1158 |
m disable:#printIt |
|
1159 |
]. |
|
418 | 1160 |
]. |
1161 |
||
2459 | 1162 |
^ m ? sub. |
430 | 1163 |
|
1501 | 1164 |
"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
|
1165 |
"Modified: / 19.11.2001 / 23:12:01 / cg" |
418 | 1166 |
! |
1167 |
||
1168 |
inspectIt |
|
1169 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
1170 |
and start an inspector on the result" |
|
1171 |
||
2981
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1172 |
|shifted| |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1173 |
|
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1174 |
shifted := self sensor shiftDown. |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1175 |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1176 |
^ self |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1177 |
do:(self selection) |
2982
9a831ab53acc
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2981
diff
changeset
|
1178 |
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
|
1179 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1180 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 1181 |
! |
1182 |
||
1183 |
printIt |
|
1184 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
1185 |
and insert result of evaluation into my text. |
|
1186 |
If the text is readOnly, do nothing." |
|
1187 |
||
1734 | 1188 |
self isReadOnly ifTrue:[ |
693 | 1189 |
self beep |
418 | 1190 |
] ifFalse:[ |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1191 |
self |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1192 |
do:(self selection) |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1193 |
withValueDo:[:result | |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1194 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1195 |
self insertSelectedStringAtCursor:(result displayString "printString") |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1196 |
] |
418 | 1197 |
] |
1198 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1199 |
"Modified: / 16.5.1998 / 16:44:44 / cg" |
1501 | 1200 |
! |
1201 |
||
1202 |
spyOnIt |
|
1203 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
1204 |
and finally restore cursor; return result of evaluation" |
|
1205 |
||
1206 |
|code| |
|
1207 |
||
1208 |
code := 'MessageTally spyOn:[' , self selection asString string, ']'. |
|
1209 |
self do:code withValueDo:[:result | ] |
|
1210 |
||
1211 |
"Modified: / 22.4.1998 / 22:03:53 / ca" |
|
1212 |
! |
|
1213 |
||
1214 |
timeIt |
|
1215 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
1216 |
and finally restore cursor; return result of evaluation" |
|
1217 |
||
1218 |
|code| |
|
1219 |
||
1220 |
code := '|t| t := Time millisecondsToRun:[' , self selection asString string, ']. |
|
3141 | 1221 |
|
1222 |
Transcript showCR:''execution time: '' , t printString , '' ms''.'. |
|
1501 | 1223 |
self do:code withValueDo:[:result | ] |
1224 |
||
1225 |
"Modified: / 22.4.1998 / 22:03:51 / ca" |
|
418 | 1226 |
! ! |
1227 |
||
2646 | 1228 |
!Workspace methodsFor:'queries'! |
1229 |
||
1230 |
isWorkspace |
|
1231 |
^ true |
|
1232 |
! ! |
|
1233 |
||
206 | 1234 |
!Workspace class methodsFor:'documentation'! |
1235 |
||
1236 |
version |
|
3141 | 1237 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.148 2005-03-31 12:03:28 cg Exp $' |
858 | 1238 |
! ! |