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