author | Claus Gittinger <cg@exept.de> |
Mon, 26 Feb 1996 22:42:02 +0100 | |
changeset 403 | ee8f6d080077 |
parent 368 | 53476ee1fbee |
child 418 | 777061f25321 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
TextCollector subclass:#Workspace |
|
257 | 14 |
instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor' |
15 |
classVariableNames:'DefaultErrorForegroundColor DefaultErrorBackgroundColor' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Interface-Workspace' |
|
0 | 18 |
! |
19 |
||
32 | 20 |
!Workspace class methodsFor:'documentation'! |
21 |
||
38 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 25 |
All Rights Reserved |
38 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
32 | 36 |
documentation |
37 |
" |
|
38 |
a view for editable text which can evaluate expressions. |
|
38 | 39 |
I.e. its basically a view for editable text, with added |
40 |
'doIt', 'printIt' and 'inspectIt' functions on the popup-menu. |
|
125 | 41 |
|
38 | 42 |
The action to be performed on doIt is defined by a block, |
58 | 43 |
which can be defined by the owner of this view. |
60 | 44 |
(thus you can put a workspace into more complex widgets, and |
45 |
control what should happen on 'doIt'). |
|
58 | 46 |
|
38 | 47 |
A useful default action is setup, which simply evaluates the |
125 | 48 |
selection as a smalltalk expression. |
49 |
(but, a lisp or prolog view could define its own action ...) |
|
32 | 50 |
|
123 | 51 |
|
52 |
Caveat: |
|
53 |
in this version, Workspace does not yet support doIt in MVC setups. |
|
54 |
For now, simulate this by setting the doItAction, to notify the |
|
55 |
model manually about the doIt. |
|
56 |
||
57 |
||
32 | 58 |
instance variables: |
59 |
||
121 | 60 |
doItAction <Block> block to evaluate for doIt |
123 | 61 |
|
121 | 62 |
codeStartPosition temporary |
63 |
||
64 |
errorFgColor <Color> fg-Color to be used when highlighting errors |
|
65 |
||
66 |
errorBgColor <Color> bg-Color to be used when highlighting errors |
|
58 | 67 |
|
121 | 68 |
|
69 |
styleSheet values: |
|
70 |
||
71 |
codeErrorSelectionForegroundColor fg color to highlight errors |
|
123 | 72 |
(default: selection fg) |
121 | 73 |
codeErrorSelectionBackgroundColor bg color to highlight errors |
123 | 74 |
(default: selection bg) |
32 | 75 |
" |
201 | 76 |
! ! |
77 |
||
78 |
!Workspace class methodsFor:'defaults'! |
|
79 |
||
80 |
updateStyleCache |
|
81 |
DefaultErrorForegroundColor := StyleSheet colorAt:'codeErrorSelectionForegroundColor'. |
|
82 |
DefaultErrorBackgroundColor := StyleSheet colorAt:'codeErrorSelectionBackgroundColor'. |
|
32 | 83 |
! ! |
84 |
||
0 | 85 |
!Workspace class methodsFor:'getting a System Workspace'! |
86 |
||
32 | 87 |
open |
0 | 88 |
"launch a new workspace" |
89 |
||
23 | 90 |
|scrollable scr topView workspace f| |
0 | 91 |
|
92 |
topView := StandardSystemView label:'Workspace' minExtent:(100 @ 100). |
|
23 | 93 |
|
94 |
scrollable := true. |
|
95 |
scrollable ifTrue:[ |
|
59 | 96 |
scr := HVScrollableView "ScrollableView" for:self in:topView. |
97 |
scr origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
98 |
workspace := scr scrolledView. |
|
23 | 99 |
] ifFalse:[ |
59 | 100 |
workspace := super origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:topView. |
101 |
workspace level:0. |
|
23 | 102 |
]. |
0 | 103 |
|
58 | 104 |
"adjust topViews extent according to my font" |
0 | 105 |
f := workspace font. |
106 |
topView extent:((f widthOf:'x') * 40) @ (f height * 10). |
|
7 | 107 |
topView open. |
131 | 108 |
^ workspace |
0 | 109 |
|
58 | 110 |
" |
111 |
Workspace open |
|
112 |
" |
|
0 | 113 |
! ! |
114 |
||
201 | 115 |
!Workspace methodsFor:'accessing'! |
0 | 116 |
|
201 | 117 |
doItAction |
118 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 119 |
|
201 | 120 |
^ doItAction |
0 | 121 |
! |
122 |
||
123 |
doItAction:aBlock |
|
124 |
"define the action to be performed when 'doIt' is selected" |
|
125 |
||
126 |
doItAction := aBlock |
|
201 | 127 |
! ! |
128 |
||
129 |
!Workspace methodsFor:'compiler interface'! |
|
130 |
||
131 |
currentSourceCode |
|
132 |
"special interface to compiler - called by parser |
|
133 |
to get the updated source code after a corrected error" |
|
134 |
||
135 |
^ self contents |
|
0 | 136 |
! |
137 |
||
201 | 138 |
wantChangeLog |
139 |
"sent by the compiler to ask if a changeLog entry should |
|
140 |
be written. Return true here." |
|
0 | 141 |
|
201 | 142 |
^ true |
0 | 143 |
! ! |
144 |
||
145 |
!Workspace methodsFor:'error handling'! |
|
146 |
||
201 | 147 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
148 |
"compiler notifies us of a correctable error; |
|
149 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
150 |
this method should return true to the compiler if user wants the error |
|
151 |
to be corrected; false otherwise" |
|
152 |
||
153 |
|action| |
|
154 |
||
155 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
368 | 156 |
action := OptionBox |
157 |
request:aString |
|
158 |
label:'Error' |
|
159 |
form:(WarningBox iconBitmap) |
|
160 |
buttonLabels:#('cancel' 'correct' 'continue') |
|
161 |
values:#(#abort #correct #continue) |
|
162 |
default:#continue. |
|
201 | 163 |
]. |
164 |
||
165 |
action == #abort ifTrue:[ |
|
368 | 166 |
Object abortSignal raise. |
167 |
^ false |
|
201 | 168 |
]. |
368 | 169 |
^ action == #correct |
170 |
||
171 |
"Modified: 20.2.1996 / 20:48:52 / cg" |
|
201 | 172 |
! |
173 |
||
174 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
|
175 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
|
176 |
and show a Box asking for continue/abort." |
|
177 |
||
178 |
|answer| |
|
179 |
||
180 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
181 |
|box lbl| |
201 | 182 |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
183 |
WarningSignal isHandled ifTrue:[ |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
184 |
WarningSignal raiseErrorString:aString. |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
185 |
^ false |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
186 |
]. |
201 | 187 |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
188 |
" |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
189 |
ask if we should abort or continue |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
190 |
" |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
191 |
box := YesNoBox title:aString |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
192 |
yesText:(resources string:'continue') |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
193 |
noText:(resources string:'abort'). |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
194 |
|
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
195 |
asWarning ifTrue:[ |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
196 |
lbl := 'Compiler warning' |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
197 |
] ifFalse:[ |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
198 |
lbl := 'Compiler error'. |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
199 |
]. |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
200 |
box label:lbl. |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
201 |
box form:(WarningBox iconBitmap). |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
202 |
answer := box confirm. |
201 | 203 |
]. |
204 |
||
205 |
" |
|
206 |
do the abort if we have to |
|
207 |
" |
|
208 |
answer ifFalse:[ |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
209 |
Object abortSignal raise. |
201 | 210 |
]. |
211 |
^ 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
|
212 |
|
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
213 |
"Created: 24.11.1995 / 22:56:34 / cg" |
201 | 214 |
! |
215 |
||
216 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
217 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
|
218 |
and show a Box asking for continue/abort." |
|
219 |
||
220 |
^ self error:aString position:relPos to:relEndPos asWarning:false |
|
221 |
! |
|
222 |
||
59 | 223 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
224 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 225 |
|
59 | 226 |
|absPosition fg bg| |
0 | 227 |
|
58 | 228 |
" |
229 |
change color of selection & hide cursor |
|
230 |
" |
|
0 | 231 |
fg := selectionFgColor. |
232 |
bg := selectionBgColor. |
|
233 |
selectionBgColor := errorBgColor. |
|
234 |
selectionFgColor := errorFgColor. |
|
58 | 235 |
self hideCursor. |
0 | 236 |
|
58 | 237 |
" |
238 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
239 |
we have to adjust the positions given by the compiler, since they |
|
240 |
are relative to the texts start (the compiler did stream-read the code). |
|
241 |
" |
|
0 | 242 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
243 |
absPosition := codeStartPosition + relPos - 1. |
|
244 |
relEndPos isNil ifTrue:[ |
|
59 | 245 |
self selectLineWhereCharacterPosition:absPosition |
0 | 246 |
] ifFalse:[ |
59 | 247 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + relEndPos - 1) |
0 | 248 |
]. |
249 |
self makeSelectionVisible. |
|
250 |
||
155 | 251 |
device flush. |
58 | 252 |
|
59 | 253 |
aBlock valueNowOrOnUnwindDo:[ |
254 |
" |
|
255 |
undo selection color change and show cursor again |
|
256 |
" |
|
257 |
selectionFgColor := fg. |
|
258 |
selectionBgColor := bg. |
|
259 |
self showCursor. |
|
0 | 260 |
]. |
261 |
! |
|
262 |
||
116 | 263 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 264 |
"compiler notifies us of a warning - same behavior as error" |
0 | 265 |
|
95 | 266 |
self error:aString position:relPos to:relEndPos asWarning:true |
0 | 267 |
! ! |
268 |
||
269 |
!Workspace methodsFor:'events'! |
|
270 |
||
271 |
keyPress:key x:x y:y |
|
132 | 272 |
|
273 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt)> |
|
274 |
||
131 | 275 |
|cmd commands fKey| |
60 | 276 |
|
32 | 277 |
(key == #DoIt) ifTrue:[^ self doIt]. |
23 | 278 |
(key == #InspectIt) ifTrue:[^ self inspectIt]. |
79 | 279 |
(key == #PrintIt) ifTrue:[ |
280 |
readOnly ifFalse:[self printIt]. |
|
281 |
^ self |
|
282 |
]. |
|
38 | 283 |
|
284 |
" |
|
131 | 285 |
Ctrl-Fn or Cmd-Fn evaluates a key-sequence (n = 0..99) |
60 | 286 |
(I added Ctrl-Fn, because some windowmanagers already use cmd-fn) |
38 | 287 |
see TextView>>keyPress:x:y: |
288 |
" |
|
131 | 289 |
key isSymbol ifTrue:[ |
290 |
(key startsWith:'CmdF') ifTrue:[ |
|
291 |
fKey := key copyFrom:4 |
|
292 |
] ifFalse:[ |
|
293 |
(key startsWith:'CtrlF') ifTrue:[ |
|
294 |
fKey := key copyFrom:5 |
|
295 |
] |
|
296 |
]. |
|
297 |
]. |
|
298 |
fKey notNil ifTrue:[ |
|
299 |
fKey := fKey asSymbol. |
|
95 | 300 |
commands := Smalltalk at:#FunctionKeySequences ifAbsent:[nil]. |
301 |
commands notNil ifTrue:[ |
|
131 | 302 |
cmd := commands at:fKey ifAbsent:[nil]. |
95 | 303 |
cmd notNil ifTrue:[ |
365 | 304 |
AbortSignal "ErrorSignal" handle:[:ex | |
131 | 305 |
self warn:'error occurred in keyboard macro'. |
306 |
ex return. |
|
307 |
] do:[ |
|
308 |
Parser evaluate:cmd asString |
|
309 |
receiver:self |
|
310 |
notifying:nil |
|
311 |
compile:false. |
|
312 |
]. |
|
95 | 313 |
^ self |
59 | 314 |
] |
315 |
] |
|
38 | 316 |
]. |
317 |
||
0 | 318 |
super keyPress:key x:x y:y |
38 | 319 |
|
320 |
" |
|
321 |
example uses of funtion keys: |
|
322 |
||
323 |
to set tab-distance to 4-cols, |
|
324 |
select the following: |
|
325 |
||
326 |
self setTab4 |
|
327 |
||
328 |
then, press shift-F2 to define the sequence; |
|
95 | 329 |
press cmd-F2 to execute it |
38 | 330 |
voila: you have set 4-tabs. |
95 | 331 |
(some window managers (MWM, 4DWM have cmd-Fn redefined; use Ctrl-Fn then). |
38 | 332 |
|
333 |
to switch back, perform the same procedure with: |
|
334 |
||
59 | 335 |
self setTab8 |
38 | 336 |
|
60 | 337 |
Within the expression, 'self' is bound to the view. Thus, you can do |
338 |
all kinds of fancy things. |
|
339 |
For example: |
|
95 | 340 |
if you like a browser to come up on the selection when pressing Cmd-F3: |
60 | 341 |
select: |
38 | 342 |
|
59 | 343 |
|sel| |
344 |
sel := self selection asString withoutSeparators. |
|
345 |
(Smalltalk includesKey:sel asSymbol) ifTrue:[ |
|
346 |
(Smalltalk at:sel asSymbol) isClass ifTrue:[ |
|
347 |
SystemBrowser browseClass:(Smalltalk at:sel asSymbol) |
|
348 |
] |
|
349 |
] |
|
38 | 350 |
|
351 |
then, press shift-F3 to define the command. |
|
352 |
press cmd-F3 to execute it (select some classname before). |
|
60 | 353 |
(notice: on the Indy, Cmd-F3 is already used by the window manager) |
38 | 354 |
|
95 | 355 |
if you like a file-include command on Cmd-F4: |
38 | 356 |
select: |
357 |
||
59 | 358 |
|sel| |
359 |
sel := self selection. |
|
360 |
sel notNil ifTrue:[ |
|
361 |
sel := sel asString withoutSeparators. |
|
362 |
s := FileStream readonlyFileNamed:sel. |
|
363 |
s notNil ifTrue:[ |
|
364 |
self paste:(s contents asString). |
|
365 |
s close |
|
366 |
] |
|
367 |
] |
|
38 | 368 |
|
369 |
this will paste the contents of the file at the current cusor position. |
|
60 | 370 |
(select above expression, press Shift-F4, |
371 |
then select any filename and press Cmd-F4) |
|
372 |
try it here: /etc/passwd |
|
38 | 373 |
" |
0 | 374 |
! ! |
201 | 375 |
|
376 |
!Workspace methodsFor:'execution'! |
|
377 |
||
378 |
doIt |
|
379 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
380 |
and finally restore cursor; return result of evaluation" |
|
381 |
||
382 |
self doItWithValueDo:[:result | ] |
|
383 |
! |
|
384 |
||
385 |
doItWithValueDo:aBlock |
|
386 |
"helper for doIt, printIt and inspectIt. Evaluate the selection and, |
|
387 |
if all went well, evaluate the argument, aBlock with the value." |
|
388 |
||
389 |
|code value selLine selCol endLine endCol cLine cCol cleanUp| |
|
390 |
||
391 |
code := self selection. |
|
392 |
code notNil ifTrue:[ |
|
257 | 393 |
codeStartPosition := self characterPositionOfSelection. |
201 | 394 |
|
257 | 395 |
" |
396 |
remember selection for later - if there is an error, |
|
397 |
the notification method will highlight it. |
|
398 |
thus destroying the current selection |
|
399 |
" |
|
400 |
selLine := selectionStartLine. |
|
401 |
selCol := selectionStartCol. |
|
402 |
endLine := selectionEndLine. |
|
403 |
endCol := selectionEndCol. |
|
404 |
cCol := cursorCol. |
|
405 |
cLine := cursorLine. |
|
201 | 406 |
|
257 | 407 |
" |
408 |
cleanup: restore previous selection and cursor positions |
|
409 |
" |
|
410 |
cleanUp := [ |
|
411 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
412 |
cLine notNil ifTrue:[ |
|
413 |
self cursorLine:cLine col:cCol |
|
414 |
]. |
|
415 |
]. |
|
201 | 416 |
|
257 | 417 |
" |
418 |
perform the action. |
|
419 |
Be careful to release the reference to the value; |
|
420 |
otherwise, we could keep lots of garbage from being freed |
|
421 |
until the view gets closed |
|
422 |
" |
|
423 |
self topView withExecuteCursorDo:[ |
|
424 |
[ |
|
425 |
AbortSignal handle:[:ex | |
|
426 |
ex return |
|
427 |
] do:[ |
|
428 |
doItAction notNil ifTrue:[ |
|
429 |
value := doItAction value:code asString. |
|
430 |
cleanUp value. cleanUp := nil. |
|
431 |
aBlock value:value. |
|
432 |
] |
|
433 |
] |
|
434 |
] valueNowOrOnUnwindDo:[ |
|
435 |
cleanUp notNil ifTrue:[cleanUp value. cleanUp := nil]. |
|
436 |
value := nil |
|
437 |
] |
|
438 |
]. |
|
201 | 439 |
] |
257 | 440 |
|
441 |
"Modified: 14.12.1995 / 21:00:05 / cg" |
|
201 | 442 |
! |
443 |
||
444 |
inspectIt |
|
445 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
446 |
and start an inspector on the result" |
|
447 |
||
448 |
self doItWithValueDo:[:result | result inspect] |
|
449 |
! |
|
450 |
||
451 |
printIt |
|
452 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
453 |
and insert result of evaluation into my text" |
|
454 |
||
455 |
self doItWithValueDo:[:result | |
|
456 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
|
457 |
self insertSelectedStringAtCursor:(result displayString "printString") |
|
458 |
] |
|
459 |
! ! |
|
460 |
||
461 |
!Workspace methodsFor:'initialize / release'! |
|
462 |
||
463 |
editMenu |
|
464 |
|m idx| |
|
465 |
||
466 |
m := super editMenu. |
|
467 |
||
468 |
" |
|
469 |
workspaces support #doIt, #printIt and #inspectIt |
|
470 |
add them after paste. |
|
471 |
" |
|
472 |
idx := m indexOf:#paste. |
|
473 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
474 |
idx ~~ 0 ifTrue:[ |
|
475 |
m addLabels:(resources array:#('-' 'doIt' 'printIt' 'inspectIt')) |
|
476 |
selectors:#(nil doIt printIt inspectIt) |
|
477 |
after:idx. |
|
478 |
]. |
|
479 |
||
480 |
self hasSelection ifFalse:[ |
|
481 |
m disableAll:#(printIt doIt inspectIt) |
|
482 |
]. |
|
483 |
||
484 |
^ m. |
|
485 |
! |
|
486 |
||
487 |
initStyle |
|
488 |
super initStyle. |
|
489 |
||
490 |
errorFgColor := DefaultErrorForegroundColor. |
|
491 |
errorFgColor isNil ifTrue:[errorFgColor := selectionFgColor]. |
|
492 |
errorBgColor := DefaultErrorBackgroundColor. |
|
493 |
errorBgColor isNil ifTrue:[ |
|
494 |
device hasColors ifTrue:[ |
|
495 |
errorBgColor := Color red |
|
496 |
] ifFalse:[ |
|
497 |
errorBgColor := selectionBgColor |
|
498 |
] |
|
499 |
]. |
|
500 |
! |
|
501 |
||
502 |
initialize |
|
503 |
super initialize. |
|
504 |
||
505 |
showMatchingParenthesis := true. |
|
506 |
||
507 |
self initializeDoITAction. |
|
508 |
! |
|
509 |
||
510 |
initializeDoITAction |
|
511 |
"set up the block to be evaluated for doIts. |
|
512 |
This is done here in a separate method to allow easier |
|
513 |
redefinition in subclasses" |
|
514 |
||
515 |
doItAction := [:theCode | |
|
516 |
Compiler |
|
517 |
evaluate:theCode |
|
518 |
in:nil |
|
519 |
receiver:nil |
|
520 |
notifying:self |
|
521 |
logged:true |
|
522 |
ifFail:nil |
|
523 |
]. |
|
524 |
! ! |
|
525 |
||
206 | 526 |
!Workspace class methodsFor:'documentation'! |
527 |
||
528 |
version |
|
368 | 529 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.37 1996-02-20 20:36:47 cg Exp $'! ! |