author | Claus Gittinger <cg@exept.de> |
Mon, 03 Dec 2001 15:24:57 +0100 | |
changeset 2489 | 6b1404066087 |
parent 2487 | 47e0a1faf544 |
child 2492 | 740174c1be0f |
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 |
||
2277 | 13 |
"{ Package: 'stx:libwidg' }" |
14 |
||
0 | 15 |
TextCollector subclass:#Workspace |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
16 |
instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
17 |
commentStrings' |
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
18 |
classVariableNames:'DefaultErrorForegroundColor DefaultErrorBackgroundColor |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
19 |
WorkspaceVariables' |
257 | 20 |
poolDictionaries:'' |
2097 | 21 |
category:'Interface-Smalltalk' |
0 | 22 |
! |
23 |
||
32 | 24 |
!Workspace class methodsFor:'documentation'! |
25 |
||
38 | 26 |
copyright |
27 |
" |
|
28 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 29 |
All Rights Reserved |
38 | 30 |
|
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
32 | 40 |
documentation |
41 |
" |
|
42 |
a view for editable text which can evaluate expressions. |
|
38 | 43 |
I.e. its basically a view for editable text, with added |
44 |
'doIt', 'printIt' and 'inspectIt' functions on the popup-menu. |
|
125 | 45 |
|
38 | 46 |
The action to be performed on doIt is defined by a block, |
58 | 47 |
which can be defined by the owner of this view. |
60 | 48 |
(thus you can put a workspace into more complex widgets, and |
49 |
control what should happen on 'doIt'). |
|
58 | 50 |
|
578 | 51 |
A useful default action is automatically defined, which simply |
52 |
evaluates the selection as a smalltalk expression. |
|
53 |
(but, a lisp or prolog workspace would define its own action, |
|
54 |
to call for another compiler/interpreter ...) |
|
32 | 55 |
|
123 | 56 |
|
57 |
Caveat: |
|
418 | 58 |
in this version, Workspace does not yet support doIt in MVC setups. |
59 |
For now, simulate this by setting the doItAction, to notify the |
|
60 |
model manually about the doIt. |
|
123 | 61 |
|
62 |
||
578 | 63 |
[instance variables:] |
32 | 64 |
|
121 | 65 |
doItAction <Block> block to evaluate for doIt |
123 | 66 |
|
121 | 67 |
errorFgColor <Color> fg-Color to be used when highlighting errors |
68 |
||
69 |
errorBgColor <Color> bg-Color to be used when highlighting errors |
|
58 | 70 |
|
578 | 71 |
codeStartPosition private temporary |
121 | 72 |
|
578 | 73 |
|
74 |
[styleSheet values:] |
|
121 | 75 |
|
76 |
codeErrorSelectionForegroundColor fg color to highlight errors |
|
418 | 77 |
(default: selection fg) |
78 |
||
121 | 79 |
codeErrorSelectionBackgroundColor bg color to highlight errors |
418 | 80 |
(default: selection bg) |
578 | 81 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
82 |
[start with:] |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
83 |
Workspace open |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
84 |
|
578 | 85 |
[see also:] |
86 |
Workspace EditTextView |
|
87 |
Parser ByteCodeCompiler |
|
583 | 88 |
|
89 |
[author:] |
|
90 |
Claus Gittinger |
|
32 | 91 |
" |
201 | 92 |
! ! |
93 |
||
94 |
!Workspace class methodsFor:'defaults'! |
|
95 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
96 |
defaultLabel |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
97 |
"my default window label" |
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 |
^ 'Workspace' |
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 |
"Created: / 16.5.1998 / 16:53:37 / cg" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
102 |
! |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
103 |
|
201 | 104 |
updateStyleCache |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
105 |
"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
|
106 |
|
1354 | 107 |
<resource: #style (#'codeErrorSelection.foregroundColor' |
108 |
#'codeErrorSelection.backgroundColor')> |
|
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
109 |
|
1354 | 110 |
DefaultErrorForegroundColor := StyleSheet colorAt:'codeErrorSelection.foregroundColor'. |
111 |
DefaultErrorBackgroundColor := StyleSheet colorAt:'codeErrorSelection.backgroundColor'. |
|
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
112 |
|
1354 | 113 |
"Modified: 20.10.1997 / 14:06:18 / cg" |
32 | 114 |
! ! |
115 |
||
0 | 116 |
!Workspace class methodsFor:'getting a System Workspace'! |
117 |
||
32 | 118 |
open |
0 | 119 |
"launch a new workspace" |
120 |
||
418 | 121 |
|scr topView workspace f| |
0 | 122 |
|
418 | 123 |
topView := StandardSystemView |
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
124 |
label:(self classResources string:(self defaultLabel)) |
1901
b3556ff49778
removed minExtent - let topView decide.
Claus Gittinger <cg@exept.de>
parents:
1738
diff
changeset
|
125 |
" minExtent:(100 @ 100)". |
23 | 126 |
|
418 | 127 |
scr := HVScrollableView for:self in:topView. |
128 |
scr origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
129 |
workspace := scr scrolledView. |
|
0 | 130 |
|
418 | 131 |
"/ adjust topViews extent according to my font |
132 |
||
0 | 133 |
f := workspace font. |
134 |
topView extent:((f widthOf:'x') * 40) @ (f height * 10). |
|
7 | 135 |
topView open. |
131 | 136 |
^ workspace |
0 | 137 |
|
58 | 138 |
" |
139 |
Workspace open |
|
140 |
" |
|
418 | 141 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
142 |
"Modified: / 16.5.1998 / 16:53:53 / cg" |
857 | 143 |
! |
144 |
||
145 |
openForRemote:hostName |
|
146 |
"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
|
147 |
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
|
148 |
and the result is shown here. |
857 | 149 |
This requires the RemoteObjects package to be loaded." |
150 |
||
151 |
|server remoteCompiler workspace| |
|
152 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
153 |
RemoteObjectServer isNil ifTrue:[ |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
154 |
self warn:'no remoteObjectServer available'. |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
155 |
^ nil |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
156 |
]. |
857 | 157 |
|
158 |
server := RemoteObjectServer on:hostName. |
|
159 |
remoteCompiler := server get:#Compiler. |
|
160 |
||
161 |
workspace := self open. |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
162 |
workspace topView |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
163 |
label:(self classResources string:'Remote Workspace {%1}' with:hostName). |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
164 |
|
857 | 165 |
workspace doItAction: |
166 |
[:theCode | |
|
167 |
remoteCompiler |
|
168 |
evaluate:theCode |
|
169 |
in:nil |
|
170 |
receiver:nil |
|
171 |
notifying:workspace |
|
172 |
logged:true |
|
173 |
ifFail:nil |
|
174 |
] |
|
175 |
" |
|
176 |
Workspace openForRemote:'andi' |
|
177 |
" |
|
178 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
179 |
"Modified: / 16.5.1998 / 16:57:38 / cg" |
0 | 180 |
! ! |
181 |
||
1523
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
182 |
!Workspace class methodsFor:'queries'! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
183 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
184 |
isVisualStartable |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
185 |
"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
|
186 |
(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
|
187 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
188 |
^ self == Workspace |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
189 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
190 |
"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
|
191 |
"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
|
192 |
! ! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
193 |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
194 |
!Workspace class methodsFor:'workspace variables'! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
195 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
196 |
addWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
197 |
"create a new workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
198 |
|
1933 | 199 |
|holder| |
200 |
||
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
201 |
WorkspaceVariables isNil ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
202 |
WorkspaceVariables := Dictionary new. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
203 |
]. |
1933 | 204 |
WorkspaceVariables at:name put:(holder := ValueHolder new). |
205 |
^ holder |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
206 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
207 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
208 |
removeAllWorkspaceVariables |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
209 |
"delete all workspace variables" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
210 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
211 |
WorkspaceVariables := nil |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
212 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
213 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
214 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
215 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
216 |
removeWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
217 |
"delete a workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
218 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
219 |
WorkspaceVariables notNil ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
220 |
WorkspaceVariables removeKey:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
221 |
WorkspaceVariables isEmpty ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
222 |
WorkspaceVariables := nil |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
223 |
] |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
224 |
]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
225 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
226 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
227 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
228 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
229 |
workspaceVariableAt:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
230 |
"retrieve a workspace variable (actually, a holder onto it)" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
231 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
232 |
WorkspaceVariables isNil ifTrue:[^ nil]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
233 |
^ WorkspaceVariables at:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
234 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
235 |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
236 |
! |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
237 |
|
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
238 |
workspaceVariables |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
239 |
"retrieve the collection of workspace variables" |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
240 |
|
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
241 |
^ WorkspaceVariables |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
242 |
|
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
243 |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
244 |
! ! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
245 |
|
201 | 246 |
!Workspace methodsFor:'accessing'! |
0 | 247 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
248 |
commentStrings:anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
249 |
"define the comment strings" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
250 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
251 |
commentStrings := anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
252 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
253 |
"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
|
254 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
255 |
|
201 | 256 |
doItAction |
257 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 258 |
|
201 | 259 |
^ doItAction |
0 | 260 |
! |
261 |
||
418 | 262 |
doItAction:aOneArgBlock |
263 |
"define the action to be performed when 'doIt' is selected. |
|
264 |
The block will be evaluated, passing the selection as a String argument. |
|
265 |
A default doItAction is set for you in the initialize method." |
|
0 | 266 |
|
418 | 267 |
doItAction := aOneArgBlock |
268 |
||
269 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
201 | 270 |
! ! |
271 |
||
272 |
!Workspace methodsFor:'compiler interface'! |
|
273 |
||
2303 | 274 |
compilerClass |
275 |
^ Compiler |
|
276 |
! |
|
277 |
||
201 | 278 |
currentSourceCode |
279 |
"special interface to compiler - called by parser |
|
280 |
to get the updated source code after a corrected error" |
|
281 |
||
282 |
^ self contents |
|
0 | 283 |
! |
284 |
||
201 | 285 |
wantChangeLog |
286 |
"sent by the compiler to ask if a changeLog entry should |
|
287 |
be written. Return true here." |
|
0 | 288 |
|
201 | 289 |
^ true |
0 | 290 |
! ! |
291 |
||
418 | 292 |
!Workspace methodsFor:'compiler interface - error handling'! |
0 | 293 |
|
201 | 294 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
295 |
"compiler notifies us of a correctable error; |
|
296 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
297 |
this method should return true to the compiler if user wants the error |
|
298 |
to be corrected; false otherwise" |
|
299 |
||
300 |
|action| |
|
301 |
||
302 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
368 | 303 |
action := OptionBox |
304 |
request:aString |
|
305 |
label:'Error' |
|
306 |
form:(WarningBox iconBitmap) |
|
2440 | 307 |
buttonLabels:#('Cancel' 'Declare as...' 'Correct...' 'Continue') |
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
308 |
values:#(#abort #declare #correct #continue) |
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
309 |
default:#continue |
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
310 |
onCancel:#abort. |
201 | 311 |
]. |
312 |
||
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
313 |
action == #declare ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
314 |
^ action |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
315 |
]. |
201 | 316 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
317 |
AbortOperationRequest raise. |
368 | 318 |
^ false |
201 | 319 |
]. |
368 | 320 |
^ action == #correct |
321 |
||
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
322 |
"Modified: / 16.11.2001 / 17:39:26 / cg" |
201 | 323 |
! |
324 |
||
2104 | 325 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
326 |
"compiler notifies us of a correctable selector warning; |
|
327 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
328 |
this method should return true to the compiler if user wants the error |
|
329 |
to be corrected; false otherwise" |
|
330 |
||
331 |
|action| |
|
332 |
||
333 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
334 |
action := OptionBox |
|
335 |
request:aString |
|
336 |
label:'Warning' |
|
337 |
form:(WarningBox iconBitmap) |
|
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
338 |
buttonLabels:(resources array:#('Cancel' 'Correct...' 'Generate' 'Continue')) |
2338 | 339 |
values:#(#abort #correct #generate #continue) |
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
340 |
default:#continue |
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
341 |
onCancel:#abort. |
2104 | 342 |
]. |
343 |
||
2338 | 344 |
action == #generate ifTrue:[ |
345 |
^ action |
|
346 |
]. |
|
347 |
||
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
348 |
(action isNil or:[action == #abort]) ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
349 |
AbortOperationRequest raise. |
2104 | 350 |
^ false |
351 |
]. |
|
352 |
^ action == #correct |
|
353 |
||
354 |
"Created: / 19.1.2000 / 16:27:28 / cg" |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
355 |
"Modified: / 16.11.2001 / 17:39:29 / cg" |
2104 | 356 |
! |
357 |
||
201 | 358 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 359 |
"obsolete - no longer invoked" |
360 |
||
361 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
362 |
! |
|
363 |
||
364 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
365 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
|
366 |
and show a Box asking for continue/abort." |
|
367 |
||
368 |
^ self error:aString position:relPos to:relEndPos from:aCompiler asWarning:false |
|
369 |
! |
|
370 |
||
371 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
201 | 372 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
373 |
and show a Box asking for continue/abort." |
|
374 |
||
375 |
|answer| |
|
376 |
||
377 |
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
|
378 |
|box lbl| |
201 | 379 |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
380 |
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
|
381 |
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
|
382 |
^ false |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
383 |
]. |
201 | 384 |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
385 |
" |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
386 |
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
|
387 |
" |
2400 | 388 |
box := YesNoBox |
389 |
title:aString |
|
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
390 |
yesText:(resources string:'Continue') |
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
391 |
noText:(resources string:'Abort'). |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
392 |
|
2277 | 393 |
lbl := aCompiler isNil ifTrue:['Compiler'] ifFalse:[aCompiler class name]. |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
394 |
asWarning ifTrue:[ |
2277 | 395 |
lbl := lbl , ' warning' |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
396 |
] ifFalse:[ |
2277 | 397 |
lbl := lbl , ' error'. |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
398 |
]. |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
399 |
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
|
400 |
box form:(WarningBox iconBitmap). |
921 | 401 |
answer := box confirm. |
402 |
box destroy. |
|
201 | 403 |
]. |
404 |
||
405 |
" |
|
406 |
do the abort if we have to |
|
407 |
" |
|
408 |
answer ifFalse:[ |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
409 |
AbortOperationRequest raise. |
201 | 410 |
]. |
411 |
^ 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
|
412 |
|
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
413 |
"Created: / 24.11.1995 / 22:56:34 / cg" |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
414 |
"Modified: / 16.11.2001 / 17:39:31 / cg" |
201 | 415 |
! |
416 |
||
59 | 417 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
418 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 419 |
|
59 | 420 |
|absPosition fg bg| |
0 | 421 |
|
58 | 422 |
" |
423 |
change color of selection & hide cursor |
|
424 |
" |
|
0 | 425 |
fg := selectionFgColor. |
426 |
bg := selectionBgColor. |
|
427 |
selectionBgColor := errorBgColor. |
|
428 |
selectionFgColor := errorFgColor. |
|
58 | 429 |
self hideCursor. |
0 | 430 |
|
58 | 431 |
" |
432 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
433 |
we have to adjust the positions given by the compiler, since they |
|
434 |
are relative to the texts start (the compiler did stream-read the code). |
|
435 |
" |
|
0 | 436 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
437 |
absPosition := codeStartPosition + relPos - 1. |
|
438 |
relEndPos isNil ifTrue:[ |
|
59 | 439 |
self selectLineWhereCharacterPosition:absPosition |
0 | 440 |
] ifFalse:[ |
59 | 441 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + relEndPos - 1) |
0 | 442 |
]. |
443 |
self makeSelectionVisible. |
|
444 |
||
155 | 445 |
device flush. |
58 | 446 |
|
59 | 447 |
aBlock valueNowOrOnUnwindDo:[ |
448 |
" |
|
449 |
undo selection color change and show cursor again |
|
450 |
" |
|
451 |
selectionFgColor := fg. |
|
452 |
selectionBgColor := bg. |
|
453 |
self showCursor. |
|
0 | 454 |
]. |
455 |
! |
|
456 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
457 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
458 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
459 |
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
|
460 |
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
|
461 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
462 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
463 |
|action| |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
464 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
465 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
466 |
action := OptionBox |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
467 |
request:aString |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
468 |
label:'Warning' |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
469 |
form:(WarningBox iconBitmap) |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
470 |
buttonLabels:#('Cancel' 'Remove Variable(s)' 'Continue') |
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
471 |
values:#(#abort #correct #continue) |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
472 |
default:#continue. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
473 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
474 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
475 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
476 |
AbortOperationRequest raise. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
477 |
^ false |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
478 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
479 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
480 |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
481 |
"Modified: / 16.11.2001 / 17:39:34 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
482 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
483 |
|
116 | 484 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 485 |
"compiler notifies us of a warning - same behavior as error" |
0 | 486 |
|
2277 | 487 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 488 |
! ! |
489 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
490 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
491 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
492 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
493 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
494 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 495 |
in the first col |
496 |
(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
|
497 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
498 |
|eolComment opening closing| |
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 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
501 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
502 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
503 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
504 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
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 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
507 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
508 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
509 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
510 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
511 |
l isNil ifTrue:[l := '']. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
512 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
513 |
l := eolComment , l |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
514 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
515 |
l := opening , l , closing |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
516 |
]. |
1903
86d3493c6a59
when commenting, do all without change notifications,
Claus Gittinger <cg@exept.de>
parents:
1901
diff
changeset
|
517 |
self at:lineNr basicPut:l |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
518 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
519 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
520 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
521 |
"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
|
522 |
"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
|
523 |
! |
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 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
526 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
527 |
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
|
528 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
529 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
530 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
531 |
|
1481 | 532 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
533 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
534 |
selectionStartLine notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
535 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
536 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
537 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
538 |
commentPair := commentStrings at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
539 |
opening := commentPair at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
540 |
closing := commentPair at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
541 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
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 |
e := selectionEndCol. |
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 |
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
|
546 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
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 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
549 |
self selectFromLine:selectionStartLine col:selectionStartCol |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
550 |
toLine:selectionEndLine col:e+closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
551 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
552 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
553 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
554 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 555 |
"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
|
556 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
557 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
558 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
559 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
560 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 561 |
in the first col. |
562 |
(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
|
563 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
564 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
565 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
566 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
567 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
568 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
569 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
570 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
571 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
572 |
rest := eolComment size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
573 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
574 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
575 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
576 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
577 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
578 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
579 |
l notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
580 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
581 |
(l startsWith:eolComment) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
582 |
l := l copyFrom:rest |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
583 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
584 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
585 |
((l startsWith:opening) |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
586 |
and:[l endsWith:closing]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
587 |
l := l copyFrom:opening size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
588 |
l := l copyWithoutLast:closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
589 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
590 |
]. |
1903
86d3493c6a59
when commenting, do all without change notifications,
Claus Gittinger <cg@exept.de>
parents:
1901
diff
changeset
|
591 |
self at:lineNr basicPut:l |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
592 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
593 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
594 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
595 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
596 |
"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
|
597 |
"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
|
598 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
599 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
600 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
601 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
602 |
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
|
603 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
604 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
605 |
|e commentPair opening closing sz1 sz2| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
606 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
607 |
selectionStartLine notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
608 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
609 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
610 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
611 |
commentPair := commentStrings at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
612 |
opening := commentPair at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
613 |
closing := commentPair at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
614 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
615 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
616 |
sz1 := opening size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
617 |
sz2 := closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
618 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
619 |
((self |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
620 |
stringAtLine:selectionStartLine |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
621 |
from:selectionStartCol |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
622 |
to:selectionStartCol+sz1 - 1) = opening |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
623 |
and:[(self |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
624 |
stringAtLine:selectionEndLine |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
625 |
from:selectionEndCol - sz2 + 1 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
626 |
to:selectionEndCol) = closing ]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
627 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
628 |
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
|
629 |
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
|
630 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
631 |
e := selectionEndCol - sz2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
632 |
selectionStartLine == selectionEndLine ifTrue:[e := e - sz1]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
633 |
self selectFromLine:selectionStartLine col:selectionStartCol |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
634 |
toLine:selectionEndLine col:e. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
635 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
636 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
637 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
638 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
639 |
"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
|
640 |
"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
|
641 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
642 |
|
0 | 643 |
!Workspace methodsFor:'events'! |
644 |
||
645 |
keyPress:key x:x y:y |
|
2418
bd16446247c5
lifted keyboardMacro handling to editTextView
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
646 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #BrowseIt)> |
60 | 647 |
|
32 | 648 |
(key == #DoIt) ifTrue:[^ self doIt]. |
23 | 649 |
(key == #InspectIt) ifTrue:[^ self inspectIt]. |
418 | 650 |
(key == #PrintIt) ifTrue:[^ self printIt]. |
2307 | 651 |
(key == #BrowseIt) ifTrue:[^ self browseIt]. |
38 | 652 |
|
0 | 653 |
super keyPress:key x:x y:y |
654 |
! ! |
|
201 | 655 |
|
2143 | 656 |
!Workspace methodsFor:'executing'! |
201 | 657 |
|
1501 | 658 |
do:code withValueDo:aBlock |
418 | 659 |
"helper for doIt, printIt and inspectIt. |
660 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
661 |
aBlock with the value. |
|
662 |
Most work is in preparing for proper cleanup in case of abort |
|
663 |
or other exception while the evaluation is performed. |
|
664 |
(restore cursor, selectionColors etc.)" |
|
201 | 665 |
|
1501 | 666 |
|selLine selCol endLine endCol cLine cCol cleanUp| |
201 | 667 |
|
668 |
code notNil ifTrue:[ |
|
2409 | 669 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
2408 | 670 |
|
257 | 671 |
codeStartPosition := self characterPositionOfSelection. |
201 | 672 |
|
257 | 673 |
" |
674 |
remember selection for later - if there is an error, |
|
675 |
the notification method will highlight it. |
|
676 |
thus destroying the current selection |
|
677 |
" |
|
678 |
selLine := selectionStartLine. |
|
679 |
selCol := selectionStartCol. |
|
680 |
endLine := selectionEndLine. |
|
681 |
endCol := selectionEndCol. |
|
682 |
cCol := cursorCol. |
|
683 |
cLine := cursorLine. |
|
201 | 684 |
|
257 | 685 |
" |
686 |
cleanup: restore previous selection and cursor positions |
|
687 |
" |
|
688 |
cleanUp := [ |
|
689 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
690 |
cLine notNil ifTrue:[ |
|
691 |
self cursorLine:cLine col:cCol |
|
692 |
]. |
|
693 |
]. |
|
201 | 694 |
|
257 | 695 |
" |
696 |
perform the action. |
|
697 |
Be careful to release the reference to the value; |
|
698 |
otherwise, we could keep lots of garbage from being freed |
|
699 |
until the view gets closed |
|
700 |
" |
|
701 |
self topView withExecuteCursorDo:[ |
|
702 |
[ |
|
703 |
AbortSignal handle:[:ex | |
|
704 |
ex return |
|
705 |
] do:[ |
|
929 | 706 |
|value| |
707 |
||
257 | 708 |
doItAction notNil ifTrue:[ |
929 | 709 |
value := doItAction value:(code asString). |
257 | 710 |
cleanUp value. cleanUp := nil. |
711 |
aBlock value:value. |
|
712 |
] |
|
713 |
] |
|
714 |
] valueNowOrOnUnwindDo:[ |
|
929 | 715 |
cleanUp notNil ifTrue:[ |
716 |
cleanUp value. cleanUp := nil |
|
717 |
]. |
|
257 | 718 |
] |
719 |
]. |
|
201 | 720 |
] |
257 | 721 |
|
1501 | 722 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
723 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
2409 | 724 |
"Modified: / 26.9.2001 / 17:32:59 / cg" |
201 | 725 |
! ! |
726 |
||
727 |
!Workspace methodsFor:'initialize / release'! |
|
728 |
||
729 |
initStyle |
|
966 | 730 |
"setup viewStyle specifics" |
731 |
||
201 | 732 |
super initStyle. |
733 |
||
734 |
errorFgColor := DefaultErrorForegroundColor. |
|
735 |
errorFgColor isNil ifTrue:[errorFgColor := selectionFgColor]. |
|
736 |
errorBgColor := DefaultErrorBackgroundColor. |
|
737 |
errorBgColor isNil ifTrue:[ |
|
966 | 738 |
device hasColors ifTrue:[ |
739 |
errorBgColor := Color red |
|
740 |
] ifFalse:[ |
|
741 |
errorBgColor := selectionBgColor |
|
742 |
] |
|
201 | 743 |
]. |
966 | 744 |
|
745 |
"Modified: 22.1.1997 / 11:58:00 / cg" |
|
201 | 746 |
! |
747 |
||
748 |
initialize |
|
749 |
super initialize. |
|
750 |
||
751 |
showMatchingParenthesis := true. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
752 |
commentStrings := #( |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
753 |
'"/' |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
754 |
('"' '"') |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
755 |
). |
201 | 756 |
|
757 |
self initializeDoITAction. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
758 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
759 |
"Modified: / 9.11.1997 / 01:10:18 / cg" |
201 | 760 |
! |
761 |
||
762 |
initializeDoITAction |
|
763 |
"set up the block to be evaluated for doIts. |
|
764 |
This is done here in a separate method to allow easier |
|
765 |
redefinition in subclasses" |
|
766 |
||
767 |
doItAction := [:theCode | |
|
2303 | 768 |
self compilerClass |
769 |
evaluate:theCode |
|
770 |
in:nil |
|
771 |
receiver:nil |
|
772 |
notifying:self |
|
773 |
logged:true |
|
774 |
ifFail:nil |
|
201 | 775 |
]. |
776 |
! ! |
|
777 |
||
418 | 778 |
!Workspace methodsFor:'menu & menu actions'! |
779 |
||
2285 | 780 |
browseClass |
781 |
"user selected 'browseClass' from menu; evaluate the code |
|
782 |
and open a browser on the resulting class (if it evaluates to one)" |
|
783 |
||
784 |
^ self |
|
785 |
do:(self selection) |
|
786 |
withValueDo:[:result | result isBehavior ifTrue:[ |
|
2410 | 787 |
result browserClass openInClass:result selector:nil |
2285 | 788 |
] ifFalse:[ |
789 |
self warn:'Selection does not evaluate to a class' |
|
790 |
] |
|
791 |
]. |
|
792 |
||
2410 | 793 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 794 |
! |
795 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
796 |
browseImplementorsOfIt |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
797 |
"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
|
798 |
|
2489 | 799 |
|sel sel2| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
800 |
|
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
801 |
sel := self selectionAsString. |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
802 |
sel size > 0 ifTrue:[ |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
803 |
self windowGroup withWaitCursorDo:[ |
2489 | 804 |
sel2 := Parser selectorInExpression:sel. |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
805 |
(UserPreferences current systemBrowserClass) |
2489 | 806 |
browseImplementorsOf:(sel2 ? sel) |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
807 |
] |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
808 |
]. |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
809 |
|
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
810 |
"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
|
811 |
"Modified: / 19.11.2001 / 22:15:17 / cg" |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
812 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
813 |
|
2307 | 814 |
browseIt |
815 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
816 |
or the class of the resulting object (if it does not evaluate to a class)" |
|
817 |
||
818 |
^ self |
|
819 |
do:(self selection) |
|
820 |
withValueDo:[:result | result isBehavior ifTrue:[ |
|
2410 | 821 |
result browserClass openInClass:result selector:nil |
2307 | 822 |
] ifFalse:[ |
2410 | 823 |
result class browserClass openInClass:(result class) selector:nil |
2307 | 824 |
] |
825 |
]. |
|
2410 | 826 |
|
827 |
"Modified: / 26.9.2001 / 17:37:50 / cg" |
|
2307 | 828 |
! |
829 |
||
2285 | 830 |
browseItsClass |
831 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
832 |
and open a browser on the results class" |
|
833 |
||
834 |
^ self |
|
835 |
do:(self selection) |
|
2410 | 836 |
withValueDo:[:result | |
837 |
result class browserClass openInClass:result class selector:nil |
|
838 |
] |
|
2285 | 839 |
|
2410 | 840 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 841 |
! |
842 |
||
2454 | 843 |
browseReferencesToIt |
844 |
"open a browser on all references to the selected global" |
|
845 |
||
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
846 |
|sel| |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
847 |
|
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
848 |
sel := self selectionAsString. |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
849 |
sel size > 0 ifTrue:[ |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
850 |
self windowGroup withWaitCursorDo:[ |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
851 |
(UserPreferences current systemBrowserClass) |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
852 |
browseReferendsOf:sel |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
853 |
]. |
2454 | 854 |
]. |
855 |
||
856 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
857 |
"Modified: / 5.11.2001 / 17:32:38 / cg" |
|
858 |
! |
|
859 |
||
2462 | 860 |
browseSendersOfIt |
861 |
"open a browser on the senders of the selected text" |
|
862 |
||
2489 | 863 |
|sel sel2| |
2462 | 864 |
|
865 |
sel := self selectionAsString. |
|
866 |
sel size > 0 ifTrue:[ |
|
867 |
self windowGroup withWaitCursorDo:[ |
|
2489 | 868 |
sel2 := Parser selectorInExpression:sel. |
2462 | 869 |
(UserPreferences current systemBrowserClass) |
2489 | 870 |
browseAllCallsOn:(sel2 ? sel) |
2462 | 871 |
] |
872 |
]. |
|
873 |
||
874 |
"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
|
875 |
"Modified: / 19.11.2001 / 22:15:27 / cg" |
2462 | 876 |
! |
877 |
||
418 | 878 |
doIt |
879 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
880 |
and finally restore cursor; return result of evaluation" |
|
881 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
882 |
^ self |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
883 |
do:(self selection) |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
884 |
withValueDo:[:result | ] |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
885 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
886 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 887 |
! |
888 |
||
889 |
editMenu |
|
1107 | 890 |
"return my popUpMenu; thats the superclasses menu |
891 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
|
892 |
||
2459 | 893 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
894 |
#CommentSelection #UncommentSelection |
|
895 |
)> |
|
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
896 |
<resource: #programMenu> |
489 | 897 |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
898 |
|m sub idx sensor s s2| |
418 | 899 |
|
900 |
m := super editMenu. |
|
2459 | 901 |
((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[ |
902 |
sub := m. |
|
903 |
m := nil. |
|
904 |
] ifFalse:[ |
|
905 |
sub := m subMenuAt:#others. |
|
906 |
]. |
|
418 | 907 |
|
2459 | 908 |
sub notNil ifTrue:[ |
909 |
" |
|
910 |
workspaces support #browse, implementors etc. |
|
911 |
add them after paste. |
|
912 |
" |
|
913 |
sub addLabels:(resources array:#( |
|
2454 | 914 |
'-' |
915 |
'Browse' |
|
916 |
'Implementors of It' |
|
2461 | 917 |
'Senders of It' |
2454 | 918 |
'References to It' |
919 |
'-' |
|
920 |
'TimeIt' |
|
2461 | 921 |
'SpyOnIt' |
922 |
'-' |
|
923 |
'Comment' |
|
924 |
'Uncomment' )) |
|
925 |
selectors:#(nil browseIt browseImplementorsOfIt browseSendersOfIt browseReferencesToIt |
|
926 |
nil timeIt spyOnIt |
|
927 |
nil commentSelection uncommentSelection) |
|
928 |
accelerators:#(nil nil nil nil nil nil nil nil nil nil CommentSelection UncommentSelection) |
|
2459 | 929 |
after:#gotoLine. |
1395
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 |
self hasSelection ifFalse:[ |
2461 | 932 |
sub disableAll:#(browseIt browseImplementorsOfIt browseSendersOfIt browseReferencesToIt timeIt spyOnIt |
933 |
commentSelection uncommentSelection ) |
|
2454 | 934 |
] ifTrue:[ |
935 |
s := self selectionAsString. |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
936 |
s2 := Parser selectorInExpression:s. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
937 |
s2 notNil ifTrue:[ |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
938 |
s2 := s2 asSymbolIfInterned. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
939 |
]. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
940 |
s notNil ifTrue:[ |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
941 |
s := s asSymbolIfInterned. |
2454 | 942 |
]. |
2487
47e0a1faf544
disabling of impl/senders menu
Claus Gittinger <cg@exept.de>
parents:
2485
diff
changeset
|
943 |
(s2 isNil and:[s isNil]) ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
944 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
945 |
]. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
946 |
(s isNil |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
947 |
or:[(Smalltalk includesKey:s) not]) |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
948 |
ifTrue:[ |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
949 |
sub disable:#browseReferencesToIt. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
950 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
951 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
952 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
953 |
|
2459 | 954 |
m notNil ifTrue:[ |
955 |
" |
|
956 |
workspaces support #doIt, #printIt and #inspectIt |
|
957 |
add them after paste. |
|
958 |
" |
|
959 |
idx := m indexOf:#paste. |
|
960 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
961 |
idx ~~ 0 ifTrue:[ |
|
962 |
m addLabels:(resources array:#('-' 'DoIt' 'PrintIt' 'InspectIt')) |
|
963 |
selectors:#(nil doIt printIt inspectIt) |
|
964 |
accelerators:#(nil #DoIt #PrintIt #InspectIt) |
|
965 |
after:idx. |
|
966 |
||
967 |
]. |
|
968 |
||
969 |
self hasSelection ifFalse:[ |
|
970 |
m disableAll:#(printIt doIt inspectIt) |
|
971 |
]. |
|
418 | 972 |
]. |
973 |
||
2459 | 974 |
^ m ? sub. |
430 | 975 |
|
1501 | 976 |
"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
|
977 |
"Modified: / 19.11.2001 / 23:12:01 / cg" |
418 | 978 |
! |
979 |
||
980 |
inspectIt |
|
981 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
982 |
and start an inspector on the result" |
|
983 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
984 |
^ self |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
985 |
do:(self selection) |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
986 |
withValueDo:[:result | result inspect] |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
987 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
988 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 989 |
! |
990 |
||
991 |
printIt |
|
992 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
993 |
and insert result of evaluation into my text. |
|
994 |
If the text is readOnly, do nothing." |
|
995 |
||
1734 | 996 |
self isReadOnly ifTrue:[ |
693 | 997 |
self beep |
418 | 998 |
] ifFalse:[ |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
999 |
self |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1000 |
do:(self selection) |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1001 |
withValueDo:[:result | |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1002 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1003 |
self insertSelectedStringAtCursor:(result displayString "printString") |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1004 |
] |
418 | 1005 |
] |
1006 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1007 |
"Modified: / 16.5.1998 / 16:44:44 / cg" |
1501 | 1008 |
! |
1009 |
||
1010 |
spyOnIt |
|
1011 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
1012 |
and finally restore cursor; return result of evaluation" |
|
1013 |
||
1014 |
|code| |
|
1015 |
||
1016 |
code := 'MessageTally spyOn:[' , self selection asString string, ']'. |
|
1017 |
self do:code withValueDo:[:result | ] |
|
1018 |
||
1019 |
"Modified: / 22.4.1998 / 22:03:53 / ca" |
|
1020 |
! |
|
1021 |
||
1022 |
timeIt |
|
1023 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
1024 |
and finally restore cursor; return result of evaluation" |
|
1025 |
||
1026 |
|code| |
|
1027 |
||
1028 |
code := '|t| t := Time millisecondsToRun:[' , self selection asString string, ']. |
|
1029 |
Transcript showCR:''execution time: '' , t printString , '' ms''.'. |
|
1030 |
self do:code withValueDo:[:result | ] |
|
1031 |
||
1032 |
"Modified: / 22.4.1998 / 22:03:51 / ca" |
|
418 | 1033 |
! ! |
1034 |
||
206 | 1035 |
!Workspace class methodsFor:'documentation'! |
1036 |
||
1037 |
version |
|
2489 | 1038 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.105 2001-12-03 14:24:57 cg Exp $' |
858 | 1039 |
! ! |