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