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