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