equal
deleted
inserted
replaced
21 |
21 |
22 Workspace comment:' |
22 Workspace comment:' |
23 COPYRIGHT (c) 1989 by Claus Gittinger |
23 COPYRIGHT (c) 1989 by Claus Gittinger |
24 All Rights Reserved |
24 All Rights Reserved |
25 |
25 |
26 $Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.16 1995-02-27 10:41:52 claus Exp $ |
26 $Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.17 1995-03-06 19:29:50 claus Exp $ |
27 '! |
27 '! |
28 |
28 |
29 !Workspace class methodsFor:'documentation'! |
29 !Workspace class methodsFor:'documentation'! |
30 |
30 |
31 copyright |
31 copyright |
42 " |
42 " |
43 ! |
43 ! |
44 |
44 |
45 version |
45 version |
46 " |
46 " |
47 $Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.16 1995-02-27 10:41:52 claus Exp $ |
47 $Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.17 1995-03-06 19:29:50 claus Exp $ |
48 " |
48 " |
49 ! |
49 ! |
50 |
50 |
51 documentation |
51 documentation |
52 " |
52 " |
132 errorBgColor := selectionBgColor |
132 errorBgColor := selectionBgColor |
133 ] |
133 ] |
134 ]. |
134 ]. |
135 ! |
135 ! |
136 |
136 |
137 initializeMiddleButtonMenu |
137 editMenu |
138 |idx| |
138 |m idx| |
139 |
139 |
140 super initializeMiddleButtonMenu. |
140 m := super editMenu. |
141 |
141 |
142 " |
142 " |
143 workspaces support #doIt, #printIt and #inspectIt |
143 workspaces support #doIt, #printIt and #inspectIt |
144 add them after paste. |
144 add them after paste. |
145 " |
145 " |
146 idx := middleButtonMenu indexOf:#paste. |
146 idx := m indexOf:#paste. |
147 middleButtonMenu addLabel:'-' |
147 m addLabel:'-' selector:nil after:idx. |
148 selector:nil |
148 m addLabel:(resources string:'doIt') selector:#doIt after:idx + 1. |
149 after:idx. |
149 m addLabel:(resources string:'printIt') selector:#printIt after:idx + 2. |
150 middleButtonMenu addLabel:(resources string:'doIt') |
150 m addLabel:(resources string:'inspectIt') selector:#inspectIt after:idx + 3. |
151 selector:#doIt |
151 |
152 after:idx + 1. |
152 self hasSelection ifFalse:[ |
153 middleButtonMenu addLabel:(resources string:'printIt') |
153 m disable:#doIt. |
154 selector:#printIt |
154 m disable:#printIt. |
155 after:idx + 2. |
155 m disable:#inspectIt. |
156 middleButtonMenu addLabel:(resources string:'inspectIt') |
156 ]. |
157 selector:#inspectIt |
157 readOnly ifTrue:[ |
158 after:idx + 3. |
158 m disable:#printIt. |
159 |
159 ]. |
160 self enableOrDisableSelectionMenuEntries |
160 |
|
161 ^ m. |
161 ! |
162 ! |
162 |
163 |
163 initializeDoITAction |
164 initializeDoITAction |
164 "set up the block to be evaluated for doIts. |
165 "set up the block to be evaluated for doIts. |
165 This is done here in a separate method to allow easier |
166 This is done here in a separate method to allow easier |
174 logged:true |
175 logged:true |
175 ifFail:nil |
176 ifFail:nil |
176 ]. |
177 ]. |
177 ! ! |
178 ! ! |
178 |
179 |
179 !Workspace methodsFor:'selections'! |
|
180 |
|
181 disableSelectionMenuEntries |
|
182 "disable relevant menu entries for a selection" |
|
183 |
|
184 super disableSelectionMenuEntries. |
|
185 middleButtonMenu notNil ifTrue:[ |
|
186 middleButtonMenu disable:#doIt. |
|
187 middleButtonMenu disable:#printIt. |
|
188 middleButtonMenu disable:#inspectIt |
|
189 ] |
|
190 ! |
|
191 |
|
192 enableSelectionMenuEntries |
|
193 "enable relevant menu entries for a selection" |
|
194 |
|
195 super enableSelectionMenuEntries. |
|
196 middleButtonMenu notNil ifTrue:[ |
|
197 middleButtonMenu enable:#doIt. |
|
198 " |
|
199 printit not allowed if readonly, since it pastes its result |
|
200 " |
|
201 readOnly ifTrue:[ |
|
202 middleButtonMenu disable:#printIt. |
|
203 ] ifFalse:[ |
|
204 middleButtonMenu enable:#printIt. |
|
205 ]. |
|
206 middleButtonMenu enable:#inspectIt |
|
207 ] |
|
208 ! ! |
|
209 |
|
210 !Workspace methodsFor:'accessing'! |
180 !Workspace methodsFor:'accessing'! |
211 |
181 |
212 doItAction:aBlock |
182 doItAction:aBlock |
213 "define the action to be performed when 'doIt' is selected" |
183 "define the action to be performed when 'doIt' is selected" |
214 |
184 |
363 endLine := selectionEndLine. |
333 endLine := selectionEndLine. |
364 endCol := selectionEndCol. |
334 endCol := selectionEndCol. |
365 cCol := cursorCol. |
335 cCol := cursorCol. |
366 cLine := cursorLine. |
336 cLine := cursorLine. |
367 |
337 |
|
338 " |
|
339 cleanup: restore previous selection and cursor positions |
|
340 " |
368 cleanUp := [ |
341 cleanUp := [ |
369 self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
342 self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
370 cLine notNil ifTrue:[ |
343 cLine notNil ifTrue:[ |
371 self cursorLine:cLine col:cCol |
344 self cursorLine:cLine col:cCol |
372 ]. |
345 ]. |
373 ]. |
346 ]. |
374 |
347 |
|
348 " |
|
349 perform the action. |
|
350 Be careful to release the reference to the value; |
|
351 otherwise, we could keep lots of garbage from being freed |
|
352 until the view gets closed |
|
353 " |
375 self topView withCursor:Cursor execute do:[ |
354 self topView withCursor:Cursor execute do:[ |
376 Object abortSignal catch:[ |
355 [ |
377 [ |
356 AbortSignal handle:[:ex | |
|
357 ex return |
|
358 ] do:[ |
378 value := doItAction value:code asString. |
359 value := doItAction value:code asString. |
379 cleanUp value. |
360 cleanUp value. cleanUp := nil. |
380 aBlock value:value. |
361 aBlock value:value. |
381 value := nil. |
362 ] |
382 ] valueOnUnwindDo:cleanUp |
363 ] valueNowOrOnUnwindDo:[ |
|
364 cleanUp notNil ifTrue:[cleanUp value. cleanUp := nil]. |
|
365 value := nil |
383 ] |
366 ] |
384 ]. |
367 ]. |
385 ] |
368 ] |
386 ! |
369 ! |
387 |
370 |