author | Claus Gittinger <cg@exept.de> |
Wed, 09 Aug 2006 14:39:39 +0200 | |
changeset 3325 | b7e01a88b167 |
parent 3319 | da288f73ea71 |
child 3383 | 41470ff2567d |
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 |
||
3325 | 259 |
holder := self 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 |
|
3157 | 263 |
anyWorkspaceVariableIsDefined |
264 |
^ WorkspaceVariables notEmptyOrNil |
|
265 |
||
266 |
"Created: / 20-04-2005 / 11:57:53 / cg" |
|
267 |
! |
|
268 |
||
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
269 |
removeAllWorkspaceVariables |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
270 |
"delete all workspace variables" |
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 |
WorkspaceVariables := nil |
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 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
275 |
! |
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 |
removeWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
278 |
"delete a workspace variable" |
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 |
WorkspaceVariables notNil ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
281 |
WorkspaceVariables removeKey:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
282 |
WorkspaceVariables isEmpty ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
283 |
WorkspaceVariables := nil |
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 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
288 |
! |
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 |
workspaceVariableAt:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
291 |
"retrieve a workspace variable (actually, a holder onto it)" |
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 |
WorkspaceVariables isNil ifTrue:[^ nil]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
294 |
^ WorkspaceVariables at:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
295 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
296 |
|
1932
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 |
|
3157 | 299 |
workspaceVariableNames |
300 |
"retrieve the collection of workspace variable names" |
|
301 |
||
302 |
WorkspaceVariables isNil ifTrue:[^ #()]. |
|
303 |
^ WorkspaceVariables keys |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
304 |
|
3157 | 305 |
"Created: / 20-04-2005 / 11:42:45 / cg" |
306 |
! |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
307 |
|
3157 | 308 |
workspaceVariables |
309 |
"retrieve the collection of workspace variables. |
|
310 |
That is a dictionary associating names to values." |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
311 |
|
3325 | 312 |
WorkspaceVariables isNil ifTrue:[ |
313 |
WorkspaceVariables := Dictionary new. |
|
314 |
]. |
|
315 |
^ WorkspaceVariables |
|
3157 | 316 |
|
317 |
"Modified: / 20-04-2005 / 11:43:14 / cg" |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
318 |
! ! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
319 |
|
201 | 320 |
!Workspace methodsFor:'accessing'! |
0 | 321 |
|
2679 | 322 |
autoDefineVariables |
323 |
^ autoDefineVariables |
|
2535 | 324 |
! |
325 |
||
2679 | 326 |
autoDefineVariables:nilOrSymbol |
327 |
autoDefineVariables := nilOrSymbol. |
|
328 |
! |
|
2535 | 329 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
330 |
commentStrings:anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
331 |
"define the comment strings" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
332 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
333 |
commentStrings := anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
334 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
335 |
"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
|
336 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
337 |
|
201 | 338 |
doItAction |
339 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 340 |
|
201 | 341 |
^ doItAction |
0 | 342 |
! |
343 |
||
3007 | 344 |
errorBackgroundColor |
345 |
errorBgColor notNil ifTrue:[ ^ errorBgColor ]. |
|
346 |
DefaultErrorBackgroundColor notNil ifTrue:[ ^ DefaultErrorBackgroundColor ]. |
|
347 |
device hasColors ifTrue:[ ^ Color red ]. |
|
348 |
||
349 |
^ selectionBgColor |
|
350 |
! |
|
351 |
||
352 |
errorForegroundColor |
|
353 |
errorFgColor notNil ifTrue:[ ^ errorFgColor ]. |
|
354 |
DefaultErrorForegroundColor notNil ifTrue:[ ^ DefaultErrorForegroundColor ]. |
|
355 |
^ selectionFgColor |
|
356 |
! |
|
357 |
||
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
358 |
hasSelectionOrTextInCursorLine |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
359 |
^ (self selectionOrTextOfCursorLine:false) notNil |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
360 |
! |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
361 |
|
2727 | 362 |
selectAll |
363 |
super selectAll |
|
364 |
! |
|
365 |
||
3272 | 366 |
selectionOrTextOfCursorLine |
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
367 |
^ self selectionOrTextOfCursorLine:true |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
368 |
! |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
369 |
|
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
370 |
selectionOrTextOfCursorLine:doSelect |
3272 | 371 |
|sel lNr line| |
372 |
||
373 |
sel := self selectionAsString. |
|
374 |
sel notNil ifTrue:[^ sel]. |
|
375 |
||
376 |
lNr := self cursorLine. |
|
377 |
line := self listAt:lNr. |
|
378 |
line notEmptyOrNil ifTrue:[ |
|
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
379 |
doSelect ifTrue:[ |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
380 |
self selectLine:lNr. |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
381 |
]. |
3272 | 382 |
^ line |
383 |
]. |
|
384 |
||
385 |
^ nil |
|
386 |
! |
|
387 |
||
2601 | 388 |
simulatedSelf:anObject |
389 |
"define what self is in an evaluation" |
|
390 |
||
391 |
simulatedSelf := anObject |
|
3007 | 392 |
! |
393 |
||
394 |
warningBackgroundColor |
|
395 |
DefaultWarningBackgroundColor notNil ifTrue:[ ^ DefaultWarningBackgroundColor ]. |
|
396 |
device hasColors ifTrue:[ ^ Color orange ]. |
|
397 |
||
398 |
^ selectionBgColor |
|
399 |
! |
|
400 |
||
401 |
warningForegroundColor |
|
402 |
DefaultWarningForegroundColor notNil ifTrue:[ ^ DefaultWarningForegroundColor ]. |
|
403 |
^ selectionFgColor |
|
201 | 404 |
! ! |
405 |
||
406 |
!Workspace methodsFor:'compiler interface'! |
|
407 |
||
2303 | 408 |
compilerClass |
2980 | 409 |
^ compilerClass ? Compiler |
410 |
! |
|
411 |
||
412 |
compilerClass:aCompilerClass |
|
413 |
compilerClass := aCompilerClass |
|
2303 | 414 |
! |
415 |
||
201 | 416 |
currentSourceCode |
417 |
"special interface to compiler - called by parser |
|
418 |
to get the updated source code after a corrected error" |
|
419 |
||
420 |
^ self contents |
|
0 | 421 |
! |
422 |
||
201 | 423 |
wantChangeLog |
424 |
"sent by the compiler to ask if a changeLog entry should |
|
425 |
be written. Return true here." |
|
0 | 426 |
|
201 | 427 |
^ true |
0 | 428 |
! ! |
429 |
||
2754 | 430 |
!Workspace methodsFor:'compiler interface-error handling'! |
0 | 431 |
|
201 | 432 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
433 |
"compiler notifies us of a correctable error; |
|
434 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
435 |
this method should return true to the compiler if user wants the error |
|
436 |
to be corrected; false otherwise" |
|
437 |
||
438 |
|action| |
|
439 |
||
440 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
368 | 441 |
action := OptionBox |
442 |
request:aString |
|
2549 | 443 |
label:'Correctable Error' |
2983
910b4d5f7b1b
dont send obsolete message (OptionBox request:..form:..)
Claus Gittinger <cg@exept.de>
parents:
2982
diff
changeset
|
444 |
image:(WarningBox iconBitmap) |
2440 | 445 |
buttonLabels:#('Cancel' 'Declare as...' 'Correct...' 'Continue') |
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
446 |
values:#(#abort #declare #correct #continue) |
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
447 |
default:#continue |
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
448 |
onCancel:#abort. |
201 | 449 |
]. |
450 |
||
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
451 |
action == #declare ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
452 |
^ action |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
453 |
]. |
201 | 454 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
455 |
AbortOperationRequest raise. |
368 | 456 |
^ false |
201 | 457 |
]. |
368 | 458 |
^ action == #correct |
459 |
||
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
460 |
"Modified: / 16.11.2001 / 17:39:26 / cg" |
201 | 461 |
! |
462 |
||
2104 | 463 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
464 |
"compiler notifies us of a correctable selector warning; |
|
465 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
466 |
this method should return true to the compiler if user wants the error |
|
467 |
to be corrected; false otherwise" |
|
468 |
||
469 |
|action| |
|
470 |
||
3261 | 471 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
2104 | 472 |
action := OptionBox |
473 |
request:aString |
|
474 |
label:'Warning' |
|
2983
910b4d5f7b1b
dont send obsolete message (OptionBox request:..form:..)
Claus Gittinger <cg@exept.de>
parents:
2982
diff
changeset
|
475 |
image:(WarningBox iconBitmap) |
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
476 |
buttonLabels:(resources array:#('Cancel' 'Correct...' 'Generate' 'Continue')) |
2338 | 477 |
values:#(#abort #correct #generate #continue) |
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
478 |
default:#continue |
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
479 |
onCancel:#abort. |
2104 | 480 |
]. |
481 |
||
2338 | 482 |
action == #generate ifTrue:[ |
483 |
^ action |
|
484 |
]. |
|
485 |
||
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
486 |
(action isNil or:[action == #abort]) ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
487 |
AbortOperationRequest raise. |
2104 | 488 |
^ false |
489 |
]. |
|
490 |
^ action == #correct |
|
491 |
||
492 |
"Created: / 19.1.2000 / 16:27:28 / cg" |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
493 |
"Modified: / 16.11.2001 / 17:39:29 / cg" |
2104 | 494 |
! |
495 |
||
201 | 496 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 497 |
"obsolete - no longer invoked" |
498 |
||
499 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
500 |
! |
|
501 |
||
502 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
503 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
|
504 |
and show a Box asking for continue/abort." |
|
505 |
||
506 |
^ self error:aString position:relPos to:relEndPos from:aCompiler asWarning:false |
|
507 |
! |
|
508 |
||
509 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
201 | 510 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
511 |
and show a Box asking for continue/abort." |
|
512 |
||
3007 | 513 |
|answer fg bg| |
201 | 514 |
|
3007 | 515 |
fg := asWarning ifTrue:[ self warningForegroundColor ] ifFalse:[ self errorForegroundColor ]. |
516 |
bg := asWarning ifTrue:[ self warningBackgroundColor ] ifFalse:[ self errorBackgroundColor ]. |
|
201 | 517 |
|
3007 | 518 |
self |
519 |
highlightingErrorPosition:relPos to:relEndPos |
|
520 |
withForeground:fg andBackground:bg |
|
521 |
do:[ |
|
522 |
|box lbl doNotShowAgainHolder l1 y1 y2 l2| |
|
201 | 523 |
|
3007 | 524 |
WarningSignal isHandled ifTrue:[ |
525 |
WarningSignal raiseErrorString:aString. |
|
526 |
^ false |
|
527 |
]. |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
528 |
|
3007 | 529 |
" |
530 |
ask if we should abort or continue |
|
531 |
" |
|
532 |
box := YesNoBox |
|
533 |
title:aString |
|
534 |
yesText:(resources string:'Continue') |
|
535 |
noText:(resources string:'Abort'). |
|
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
536 |
|
3007 | 537 |
lbl := aCompiler isNil ifTrue:['Compiler'] ifFalse:[aCompiler class name]. |
538 |
asWarning ifTrue:[ |
|
539 |
lbl := lbl , ' Warning' |
|
540 |
] ifFalse:[ |
|
541 |
lbl := lbl , ' Error'. |
|
542 |
]. |
|
543 |
box label:lbl. |
|
544 |
box image:(WarningBox iconBitmap). |
|
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
545 |
|
3007 | 546 |
aCompiler class doNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
547 |
doNotShowAgainHolder := false asValue. |
|
548 |
box addCheckBox:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
|
549 |
]. |
|
550 |
||
551 |
answer := box confirm. |
|
552 |
||
553 |
doNotShowAgainHolder value == true ifTrue:[ |
|
554 |
aCompiler class doNotShowCompilerWarningAgainActionQuery actionQuery value |
|
555 |
]. |
|
556 |
||
557 |
box destroy. |
|
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
558 |
]. |
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
559 |
|
201 | 560 |
" |
561 |
do the abort if we have to |
|
562 |
" |
|
563 |
answer ifFalse:[ |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
564 |
AbortOperationRequest raise. |
201 | 565 |
]. |
566 |
^ 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
|
567 |
|
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
568 |
"Created: / 24.11.1995 / 22:56:34 / cg" |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
569 |
"Modified: / 16.11.2001 / 17:39:31 / cg" |
201 | 570 |
! |
571 |
||
2663 | 572 |
highlightingErrorLine:lineNr do:aBlock |
573 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
574 |
||
575 |
|linePosition| |
|
576 |
||
577 |
linePosition := self characterPositionOfLine:lineNr col:1. |
|
578 |
self highlightingErrorPosition:linePosition to:nil do:aBlock |
|
579 |
! |
|
580 |
||
59 | 581 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
582 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 583 |
|
3007 | 584 |
self |
585 |
highlightingErrorPosition:relPos to:relEndPos |
|
586 |
withForeground:(self errorForegroundColor) andBackground:(self errorBackgroundColor) |
|
587 |
do:aBlock |
|
588 |
! |
|
589 |
||
590 |
highlightingErrorPosition:relPos to:relEndPos withForeground:hilightFg andBackground:hilightBg do:aBlock |
|
591 |
"evaluate aBlock while some selection is shown highlighted with colors passed as args." |
|
592 |
||
593 |
|absPosition oldFg oldBg| |
|
0 | 594 |
|
58 | 595 |
" |
596 |
change color of selection & hide cursor |
|
597 |
" |
|
3007 | 598 |
oldFg := selectionFgColor. |
599 |
oldBg := selectionBgColor. |
|
600 |
selectionBgColor := hilightBg. |
|
601 |
selectionFgColor := hilightFg. |
|
58 | 602 |
self hideCursor. |
0 | 603 |
|
58 | 604 |
" |
605 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
606 |
we have to adjust the positions given by the compiler, since they |
|
607 |
are relative to the texts start (the compiler did stream-read the code). |
|
608 |
" |
|
0 | 609 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
610 |
absPosition := codeStartPosition + relPos - 1. |
|
611 |
relEndPos isNil ifTrue:[ |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
612 |
self selectLineWhereCharacterPosition:absPosition |
0 | 613 |
] ifFalse:[ |
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
614 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + relEndPos - 1) |
0 | 615 |
]. |
616 |
self makeSelectionVisible. |
|
617 |
||
155 | 618 |
device flush. |
58 | 619 |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
620 |
aBlock ensure:[ |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
621 |
" |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
622 |
undo selection color change and show cursor again |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
623 |
" |
3007 | 624 |
selectionFgColor := oldFg. |
625 |
selectionBgColor := oldBg. |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
626 |
self showCursor. |
0 | 627 |
]. |
628 |
! |
|
629 |
||
3007 | 630 |
highlightingWarningPosition:relPos to:relEndPos do:aBlock |
631 |
"evaluate aBlock while some selection is shown highlighted with warning colors." |
|
632 |
||
633 |
self |
|
634 |
highlightingErrorPosition:relPos to:relEndPos |
|
635 |
withForeground:(self warningForegroundColor) andBackground:(self warningBackgroundColor) |
|
636 |
do:aBlock |
|
637 |
! |
|
638 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
639 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
640 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
641 |
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
|
642 |
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
|
643 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
644 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
645 |
|action| |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
646 |
|
3007 | 647 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
648 |
action := OptionBox |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
649 |
request:aString |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
650 |
label:'Warning' |
2990
1373f301a694
dont send obsolete message to OptionBox
Claus Gittinger <cg@exept.de>
parents:
2983
diff
changeset
|
651 |
image:(WarningBox iconBitmap) |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
652 |
buttonLabels:#('Cancel' 'Remove Variable(s)' 'Continue') |
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
653 |
values:#(#abort #correct #continue) |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
654 |
default:#continue. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
655 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
656 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
657 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
658 |
AbortOperationRequest raise. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
659 |
^ false |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
660 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
661 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
662 |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
663 |
"Modified: / 16.11.2001 / 17:39:34 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
664 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
665 |
|
116 | 666 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 667 |
"compiler notifies us of a warning - same behavior as error" |
0 | 668 |
|
2277 | 669 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 670 |
! ! |
671 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
672 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
673 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
674 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
675 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
676 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 677 |
in the first col |
678 |
(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
|
679 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
680 |
|eolComment opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
681 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
682 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
683 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
684 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
685 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
686 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
687 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
688 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
689 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
690 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
691 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
692 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
693 |
l isNil ifTrue:[l := '']. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
694 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
695 |
l := eolComment , l |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
696 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
697 |
l := opening , l , closing |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
698 |
]. |
1903
86d3493c6a59
when commenting, do all without change notifications,
Claus Gittinger <cg@exept.de>
parents:
1901
diff
changeset
|
699 |
self at:lineNr basicPut:l |
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 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
702 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
703 |
"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
|
704 |
"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
|
705 |
! |
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 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
708 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
709 |
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
|
710 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
711 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
712 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
713 |
|
1481 | 714 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3210 | 715 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
716 |
||
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
717 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
718 |
self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
719 |
undoableDo:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
720 |
self commentFrom:cursorLine to:cursorLine |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
721 |
]. |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
722 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
723 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
724 |
|
3129 | 725 |
self |
726 |
undoableDo: |
|
727 |
[ |
|
728 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
729 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
|
730 |
] ifFalse:[ |
|
3210 | 731 |
commentPair := commentStrings at:2 ifAbsent:nil. |
732 |
commentPair isNil ifTrue:[ |
|
733 |
self beep. |
|
734 |
] ifFalse:[ |
|
735 |
opening := commentPair at:1. |
|
736 |
closing := commentPair at:2. |
|
737 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
3129 | 738 |
|
3210 | 739 |
e := selectionEndCol. |
740 |
||
741 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
742 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
3129 | 743 |
|
3210 | 744 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
745 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
746 |
toLine:selectionEndLine col:e+closing size. |
|
747 |
] |
|
3129 | 748 |
] |
749 |
] |
|
750 |
info:'comment' |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
751 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
752 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 753 |
"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
|
754 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
755 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
756 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
757 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
758 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 759 |
in the first col. |
760 |
(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
|
761 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
762 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
763 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
764 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
765 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
766 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
767 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
768 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
769 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
770 |
rest := eolComment size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
771 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
772 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
773 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
774 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
775 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
776 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
777 |
l notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
778 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
779 |
(l startsWith:eolComment) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
780 |
l := l copyFrom:rest |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
781 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
782 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
783 |
((l startsWith:opening) |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
784 |
and:[l endsWith:closing]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
785 |
l := l copyFrom:opening size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
786 |
l := l copyWithoutLast:closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
787 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
788 |
]. |
1903
86d3493c6a59
when commenting, do all without change notifications,
Claus Gittinger <cg@exept.de>
parents:
1901
diff
changeset
|
789 |
self at:lineNr basicPut:l |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
790 |
] |
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 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
793 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
794 |
"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
|
795 |
"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
|
796 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
797 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
798 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
799 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
800 |
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
|
801 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
802 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
803 |
|e commentPair opening closing sz1 sz2| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
804 |
|
3129 | 805 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
806 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
807 |
self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
808 |
undoableDo:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
809 |
self uncommentFrom:cursorLine to:cursorLine |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
810 |
]. |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
811 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
812 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
813 |
|
3129 | 814 |
self |
815 |
undoableDo: |
|
816 |
[ |
|
817 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
818 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
|
819 |
] ifFalse:[ |
|
820 |
commentPair := commentStrings at:2. |
|
821 |
opening := commentPair at:1. |
|
822 |
closing := commentPair at:2. |
|
823 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
824 |
||
825 |
sz1 := opening size. |
|
826 |
sz2 := closing size. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
827 |
|
3129 | 828 |
((self |
829 |
stringAtLine:selectionStartLine |
|
830 |
from:selectionStartCol |
|
831 |
to:selectionStartCol+sz1 - 1) = opening |
|
832 |
and:[(self |
|
833 |
stringAtLine:selectionEndLine |
|
834 |
from:selectionEndCol - sz2 + 1 |
|
835 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
836 |
|
3129 | 837 |
self deleteCharsAtLine:selectionEndLine fromCol:selectionEndCol-sz2+1 toCol:selectionEndCol. |
838 |
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
|
839 |
|
3129 | 840 |
e := selectionEndCol - sz2. |
841 |
selectionStartLine == selectionEndLine ifTrue:[e := e - sz1]. |
|
842 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
843 |
toLine:selectionEndLine col:e. |
|
844 |
] |
|
845 |
] |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
846 |
] |
3129 | 847 |
info:'uncomment' |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
848 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
849 |
"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
|
850 |
"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
|
851 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
852 |
|
0 | 853 |
!Workspace methodsFor:'events'! |
854 |
||
855 |
keyPress:key x:x y:y |
|
2418
bd16446247c5
lifted keyboardMacro handling to editTextView
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
856 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #BrowseIt)> |
60 | 857 |
|
32 | 858 |
(key == #DoIt) ifTrue:[^ self doIt]. |
23 | 859 |
(key == #InspectIt) ifTrue:[^ self inspectIt]. |
418 | 860 |
(key == #PrintIt) ifTrue:[^ self printIt]. |
2307 | 861 |
(key == #BrowseIt) ifTrue:[^ self browseIt]. |
38 | 862 |
|
0 | 863 |
super keyPress:key x:x y:y |
864 |
! ! |
|
201 | 865 |
|
2143 | 866 |
!Workspace methodsFor:'executing'! |
201 | 867 |
|
1501 | 868 |
do:code withValueDo:aBlock |
418 | 869 |
"helper for doIt, printIt and inspectIt. |
870 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
871 |
aBlock with the value. |
|
872 |
Most work is in preparing for proper cleanup in case of abort |
|
873 |
or other exception while the evaluation is performed. |
|
874 |
(restore cursor, selectionColors etc.)" |
|
201 | 875 |
|
1501 | 876 |
|selLine selCol endLine endCol cLine cCol cleanUp| |
201 | 877 |
|
878 |
code notNil ifTrue:[ |
|
2409 | 879 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
2408 | 880 |
|
257 | 881 |
codeStartPosition := self characterPositionOfSelection. |
201 | 882 |
|
257 | 883 |
" |
884 |
remember selection for later - if there is an error, |
|
885 |
the notification method will highlight it. |
|
886 |
thus destroying the current selection |
|
887 |
" |
|
888 |
selLine := selectionStartLine. |
|
889 |
selCol := selectionStartCol. |
|
890 |
endLine := selectionEndLine. |
|
891 |
endCol := selectionEndCol. |
|
892 |
cCol := cursorCol. |
|
893 |
cLine := cursorLine. |
|
201 | 894 |
|
257 | 895 |
" |
896 |
cleanup: restore previous selection and cursor positions |
|
897 |
" |
|
898 |
cleanUp := [ |
|
899 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
900 |
cLine notNil ifTrue:[ |
|
901 |
self cursorLine:cLine col:cCol |
|
902 |
]. |
|
903 |
]. |
|
201 | 904 |
|
257 | 905 |
" |
906 |
perform the action. |
|
907 |
Be careful to release the reference to the value; |
|
908 |
otherwise, we could keep lots of garbage from being freed |
|
909 |
until the view gets closed |
|
910 |
" |
|
911 |
self topView withExecuteCursorDo:[ |
|
912 |
[ |
|
3008 | 913 |
AbortOperationRequest handle:[:ex | |
257 | 914 |
ex return |
915 |
] do:[ |
|
929 | 916 |
|value| |
917 |
||
257 | 918 |
doItAction notNil ifTrue:[ |
929 | 919 |
value := doItAction value:(code asString). |
257 | 920 |
cleanUp value. cleanUp := nil. |
921 |
aBlock value:value. |
|
2726 | 922 |
value := nil. |
2657 | 923 |
self class rememberDoIt:code. |
257 | 924 |
] |
925 |
] |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
926 |
] ensure:[ |
929 | 927 |
cleanUp notNil ifTrue:[ |
928 |
cleanUp value. cleanUp := nil |
|
929 |
]. |
|
257 | 930 |
] |
931 |
]. |
|
201 | 932 |
] |
257 | 933 |
|
1501 | 934 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
935 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
2409 | 936 |
"Modified: / 26.9.2001 / 17:32:59 / cg" |
201 | 937 |
! ! |
938 |
||
2751 | 939 |
!Workspace methodsFor:'initialization & release'! |
201 | 940 |
|
2733 | 941 |
doItAction:aOneArgBlock |
942 |
"define the action to be performed when 'doIt' is selected. |
|
943 |
The block will be evaluated, passing the selection as a String argument. |
|
944 |
A default doItAction is set for you in the initialize method." |
|
945 |
||
946 |
doItAction := aOneArgBlock |
|
947 |
||
948 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
949 |
! |
|
950 |
||
951 |
executeDoIt:theCode |
|
952 |
^ self compilerClass |
|
953 |
evaluate:theCode |
|
954 |
in:nil |
|
955 |
receiver:simulatedSelf |
|
956 |
notifying:self |
|
957 |
logged:true |
|
958 |
ifFail:nil |
|
959 |
! |
|
960 |
||
201 | 961 |
initStyle |
966 | 962 |
"setup viewStyle specifics" |
963 |
||
201 | 964 |
super initStyle. |
965 |
||
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
966 |
DefaultViewBackground notNil ifTrue:[ |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
967 |
viewBackground := DefaultViewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
968 |
self backgroundColor:viewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
969 |
]. |
201 | 970 |
! |
971 |
||
972 |
initialize |
|
973 |
super initialize. |
|
974 |
||
2775 | 975 |
scrollWhenUpdating := #beginOfText. |
201 | 976 |
showMatchingParenthesis := true. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
977 |
commentStrings := #( |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
978 |
'"/' |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
979 |
('"' '"') |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
980 |
). |
201 | 981 |
|
982 |
self initializeDoITAction. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
983 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
984 |
"Modified: / 9.11.1997 / 01:10:18 / cg" |
201 | 985 |
! |
986 |
||
987 |
initializeDoITAction |
|
988 |
"set up the block to be evaluated for doIts. |
|
989 |
This is done here in a separate method to allow easier |
|
990 |
redefinition in subclasses" |
|
991 |
||
2733 | 992 |
doItAction := [:theCode | self executeDoIt:theCode]. |
201 | 993 |
! ! |
994 |
||
418 | 995 |
!Workspace methodsFor:'menu & menu actions'! |
996 |
||
2285 | 997 |
browseClass |
998 |
"user selected 'browseClass' from menu; evaluate the code |
|
999 |
and open a browser on the resulting class (if it evaluates to one)" |
|
1000 |
||
1001 |
^ self |
|
3272 | 1002 |
do:(self selectionAsString) |
2285 | 1003 |
withValueDo:[:result | result isBehavior ifTrue:[ |
2410 | 1004 |
result browserClass openInClass:result selector:nil |
2285 | 1005 |
] ifFalse:[ |
1006 |
self warn:'Selection does not evaluate to a class' |
|
1007 |
] |
|
1008 |
]. |
|
1009 |
||
2410 | 1010 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 1011 |
! |
1012 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1013 |
browseImplementorsOfIt |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1014 |
"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
|
1015 |
|
2714 | 1016 |
|selectedText selector browserClass| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1017 |
|
2714 | 1018 |
selectedText := self selectionAsString. |
1019 |
selectedText size > 0 ifTrue:[ |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1020 |
self windowGroup withWaitCursorDo:[ |
3287 | 1021 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
2714 | 1022 |
|
1023 |
browserClass := UserPreferences current systemBrowserClass. |
|
1024 |
||
3287 | 1025 |
(selector notNil and:[selector ~= selectedText]) ifTrue:[ |
2714 | 1026 |
browserClass browseImplementorsOfAny:(Set with:selector with:selectedText) |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1027 |
] ifFalse:[ |
2714 | 1028 |
browserClass browseImplementorsOf:(selector ? selectedText) |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1029 |
] |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1030 |
] |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1031 |
]. |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1032 |
|
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1033 |
"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
|
1034 |
"Modified: / 19.11.2001 / 22:15:17 / cg" |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1035 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1036 |
|
2307 | 1037 |
browseIt |
1038 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
2713 | 1039 |
or the class of the resulting object (if it does not evaluate to a class). |
1040 |
||
1041 |
Added feature: if selection is of the form class >> selector, immediately switch to that selector." |
|
1042 |
||
1043 |
|codeToEvaluate idx selector| |
|
1044 |
||
3272 | 1045 |
codeToEvaluate := self selectionOrTextOfCursorLine withoutSeparators. |
2713 | 1046 |
idx := codeToEvaluate indexOfSubCollection:'>>'. |
1047 |
idx ~~ 0 ifTrue:[ |
|
2717 | 1048 |
selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string. |
3155 | 1049 |
(selector startsWith:'#') ifTrue:[ |
1050 |
selector := Symbol readFrom:selector. |
|
1051 |
]. |
|
2713 | 1052 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
1053 |
]. |
|
2307 | 1054 |
|
1055 |
^ self |
|
2713 | 1056 |
do:codeToEvaluate |
3284
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1057 |
withValueDo:[:result | |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1058 |
result isNil ifTrue:[ |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1059 |
codeToEvaluate asCollectionOfWords size == 1 ifTrue:[ |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1060 |
codeToEvaluate isUppercaseFirst ifTrue:[ |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1061 |
Dialog information:(codeToEvaluate allBold , ' is unbound or nil'). |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1062 |
^ self. |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1063 |
]. |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1064 |
] |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1065 |
]. |
68f4e33b5c65
dont browse nil/unbound globals
Claus Gittinger <cg@exept.de>
parents:
3279
diff
changeset
|
1066 |
result isBehavior ifTrue:[ |
2713 | 1067 |
result browserClass openInClass:result selector:selector |
2307 | 1068 |
] ifFalse:[ |
2410 | 1069 |
result class browserClass openInClass:(result class) selector:nil |
2307 | 1070 |
] |
1071 |
]. |
|
2410 | 1072 |
|
1073 |
"Modified: / 26.9.2001 / 17:37:50 / cg" |
|
2307 | 1074 |
! |
1075 |
||
2285 | 1076 |
browseItsClass |
1077 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
1078 |
and open a browser on the results class" |
|
1079 |
||
1080 |
^ self |
|
3272 | 1081 |
do:(self selectionAsString) |
2410 | 1082 |
withValueDo:[:result | |
1083 |
result class browserClass openInClass:result class selector:nil |
|
1084 |
] |
|
2285 | 1085 |
|
2410 | 1086 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 1087 |
! |
1088 |
||
2454 | 1089 |
browseReferencesToIt |
1090 |
"open a browser on all references to the selected global" |
|
1091 |
||
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1092 |
|sel| |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1093 |
|
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1094 |
sel := self selectionAsString. |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1095 |
sel size > 0 ifTrue:[ |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1096 |
self windowGroup withWaitCursorDo:[ |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1097 |
(UserPreferences current systemBrowserClass) |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1098 |
browseReferendsOf:sel |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1099 |
]. |
2454 | 1100 |
]. |
1101 |
||
1102 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
1103 |
"Modified: / 5.11.2001 / 17:32:38 / cg" |
|
1104 |
! |
|
1105 |
||
2462 | 1106 |
browseSendersOfIt |
1107 |
"open a browser on the senders of the selected text" |
|
1108 |
||
2715 | 1109 |
|selectedText selector| |
2462 | 1110 |
|
2715 | 1111 |
selectedText := self selectionAsString. |
1112 |
selectedText size > 0 ifTrue:[ |
|
2462 | 1113 |
self windowGroup withWaitCursorDo:[ |
3287 | 1114 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
2462 | 1115 |
(UserPreferences current systemBrowserClass) |
2715 | 1116 |
browseAllCallsOn:(selector ? selectedText) |
2462 | 1117 |
] |
1118 |
]. |
|
1119 |
||
1120 |
"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
|
1121 |
"Modified: / 19.11.2001 / 22:15:27 / cg" |
2462 | 1122 |
! |
1123 |
||
418 | 1124 |
doIt |
1125 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
1126 |
and finally restore cursor; return result of evaluation" |
|
1127 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1128 |
^ self |
3272 | 1129 |
do:(self selectionOrTextOfCursorLine) |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1130 |
withValueDo:[:result | ] |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1131 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1132 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 1133 |
! |
1134 |
||
1135 |
editMenu |
|
1107 | 1136 |
"return my popUpMenu; thats the superclasses menu |
1137 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
|
1138 |
||
2459 | 1139 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
1140 |
#CommentSelection #UncommentSelection |
|
2573
52c995a1ea78
accelerators for browseIt and implementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
2571
diff
changeset
|
1141 |
#BrowseIt #ImplementorsOfIt |
2459 | 1142 |
)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
1143 |
<resource: #programMenu> |
489 | 1144 |
|
2867 | 1145 |
|m sub subsub idx sensor s s2| |
418 | 1146 |
|
1147 |
m := super editMenu. |
|
3252 | 1148 |
((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
2459 | 1149 |
sub := m. |
1150 |
m := nil. |
|
1151 |
] ifFalse:[ |
|
1152 |
sub := m subMenuAt:#others. |
|
1153 |
]. |
|
418 | 1154 |
|
2459 | 1155 |
sub notNil ifTrue:[ |
2867 | 1156 |
|
2459 | 1157 |
" |
2867 | 1158 |
workspaces support #browse, implementors etc. add them after paste. |
2459 | 1159 |
" |
2867 | 1160 |
sub |
1161 |
addItemList:#( |
|
1162 |
('-' ) |
|
1163 |
('Browse' browseIt BrowseIt ) |
|
1164 |
('Senders of It' browseSendersOfIt ) |
|
1165 |
('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
|
1166 |
('References to It' browseReferencesToIt ) |
|
1167 |
('-' ) |
|
1168 |
('TimeIt' timeIt ) |
|
1169 |
('SpyOnIt' spyOnIt )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1170 |
resources:resources |
2459 | 1171 |
after:#gotoLine. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1172 |
|
2867 | 1173 |
subsub := sub subMenuAt:#tools. |
1174 |
subsub notNil ifTrue:[ |
|
1175 |
subsub |
|
1176 |
addItemList:#( |
|
1177 |
('-' ) |
|
1178 |
('Comment' commentSelection CommentSelection ) |
|
1179 |
('Uncomment' uncommentSelection UncommentSelection )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1180 |
resources:resources |
2867 | 1181 |
after:#'indent'. |
1182 |
]. |
|
1183 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1184 |
self hasSelection ifFalse:[ |
3272 | 1185 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt browseReferencesToIt timeIt spyOnIt |
1186 |
commentSelection uncommentSelection ) |
|
2454 | 1187 |
] ifTrue:[ |
1188 |
s := self selectionAsString. |
|
3287 | 1189 |
s2 := SystemBrowser extractSelectorFrom:s. |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1190 |
s2 notNil ifTrue:[ |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1191 |
s2 := s2 asSymbolIfInterned. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1192 |
]. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1193 |
s notNil ifTrue:[ |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1194 |
s := s asSymbolIfInterned. |
2454 | 1195 |
]. |
2487
47e0a1faf544
disabling of impl/senders menu
Claus Gittinger <cg@exept.de>
parents:
2485
diff
changeset
|
1196 |
(s2 isNil and:[s isNil]) ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1197 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1198 |
]. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1199 |
(s isNil |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1200 |
or:[(Smalltalk includesKey:s) not]) |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1201 |
ifTrue:[ |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1202 |
sub disable:#browseReferencesToIt. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1203 |
]. |
2595 | 1204 |
self isReadOnly ifTrue:[ |
2641 | 1205 |
sub disableAll:#(commentSelection uncommentSelection) |
2595 | 1206 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1207 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1208 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1209 |
|
2459 | 1210 |
m notNil ifTrue:[ |
1211 |
" |
|
1212 |
workspaces support #doIt, #printIt and #inspectIt |
|
1213 |
add them after paste. |
|
1214 |
" |
|
1215 |
idx := m indexOf:#paste. |
|
1216 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
1217 |
idx ~~ 0 ifTrue:[ |
|
2867 | 1218 |
m |
1219 |
addItemList:#( |
|
1220 |
('-' ) |
|
1221 |
('DoIt' doIt DoIt ) |
|
1222 |
('PrintIt' printIt PrintIt ) |
|
1223 |
('InspectIt' inspectIt InspectIt)) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1224 |
resources:resources |
2459 | 1225 |
after:idx. |
1226 |
||
1227 |
]. |
|
1228 |
||
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
1229 |
(self hasSelectionOrTextInCursorLine) ifFalse:[ |
3272 | 1230 |
|lNr line| |
1231 |
||
1232 |
lNr := self cursorLine. |
|
1233 |
line := self listAt:lNr. |
|
1234 |
line isEmptyOrNil ifTrue:[ |
|
1235 |
m disableAll:#(printIt doIt inspectIt browseIt) |
|
1236 |
]. |
|
2459 | 1237 |
]. |
2595 | 1238 |
self isReadOnly ifTrue:[ |
1239 |
m disable:#printIt |
|
1240 |
]. |
|
418 | 1241 |
]. |
1242 |
||
2459 | 1243 |
^ m ? sub. |
430 | 1244 |
|
1501 | 1245 |
"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
|
1246 |
"Modified: / 19.11.2001 / 23:12:01 / cg" |
418 | 1247 |
! |
1248 |
||
1249 |
inspectIt |
|
1250 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
1251 |
and start an inspector on the result" |
|
1252 |
||
2981
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1253 |
|shifted| |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1254 |
|
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1255 |
shifted := self sensor shiftDown. |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1256 |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1257 |
^ self |
3272 | 1258 |
do:(self selectionOrTextOfCursorLine) |
2982
9a831ab53acc
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2981
diff
changeset
|
1259 |
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
|
1260 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1261 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 1262 |
! |
1263 |
||
1264 |
printIt |
|
1265 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
1266 |
and insert result of evaluation into my text. |
|
1267 |
If the text is readOnly, do nothing." |
|
1268 |
||
1734 | 1269 |
self isReadOnly ifTrue:[ |
693 | 1270 |
self beep |
418 | 1271 |
] ifFalse:[ |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1272 |
self |
3272 | 1273 |
do:(self selectionOrTextOfCursorLine) |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1274 |
withValueDo:[:result | |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1275 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1276 |
self insertSelectedStringAtCursor:(result displayString "printString") |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1277 |
] |
418 | 1278 |
] |
1279 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1280 |
"Modified: / 16.5.1998 / 16:44:44 / cg" |
1501 | 1281 |
! |
1282 |
||
1283 |
spyOnIt |
|
1284 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
1285 |
and finally restore cursor; return result of evaluation" |
|
1286 |
||
1287 |
|code| |
|
1288 |
||
3272 | 1289 |
code := 'MessageTally spyOn:[' , self selectionAsString, ']'. |
1501 | 1290 |
self do:code withValueDo:[:result | ] |
1291 |
||
1292 |
"Modified: / 22.4.1998 / 22:03:53 / ca" |
|
1293 |
! |
|
1294 |
||
1295 |
timeIt |
|
1296 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
1297 |
and finally restore cursor; return result of evaluation" |
|
1298 |
||
1299 |
|code| |
|
1300 |
||
3272 | 1301 |
code := '|t| t := Time millisecondsToRun:[' , self selectionAsString, ']. |
3141 | 1302 |
|
1303 |
Transcript showCR:''execution time: '' , t printString , '' ms''.'. |
|
1501 | 1304 |
self do:code withValueDo:[:result | ] |
1305 |
||
1306 |
"Modified: / 22.4.1998 / 22:03:51 / ca" |
|
418 | 1307 |
! ! |
1308 |
||
2646 | 1309 |
!Workspace methodsFor:'queries'! |
1310 |
||
1311 |
isWorkspace |
|
1312 |
^ true |
|
1313 |
! ! |
|
1314 |
||
206 | 1315 |
!Workspace class methodsFor:'documentation'! |
1316 |
||
1317 |
version |
|
3325 | 1318 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.162 2006-08-09 12:39:39 cg Exp $' |
858 | 1319 |
! ! |