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