author | Claus Gittinger <cg@exept.de> |
Sat, 26 Jun 1999 15:49:19 +0200 | |
changeset 1930 | 5852350f36f4 |
parent 1925 | e73fe37177a0 |
child 1931 | 06cbb886dd10 |
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 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
14 |
instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
15 |
commentStrings' |
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
16 |
classVariableNames:'DefaultErrorForegroundColor DefaultErrorBackgroundColor |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
17 |
WorkspaceVariables' |
257 | 18 |
poolDictionaries:'' |
19 |
category:'Interface-Workspace' |
|
0 | 20 |
! |
21 |
||
32 | 22 |
!Workspace class methodsFor:'documentation'! |
23 |
||
38 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 27 |
All Rights Reserved |
38 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
32 | 38 |
documentation |
39 |
" |
|
40 |
a view for editable text which can evaluate expressions. |
|
38 | 41 |
I.e. its basically a view for editable text, with added |
42 |
'doIt', 'printIt' and 'inspectIt' functions on the popup-menu. |
|
125 | 43 |
|
38 | 44 |
The action to be performed on doIt is defined by a block, |
58 | 45 |
which can be defined by the owner of this view. |
60 | 46 |
(thus you can put a workspace into more complex widgets, and |
47 |
control what should happen on 'doIt'). |
|
58 | 48 |
|
578 | 49 |
A useful default action is automatically defined, which simply |
50 |
evaluates the selection as a smalltalk expression. |
|
51 |
(but, a lisp or prolog workspace would define its own action, |
|
52 |
to call for another compiler/interpreter ...) |
|
32 | 53 |
|
123 | 54 |
|
55 |
Caveat: |
|
418 | 56 |
in this version, Workspace does not yet support doIt in MVC setups. |
57 |
For now, simulate this by setting the doItAction, to notify the |
|
58 |
model manually about the doIt. |
|
123 | 59 |
|
60 |
||
578 | 61 |
[instance variables:] |
32 | 62 |
|
121 | 63 |
doItAction <Block> block to evaluate for doIt |
123 | 64 |
|
121 | 65 |
errorFgColor <Color> fg-Color to be used when highlighting errors |
66 |
||
67 |
errorBgColor <Color> bg-Color to be used when highlighting errors |
|
58 | 68 |
|
578 | 69 |
codeStartPosition private temporary |
121 | 70 |
|
578 | 71 |
|
72 |
[styleSheet values:] |
|
121 | 73 |
|
74 |
codeErrorSelectionForegroundColor fg color to highlight errors |
|
418 | 75 |
(default: selection fg) |
76 |
||
121 | 77 |
codeErrorSelectionBackgroundColor bg color to highlight errors |
418 | 78 |
(default: selection bg) |
578 | 79 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
80 |
[start with:] |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
81 |
Workspace open |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
82 |
|
578 | 83 |
[see also:] |
84 |
Workspace EditTextView |
|
85 |
Parser ByteCodeCompiler |
|
583 | 86 |
|
87 |
[author:] |
|
88 |
Claus Gittinger |
|
32 | 89 |
" |
201 | 90 |
! ! |
91 |
||
92 |
!Workspace class methodsFor:'defaults'! |
|
93 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
94 |
defaultLabel |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
95 |
"my default window label" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
96 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
97 |
^ 'Workspace' |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
98 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
99 |
"Created: / 16.5.1998 / 16:53:37 / cg" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
100 |
! |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
101 |
|
201 | 102 |
updateStyleCache |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
103 |
"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
|
104 |
|
1354 | 105 |
<resource: #style (#'codeErrorSelection.foregroundColor' |
106 |
#'codeErrorSelection.backgroundColor')> |
|
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
107 |
|
1354 | 108 |
DefaultErrorForegroundColor := StyleSheet colorAt:'codeErrorSelection.foregroundColor'. |
109 |
DefaultErrorBackgroundColor := StyleSheet colorAt:'codeErrorSelection.backgroundColor'. |
|
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
110 |
|
1354 | 111 |
"Modified: 20.10.1997 / 14:06:18 / cg" |
32 | 112 |
! ! |
113 |
||
0 | 114 |
!Workspace class methodsFor:'getting a System Workspace'! |
115 |
||
32 | 116 |
open |
0 | 117 |
"launch a new workspace" |
118 |
||
418 | 119 |
|scr topView workspace f| |
0 | 120 |
|
418 | 121 |
topView := StandardSystemView |
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
122 |
label:(self classResources string:(self defaultLabel)) |
1901
b3556ff49778
removed minExtent - let topView decide.
Claus Gittinger <cg@exept.de>
parents:
1738
diff
changeset
|
123 |
" minExtent:(100 @ 100)". |
23 | 124 |
|
418 | 125 |
scr := HVScrollableView for:self in:topView. |
126 |
scr origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
127 |
workspace := scr scrolledView. |
|
0 | 128 |
|
418 | 129 |
"/ adjust topViews extent according to my font |
130 |
||
0 | 131 |
f := workspace font. |
132 |
topView extent:((f widthOf:'x') * 40) @ (f height * 10). |
|
7 | 133 |
topView open. |
131 | 134 |
^ workspace |
0 | 135 |
|
58 | 136 |
" |
137 |
Workspace open |
|
138 |
" |
|
418 | 139 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
140 |
"Modified: / 16.5.1998 / 16:53:53 / cg" |
857 | 141 |
! |
142 |
||
143 |
openForRemote:hostName |
|
144 |
"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
|
145 |
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
|
146 |
and the result is shown here. |
857 | 147 |
This requires the RemoteObjects package to be loaded." |
148 |
||
149 |
|server remoteCompiler workspace| |
|
150 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
151 |
RemoteObjectServer isNil ifTrue:[ |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
152 |
self warn:'no remoteObjectServer available'. |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
153 |
^ nil |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
154 |
]. |
857 | 155 |
|
156 |
server := RemoteObjectServer on:hostName. |
|
157 |
remoteCompiler := server get:#Compiler. |
|
158 |
||
159 |
workspace := self open. |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
160 |
workspace topView |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
161 |
label:(self classResources string:'Remote Workspace {%1}' with:hostName). |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
162 |
|
857 | 163 |
workspace doItAction: |
164 |
[:theCode | |
|
165 |
remoteCompiler |
|
166 |
evaluate:theCode |
|
167 |
in:nil |
|
168 |
receiver:nil |
|
169 |
notifying:workspace |
|
170 |
logged:true |
|
171 |
ifFail:nil |
|
172 |
] |
|
173 |
" |
|
174 |
Workspace openForRemote:'andi' |
|
175 |
" |
|
176 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
177 |
"Modified: / 16.5.1998 / 16:57:38 / cg" |
0 | 178 |
! ! |
179 |
||
1523
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
180 |
!Workspace class methodsFor:'queries'! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
181 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
182 |
isVisualStartable |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
183 |
"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
|
184 |
(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
|
185 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
186 |
^ self == Workspace |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
187 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
188 |
"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
|
189 |
"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
|
190 |
! ! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
191 |
|
201 | 192 |
!Workspace methodsFor:'accessing'! |
0 | 193 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
194 |
commentStrings:anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
195 |
"define the comment strings" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
196 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
197 |
commentStrings := anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
198 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
199 |
"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
|
200 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
201 |
|
201 | 202 |
doItAction |
203 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 204 |
|
201 | 205 |
^ doItAction |
0 | 206 |
! |
207 |
||
418 | 208 |
doItAction:aOneArgBlock |
209 |
"define the action to be performed when 'doIt' is selected. |
|
210 |
The block will be evaluated, passing the selection as a String argument. |
|
211 |
A default doItAction is set for you in the initialize method." |
|
0 | 212 |
|
418 | 213 |
doItAction := aOneArgBlock |
214 |
||
215 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
201 | 216 |
! ! |
217 |
||
218 |
!Workspace methodsFor:'compiler interface'! |
|
219 |
||
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
220 |
addWorkspaceVariable:name |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
221 |
"create a new workspace variable" |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
222 |
|
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
223 |
WorkspaceVariables isNil ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
224 |
WorkspaceVariables := Dictionary new. |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
225 |
]. |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
226 |
WorkspaceVariables at:name put:(ValueHolder new). |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
227 |
! |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
228 |
|
201 | 229 |
currentSourceCode |
230 |
"special interface to compiler - called by parser |
|
231 |
to get the updated source code after a corrected error" |
|
232 |
||
233 |
^ self contents |
|
0 | 234 |
! |
235 |
||
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
236 |
removeAllWorkspaceVariables |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
237 |
"delete all workspace variables" |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
238 |
|
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
239 |
WorkspaceVariables := nil |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
240 |
! |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
241 |
|
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
242 |
removeWorkspaceVariable:name |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
243 |
"delete a workspace variable" |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
244 |
|
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
245 |
WorkspaceVariables notNil ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
246 |
WorkspaceVariables removeKey:name ifAbsent:nil. |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
247 |
WorkspaceVariables isEmpty ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
248 |
WorkspaceVariables := nil |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
249 |
] |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
250 |
]. |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
251 |
! |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
252 |
|
201 | 253 |
wantChangeLog |
254 |
"sent by the compiler to ask if a changeLog entry should |
|
255 |
be written. Return true here." |
|
0 | 256 |
|
201 | 257 |
^ true |
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
258 |
! |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
259 |
|
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
260 |
workspaceVariableAt:name |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
261 |
"retrieve a workspace variable (actually, a holder onto it)" |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
262 |
|
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
263 |
WorkspaceVariables isNil ifTrue:[^ nil]. |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
264 |
^ WorkspaceVariables at:name ifAbsent:nil. |
0 | 265 |
! ! |
266 |
||
418 | 267 |
!Workspace methodsFor:'compiler interface - error handling'! |
0 | 268 |
|
201 | 269 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
270 |
"compiler notifies us of a correctable error; |
|
271 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
272 |
this method should return true to the compiler if user wants the error |
|
273 |
to be corrected; false otherwise" |
|
274 |
||
275 |
|action| |
|
276 |
||
277 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
368 | 278 |
action := OptionBox |
279 |
request:aString |
|
280 |
label:'Error' |
|
281 |
form:(WarningBox iconBitmap) |
|
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
282 |
buttonLabels:#('cancel' 'declare as...' 'correct...' 'continue') |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
283 |
values:#(#abort #declare #correct #continue) |
368 | 284 |
default:#continue. |
201 | 285 |
]. |
286 |
||
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
287 |
action == #declare ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
288 |
^ action |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
289 |
]. |
201 | 290 |
action == #abort ifTrue:[ |
368 | 291 |
Object abortSignal raise. |
292 |
^ false |
|
201 | 293 |
]. |
368 | 294 |
^ action == #correct |
295 |
||
296 |
"Modified: 20.2.1996 / 20:48:52 / cg" |
|
201 | 297 |
! |
298 |
||
299 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
|
300 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
|
301 |
and show a Box asking for continue/abort." |
|
302 |
||
303 |
|answer| |
|
304 |
||
305 |
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
|
306 |
|box lbl| |
201 | 307 |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
308 |
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
|
309 |
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
|
310 |
^ false |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
311 |
]. |
201 | 312 |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
313 |
" |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
314 |
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
|
315 |
" |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
316 |
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
|
317 |
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
|
318 |
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
|
319 |
|
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
320 |
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
|
321 |
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
|
322 |
] ifFalse:[ |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
323 |
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
|
324 |
]. |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
325 |
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
|
326 |
box form:(WarningBox iconBitmap). |
921 | 327 |
answer := box confirm. |
328 |
box destroy. |
|
201 | 329 |
]. |
330 |
||
331 |
" |
|
332 |
do the abort if we have to |
|
333 |
" |
|
334 |
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
|
335 |
Object abortSignal raise. |
201 | 336 |
]. |
337 |
^ 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
|
338 |
|
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
339 |
"Created: 24.11.1995 / 22:56:34 / cg" |
921 | 340 |
"Modified: 7.1.1997 / 23:00:45 / cg" |
201 | 341 |
! |
342 |
||
343 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
344 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
|
345 |
and show a Box asking for continue/abort." |
|
346 |
||
347 |
^ self error:aString position:relPos to:relEndPos asWarning:false |
|
348 |
! |
|
349 |
||
59 | 350 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
351 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 352 |
|
59 | 353 |
|absPosition fg bg| |
0 | 354 |
|
58 | 355 |
" |
356 |
change color of selection & hide cursor |
|
357 |
" |
|
0 | 358 |
fg := selectionFgColor. |
359 |
bg := selectionBgColor. |
|
360 |
selectionBgColor := errorBgColor. |
|
361 |
selectionFgColor := errorFgColor. |
|
58 | 362 |
self hideCursor. |
0 | 363 |
|
58 | 364 |
" |
365 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
366 |
we have to adjust the positions given by the compiler, since they |
|
367 |
are relative to the texts start (the compiler did stream-read the code). |
|
368 |
" |
|
0 | 369 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
370 |
absPosition := codeStartPosition + relPos - 1. |
|
371 |
relEndPos isNil ifTrue:[ |
|
59 | 372 |
self selectLineWhereCharacterPosition:absPosition |
0 | 373 |
] ifFalse:[ |
59 | 374 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + relEndPos - 1) |
0 | 375 |
]. |
376 |
self makeSelectionVisible. |
|
377 |
||
155 | 378 |
device flush. |
58 | 379 |
|
59 | 380 |
aBlock valueNowOrOnUnwindDo:[ |
381 |
" |
|
382 |
undo selection color change and show cursor again |
|
383 |
" |
|
384 |
selectionFgColor := fg. |
|
385 |
selectionBgColor := bg. |
|
386 |
self showCursor. |
|
0 | 387 |
]. |
388 |
! |
|
389 |
||
116 | 390 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 391 |
"compiler notifies us of a warning - same behavior as error" |
0 | 392 |
|
95 | 393 |
self error:aString position:relPos to:relEndPos asWarning:true |
0 | 394 |
! ! |
395 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
396 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
397 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
398 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
399 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
400 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 401 |
in the first col |
402 |
(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
|
403 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
404 |
|eolComment opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
405 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
406 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
407 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
408 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
409 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
410 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
411 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
412 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
413 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
414 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
415 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
416 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
417 |
l isNil ifTrue:[l := '']. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
418 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
419 |
l := eolComment , l |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
420 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
421 |
l := opening , l , closing |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
422 |
]. |
1903
86d3493c6a59
when commenting, do all without change notifications,
Claus Gittinger <cg@exept.de>
parents:
1901
diff
changeset
|
423 |
self at:lineNr basicPut:l |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
424 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
425 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
426 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
427 |
"Modified: / 7.1.1997 / 20:15:06 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
428 |
"Created: / 9.11.1997 / 01:05:35 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
429 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
430 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
431 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
432 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
433 |
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
|
434 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
435 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
436 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
437 |
|
1481 | 438 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
439 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
440 |
selectionStartLine notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
441 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
442 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
443 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
444 |
commentPair := commentStrings at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
445 |
opening := commentPair at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
446 |
closing := commentPair at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
447 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
448 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
449 |
e := selectionEndCol. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
450 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
451 |
self insertString:closing atLine:selectionEndLine col:e+1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
452 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
453 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
454 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
455 |
self selectFromLine:selectionStartLine col:selectionStartCol |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
456 |
toLine:selectionEndLine col:e+closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
457 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
458 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
459 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
460 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 461 |
"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
|
462 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
463 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
464 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
465 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
466 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 467 |
in the first col. |
468 |
(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
|
469 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
470 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
471 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
472 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
473 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
474 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
475 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
476 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
477 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
478 |
rest := eolComment size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
479 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
480 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
481 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
482 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
483 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
484 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
485 |
l notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
486 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
487 |
(l startsWith:eolComment) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
488 |
l := l copyFrom:rest |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
489 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
490 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
491 |
((l startsWith:opening) |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
492 |
and:[l endsWith:closing]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
493 |
l := l copyFrom:opening size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
494 |
l := l copyWithoutLast:closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
495 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
496 |
]. |
1903
86d3493c6a59
when commenting, do all without change notifications,
Claus Gittinger <cg@exept.de>
parents:
1901
diff
changeset
|
497 |
self at:lineNr basicPut:l |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
498 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
499 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
500 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
501 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
502 |
"Modified: / 7.1.1997 / 20:17:44 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
503 |
"Created: / 9.11.1997 / 01:05:43 / cg" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
504 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
505 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
506 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
507 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
508 |
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
|
509 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
510 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
511 |
|e commentPair opening closing sz1 sz2| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
512 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
513 |
selectionStartLine notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
514 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
515 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
516 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
517 |
commentPair := commentStrings at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
518 |
opening := commentPair at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
519 |
closing := commentPair at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
520 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
521 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
522 |
sz1 := opening size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
523 |
sz2 := closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
524 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
525 |
((self |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
526 |
stringAtLine:selectionStartLine |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
527 |
from:selectionStartCol |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
528 |
to:selectionStartCol+sz1 - 1) = opening |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
529 |
and:[(self |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
530 |
stringAtLine:selectionEndLine |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
531 |
from:selectionEndCol - sz2 + 1 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
532 |
to:selectionEndCol) = closing ]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
533 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
534 |
self deleteCharsAtLine:selectionEndLine fromCol:selectionEndCol-sz2+1 toCol:selectionEndCol. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
535 |
self deleteCharsAtLine:selectionStartLine fromCol:selectionStartCol toCol:selectionStartCol+sz1-1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
536 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
537 |
e := selectionEndCol - sz2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
538 |
selectionStartLine == selectionEndLine ifTrue:[e := e - sz1]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
539 |
self selectFromLine:selectionStartLine col:selectionStartCol |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
540 |
toLine:selectionEndLine col:e. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
541 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
542 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
543 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
544 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
545 |
"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
|
546 |
"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
|
547 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
548 |
|
0 | 549 |
!Workspace methodsFor:'events'! |
550 |
||
551 |
keyPress:key x:x y:y |
|
132 | 552 |
|
922 | 553 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #'CmdF*' #'CtrlF*')> |
132 | 554 |
|
131 | 555 |
|cmd commands fKey| |
60 | 556 |
|
32 | 557 |
(key == #DoIt) ifTrue:[^ self doIt]. |
23 | 558 |
(key == #InspectIt) ifTrue:[^ self inspectIt]. |
418 | 559 |
(key == #PrintIt) ifTrue:[^ self printIt]. |
38 | 560 |
|
561 |
" |
|
131 | 562 |
Ctrl-Fn or Cmd-Fn evaluates a key-sequence (n = 0..99) |
60 | 563 |
(I added Ctrl-Fn, because some windowmanagers already use cmd-fn) |
38 | 564 |
see TextView>>keyPress:x:y: |
565 |
" |
|
131 | 566 |
key isSymbol ifTrue:[ |
418 | 567 |
(key startsWith:'CmdF') ifTrue:[ |
568 |
fKey := key copyFrom:4 |
|
569 |
] ifFalse:[ |
|
570 |
(key startsWith:'CtrlF') ifTrue:[ |
|
571 |
fKey := key copyFrom:5 |
|
572 |
] |
|
573 |
]. |
|
131 | 574 |
]. |
575 |
fKey notNil ifTrue:[ |
|
418 | 576 |
fKey := fKey asSymbol. |
577 |
commands := Smalltalk at:#FunctionKeySequences ifAbsent:[nil]. |
|
578 |
commands notNil ifTrue:[ |
|
579 |
cmd := commands at:fKey ifAbsent:[nil]. |
|
580 |
cmd notNil ifTrue:[ |
|
581 |
AbortSignal "ErrorSignal" handle:[:ex | |
|
582 |
self warn:'error occurred in keyboard macro'. |
|
583 |
ex return. |
|
584 |
] do:[ |
|
585 |
Parser evaluate:cmd asString |
|
586 |
receiver:self |
|
587 |
notifying:nil |
|
588 |
compile:false. |
|
589 |
]. |
|
590 |
^ self |
|
591 |
] |
|
592 |
] |
|
38 | 593 |
]. |
594 |
||
0 | 595 |
super keyPress:key x:x y:y |
38 | 596 |
|
597 |
" |
|
418 | 598 |
example uses of function keys: |
38 | 599 |
|
600 |
to set tab-distance to 4-cols, |
|
601 |
select the following: |
|
602 |
||
603 |
self setTab4 |
|
604 |
||
605 |
then, press shift-F2 to define the sequence; |
|
95 | 606 |
press cmd-F2 to execute it |
38 | 607 |
voila: you have set 4-tabs. |
95 | 608 |
(some window managers (MWM, 4DWM have cmd-Fn redefined; use Ctrl-Fn then). |
38 | 609 |
|
610 |
to switch back, perform the same procedure with: |
|
611 |
||
418 | 612 |
self setTab8 |
38 | 613 |
|
60 | 614 |
Within the expression, 'self' is bound to the view. Thus, you can do |
615 |
all kinds of fancy things. |
|
616 |
For example: |
|
95 | 617 |
if you like a browser to come up on the selection when pressing Cmd-F3: |
60 | 618 |
select: |
38 | 619 |
|
418 | 620 |
|sel| |
621 |
sel := self selection asString withoutSeparators. |
|
622 |
(Smalltalk includesKey:sel asSymbol) ifTrue:[ |
|
623 |
(Smalltalk at:sel asSymbol) isClass ifTrue:[ |
|
624 |
SystemBrowser browseClass:(Smalltalk at:sel asSymbol) |
|
625 |
] |
|
626 |
] |
|
38 | 627 |
|
628 |
then, press shift-F3 to define the command. |
|
629 |
press cmd-F3 to execute it (select some classname before). |
|
60 | 630 |
(notice: on the Indy, Cmd-F3 is already used by the window manager) |
38 | 631 |
|
95 | 632 |
if you like a file-include command on Cmd-F4: |
38 | 633 |
select: |
634 |
||
418 | 635 |
|sel| |
636 |
sel := self selection. |
|
637 |
sel notNil ifTrue:[ |
|
638 |
sel := sel asString withoutSeparators. |
|
639 |
s := FileStream readonlyFileNamed:sel. |
|
640 |
s notNil ifTrue:[ |
|
641 |
self paste:(s contents asString). |
|
642 |
s close |
|
643 |
] |
|
644 |
] |
|
38 | 645 |
|
646 |
this will paste the contents of the file at the current cusor position. |
|
60 | 647 |
(select above expression, press Shift-F4, |
648 |
then select any filename and press Cmd-F4) |
|
418 | 649 |
try it here: /etc/passwd |
38 | 650 |
" |
418 | 651 |
|
922 | 652 |
"Modified: 9.1.1997 / 12:18:30 / cg" |
0 | 653 |
! ! |
201 | 654 |
|
655 |
!Workspace methodsFor:'execution'! |
|
656 |
||
1501 | 657 |
do:code withValueDo:aBlock |
418 | 658 |
"helper for doIt, printIt and inspectIt. |
659 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
660 |
aBlock with the value. |
|
661 |
Most work is in preparing for proper cleanup in case of abort |
|
662 |
or other exception while the evaluation is performed. |
|
663 |
(restore cursor, selectionColors etc.)" |
|
201 | 664 |
|
1501 | 665 |
|selLine selCol endLine endCol cLine cCol cleanUp| |
201 | 666 |
|
667 |
code notNil ifTrue:[ |
|
257 | 668 |
codeStartPosition := self characterPositionOfSelection. |
201 | 669 |
|
257 | 670 |
" |
671 |
remember selection for later - if there is an error, |
|
672 |
the notification method will highlight it. |
|
673 |
thus destroying the current selection |
|
674 |
" |
|
675 |
selLine := selectionStartLine. |
|
676 |
selCol := selectionStartCol. |
|
677 |
endLine := selectionEndLine. |
|
678 |
endCol := selectionEndCol. |
|
679 |
cCol := cursorCol. |
|
680 |
cLine := cursorLine. |
|
201 | 681 |
|
257 | 682 |
" |
683 |
cleanup: restore previous selection and cursor positions |
|
684 |
" |
|
685 |
cleanUp := [ |
|
686 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
687 |
cLine notNil ifTrue:[ |
|
688 |
self cursorLine:cLine col:cCol |
|
689 |
]. |
|
690 |
]. |
|
201 | 691 |
|
257 | 692 |
" |
693 |
perform the action. |
|
694 |
Be careful to release the reference to the value; |
|
695 |
otherwise, we could keep lots of garbage from being freed |
|
696 |
until the view gets closed |
|
697 |
" |
|
698 |
self topView withExecuteCursorDo:[ |
|
699 |
[ |
|
700 |
AbortSignal handle:[:ex | |
|
701 |
ex return |
|
702 |
] do:[ |
|
929 | 703 |
|value| |
704 |
||
257 | 705 |
doItAction notNil ifTrue:[ |
929 | 706 |
value := doItAction value:(code asString). |
257 | 707 |
cleanUp value. cleanUp := nil. |
708 |
aBlock value:value. |
|
709 |
] |
|
710 |
] |
|
711 |
] valueNowOrOnUnwindDo:[ |
|
929 | 712 |
cleanUp notNil ifTrue:[ |
713 |
cleanUp value. cleanUp := nil |
|
714 |
]. |
|
257 | 715 |
] |
716 |
]. |
|
201 | 717 |
] |
257 | 718 |
|
1501 | 719 |
"Modified: / 11.1.1997 / 20:56:30 / cg" |
720 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
|
721 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
201 | 722 |
! ! |
723 |
||
724 |
!Workspace methodsFor:'initialize / release'! |
|
725 |
||
726 |
initStyle |
|
966 | 727 |
"setup viewStyle specifics" |
728 |
||
201 | 729 |
super initStyle. |
730 |
||
731 |
errorFgColor := DefaultErrorForegroundColor. |
|
732 |
errorFgColor isNil ifTrue:[errorFgColor := selectionFgColor]. |
|
733 |
errorBgColor := DefaultErrorBackgroundColor. |
|
734 |
errorBgColor isNil ifTrue:[ |
|
966 | 735 |
device hasColors ifTrue:[ |
736 |
errorBgColor := Color red |
|
737 |
] ifFalse:[ |
|
738 |
errorBgColor := selectionBgColor |
|
739 |
] |
|
201 | 740 |
]. |
966 | 741 |
|
742 |
"Modified: 22.1.1997 / 11:58:00 / cg" |
|
201 | 743 |
! |
744 |
||
745 |
initialize |
|
746 |
super initialize. |
|
747 |
||
748 |
showMatchingParenthesis := true. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
749 |
commentStrings := #( |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
750 |
'"/' |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
751 |
('"' '"') |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
752 |
). |
201 | 753 |
|
754 |
self initializeDoITAction. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
755 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
756 |
"Modified: / 9.11.1997 / 01:10:18 / cg" |
201 | 757 |
! |
758 |
||
759 |
initializeDoITAction |
|
760 |
"set up the block to be evaluated for doIts. |
|
761 |
This is done here in a separate method to allow easier |
|
762 |
redefinition in subclasses" |
|
763 |
||
764 |
doItAction := [:theCode | |
|
765 |
Compiler |
|
766 |
evaluate:theCode |
|
767 |
in:nil |
|
768 |
receiver:nil |
|
769 |
notifying:self |
|
770 |
logged:true |
|
771 |
ifFail:nil |
|
772 |
]. |
|
773 |
! ! |
|
774 |
||
418 | 775 |
!Workspace methodsFor:'menu & menu actions'! |
776 |
||
777 |
doIt |
|
778 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
779 |
and finally restore cursor; return result of evaluation" |
|
780 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
781 |
^ self |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
782 |
do:(self selection) |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
783 |
withValueDo:[:result | ] |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
784 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
785 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 786 |
! |
787 |
||
788 |
editMenu |
|
1107 | 789 |
"return my popUpMenu; thats the superclasses menu |
790 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
|
791 |
||
489 | 792 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
793 |
<resource: #programMenu> |
489 | 794 |
|
1516 | 795 |
|m idx sensor| |
418 | 796 |
|
797 |
m := super editMenu. |
|
798 |
||
1516 | 799 |
((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[ |
1501 | 800 |
m addLabels:(resources array:#('-' 'commentIt' 'uncommentIt' '-' 'timeIt' 'spyOnIt')) |
801 |
selectors:#(nil commentSelection uncommentSelection nil timeIt spyOnIt) |
|
802 |
accelerators:#(nil CommentSelection UncommentSelection nil nil nil) |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
803 |
after:#again. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
804 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
805 |
self hasSelection ifFalse:[ |
1501 | 806 |
m disableAll:#(commentSelection uncommentSelection timeIt spyOnIt) |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
807 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
808 |
^ m |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
809 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
810 |
|
418 | 811 |
" |
812 |
workspaces support #doIt, #printIt and #inspectIt |
|
813 |
add them after paste. |
|
814 |
" |
|
815 |
idx := m indexOf:#paste. |
|
816 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
817 |
idx ~~ 0 ifTrue:[ |
|
430 | 818 |
m addLabels:(resources array:#('-' 'doIt' 'printIt' 'inspectIt')) |
819 |
selectors:#(nil doIt printIt inspectIt) |
|
922 | 820 |
accelerators:#(nil #DoIt #PrintIt #InspectIt) |
430 | 821 |
after:idx |
418 | 822 |
]. |
823 |
||
824 |
self hasSelection ifFalse:[ |
|
430 | 825 |
m disableAll:#(printIt doIt inspectIt) |
418 | 826 |
]. |
827 |
||
828 |
^ m. |
|
430 | 829 |
|
1501 | 830 |
"Modified: / 22.4.1998 / 21:49:06 / ca" |
1516 | 831 |
"Modified: / 7.5.1998 / 02:47:00 / cg" |
418 | 832 |
! |
833 |
||
834 |
inspectIt |
|
835 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
836 |
and start an inspector on the result" |
|
837 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
838 |
^ self |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
839 |
do:(self selection) |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
840 |
withValueDo:[:result | result inspect] |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
841 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
842 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 843 |
! |
844 |
||
845 |
printIt |
|
846 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
847 |
and insert result of evaluation into my text. |
|
848 |
If the text is readOnly, do nothing." |
|
849 |
||
1734 | 850 |
self isReadOnly ifTrue:[ |
693 | 851 |
self beep |
418 | 852 |
] ifFalse:[ |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
853 |
self |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
854 |
do:(self selection) |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
855 |
withValueDo:[:result | |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
856 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
857 |
self insertSelectedStringAtCursor:(result displayString "printString") |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
858 |
] |
418 | 859 |
] |
860 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
861 |
"Modified: / 16.5.1998 / 16:44:44 / cg" |
1501 | 862 |
! |
863 |
||
864 |
spyOnIt |
|
865 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
866 |
and finally restore cursor; return result of evaluation" |
|
867 |
||
868 |
|code| |
|
869 |
||
870 |
code := 'MessageTally spyOn:[' , self selection asString string, ']'. |
|
871 |
self do:code withValueDo:[:result | ] |
|
872 |
||
873 |
"Modified: / 22.4.1998 / 22:03:53 / ca" |
|
874 |
! |
|
875 |
||
876 |
timeIt |
|
877 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
878 |
and finally restore cursor; return result of evaluation" |
|
879 |
||
880 |
|code| |
|
881 |
||
882 |
code := '|t| t := Time millisecondsToRun:[' , self selection asString string, ']. |
|
883 |
Transcript showCR:''execution time: '' , t printString , '' ms''.'. |
|
884 |
self do:code withValueDo:[:result | ] |
|
885 |
||
886 |
"Modified: / 22.4.1998 / 22:03:51 / ca" |
|
418 | 887 |
! ! |
888 |
||
206 | 889 |
!Workspace class methodsFor:'documentation'! |
890 |
||
891 |
version |
|
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
892 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.69 1999-06-26 13:49:19 cg Exp $' |
858 | 893 |
! ! |