author | Claus Gittinger <cg@exept.de> |
Mon, 23 Apr 2001 10:21:56 +0200 | |
changeset 2355 | 986d96f5ff6c |
parent 2338 | 4c67cec79a84 |
child 2386 | ace953bac401 |
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) |
|
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
307 |
buttonLabels:#('cancel' 'declare as...' 'correct...' 'continue') |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
308 |
values:#(#abort #declare #correct #continue) |
368 | 309 |
default:#continue. |
201 | 310 |
]. |
311 |
||
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
312 |
action == #declare ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
313 |
^ action |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
314 |
]. |
201 | 315 |
action == #abort ifTrue:[ |
368 | 316 |
Object abortSignal raise. |
317 |
^ false |
|
201 | 318 |
]. |
368 | 319 |
^ action == #correct |
320 |
||
321 |
"Modified: 20.2.1996 / 20:48:52 / cg" |
|
201 | 322 |
! |
323 |
||
2104 | 324 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
325 |
"compiler notifies us of a correctable selector warning; |
|
326 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
327 |
this method should return true to the compiler if user wants the error |
|
328 |
to be corrected; false otherwise" |
|
329 |
||
330 |
|action| |
|
331 |
||
332 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
333 |
action := OptionBox |
|
334 |
request:aString |
|
335 |
label:'Warning' |
|
336 |
form:(WarningBox iconBitmap) |
|
2338 | 337 |
buttonLabels:#('cancel' 'correct...' 'generate' 'continue') |
338 |
values:#(#abort #correct #generate #continue) |
|
2104 | 339 |
default:#continue. |
340 |
]. |
|
341 |
||
2338 | 342 |
action == #generate ifTrue:[ |
343 |
^ action |
|
344 |
]. |
|
345 |
||
2104 | 346 |
action == #abort ifTrue:[ |
347 |
Object abortSignal raise. |
|
348 |
^ false |
|
349 |
]. |
|
350 |
^ action == #correct |
|
351 |
||
352 |
"Modified: / 19.1.2000 / 16:26:39 / cg" |
|
353 |
"Created: / 19.1.2000 / 16:27:28 / cg" |
|
354 |
! |
|
355 |
||
201 | 356 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 357 |
"obsolete - no longer invoked" |
358 |
||
359 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
360 |
! |
|
361 |
||
362 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
363 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
|
364 |
and show a Box asking for continue/abort." |
|
365 |
||
366 |
^ self error:aString position:relPos to:relEndPos from:aCompiler asWarning:false |
|
367 |
! |
|
368 |
||
369 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
201 | 370 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
371 |
and show a Box asking for continue/abort." |
|
372 |
||
373 |
|answer| |
|
374 |
||
375 |
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
|
376 |
|box lbl| |
201 | 377 |
|
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 |
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
|
379 |
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
|
380 |
^ false |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
381 |
]. |
201 | 382 |
|
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
383 |
" |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
384 |
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
|
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 |
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
|
387 |
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
|
388 |
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
|
389 |
|
2277 | 390 |
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
|
391 |
asWarning ifTrue:[ |
2277 | 392 |
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
|
393 |
] ifFalse:[ |
2277 | 394 |
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
|
395 |
]. |
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
396 |
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
|
397 |
box form:(WarningBox iconBitmap). |
921 | 398 |
answer := box confirm. |
399 |
box destroy. |
|
201 | 400 |
]. |
401 |
||
402 |
" |
|
403 |
do the abort if we have to |
|
404 |
" |
|
405 |
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
|
406 |
Object abortSignal raise. |
201 | 407 |
]. |
408 |
^ 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
|
409 |
|
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
410 |
"Created: 24.11.1995 / 22:56:34 / cg" |
921 | 411 |
"Modified: 7.1.1997 / 23:00:45 / cg" |
201 | 412 |
! |
413 |
||
59 | 414 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
415 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 416 |
|
59 | 417 |
|absPosition fg bg| |
0 | 418 |
|
58 | 419 |
" |
420 |
change color of selection & hide cursor |
|
421 |
" |
|
0 | 422 |
fg := selectionFgColor. |
423 |
bg := selectionBgColor. |
|
424 |
selectionBgColor := errorBgColor. |
|
425 |
selectionFgColor := errorFgColor. |
|
58 | 426 |
self hideCursor. |
0 | 427 |
|
58 | 428 |
" |
429 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
430 |
we have to adjust the positions given by the compiler, since they |
|
431 |
are relative to the texts start (the compiler did stream-read the code). |
|
432 |
" |
|
0 | 433 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
434 |
absPosition := codeStartPosition + relPos - 1. |
|
435 |
relEndPos isNil ifTrue:[ |
|
59 | 436 |
self selectLineWhereCharacterPosition:absPosition |
0 | 437 |
] ifFalse:[ |
59 | 438 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + relEndPos - 1) |
0 | 439 |
]. |
440 |
self makeSelectionVisible. |
|
441 |
||
155 | 442 |
device flush. |
58 | 443 |
|
59 | 444 |
aBlock valueNowOrOnUnwindDo:[ |
445 |
" |
|
446 |
undo selection color change and show cursor again |
|
447 |
" |
|
448 |
selectionFgColor := fg. |
|
449 |
selectionBgColor := bg. |
|
450 |
self showCursor. |
|
0 | 451 |
]. |
452 |
! |
|
453 |
||
116 | 454 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 455 |
"compiler notifies us of a warning - same behavior as error" |
0 | 456 |
|
2277 | 457 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 458 |
! ! |
459 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
460 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
461 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
462 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
463 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
464 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 465 |
in the first col |
466 |
(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
|
467 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
468 |
|eolComment opening closing| |
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 := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
471 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
472 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
473 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
474 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
475 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
476 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
477 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
478 |
|l| |
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 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
481 |
l isNil ifTrue:[l := '']. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
482 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
483 |
l := eolComment , l |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
484 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
485 |
l := opening , l , closing |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
486 |
]. |
1903
86d3493c6a59
when commenting, do all without change notifications,
Claus Gittinger <cg@exept.de>
parents:
1901
diff
changeset
|
487 |
self at:lineNr basicPut:l |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
488 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
489 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
490 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
491 |
"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
|
492 |
"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
|
493 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
494 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
495 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
496 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
497 |
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
|
498 |
in the first col." |
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 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
501 |
|
1481 | 502 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
503 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
504 |
selectionStartLine notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
505 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
506 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
507 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
508 |
commentPair := commentStrings at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
509 |
opening := commentPair at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
510 |
closing := commentPair at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
511 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
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 |
e := selectionEndCol. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
514 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
515 |
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
|
516 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
517 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
518 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
519 |
self selectFromLine:selectionStartLine col:selectionStartCol |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
520 |
toLine:selectionEndLine col:e+closing size. |
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 |
] |
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 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 525 |
"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
|
526 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
527 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
528 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
529 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
530 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 531 |
in the first col. |
532 |
(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
|
533 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
534 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
535 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
536 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
537 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
538 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
539 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
540 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
541 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
542 |
rest := eolComment size + 1. |
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 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
546 |
|l| |
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 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
549 |
l notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
550 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
551 |
(l startsWith:eolComment) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
552 |
l := l copyFrom:rest |
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 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
555 |
((l startsWith:opening) |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
556 |
and:[l endsWith:closing]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
557 |
l := l copyFrom:opening size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
558 |
l := l copyWithoutLast:closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
559 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
560 |
]. |
1903
86d3493c6a59
when commenting, do all without change notifications,
Claus Gittinger <cg@exept.de>
parents:
1901
diff
changeset
|
561 |
self at:lineNr basicPut:l |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
562 |
] |
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 |
self textChanged. |
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 |
"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
|
567 |
"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
|
568 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
569 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
570 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
571 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
572 |
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
|
573 |
in the first col." |
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 |
|e commentPair opening closing sz1 sz2| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
576 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
577 |
selectionStartLine notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
578 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
579 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
580 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
581 |
commentPair := commentStrings at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
582 |
opening := commentPair at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
583 |
closing := commentPair at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
584 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
585 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
586 |
sz1 := opening size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
587 |
sz2 := closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
588 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
589 |
((self |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
590 |
stringAtLine:selectionStartLine |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
591 |
from:selectionStartCol |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
592 |
to:selectionStartCol+sz1 - 1) = opening |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
593 |
and:[(self |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
594 |
stringAtLine:selectionEndLine |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
595 |
from:selectionEndCol - sz2 + 1 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
596 |
to:selectionEndCol) = closing ]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
597 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
598 |
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
|
599 |
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
|
600 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
601 |
e := selectionEndCol - sz2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
602 |
selectionStartLine == selectionEndLine ifTrue:[e := e - sz1]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
603 |
self selectFromLine:selectionStartLine col:selectionStartCol |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
604 |
toLine:selectionEndLine col:e. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
605 |
] |
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 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
608 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
609 |
"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
|
610 |
"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
|
611 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
612 |
|
0 | 613 |
!Workspace methodsFor:'events'! |
614 |
||
615 |
keyPress:key x:x y:y |
|
132 | 616 |
|
2307 | 617 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #BrowseIt #'CmdF*' #'CtrlF*')> |
132 | 618 |
|
1968
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
619 |
|cmd fKey| |
60 | 620 |
|
32 | 621 |
(key == #DoIt) ifTrue:[^ self doIt]. |
23 | 622 |
(key == #InspectIt) ifTrue:[^ self inspectIt]. |
418 | 623 |
(key == #PrintIt) ifTrue:[^ self printIt]. |
2307 | 624 |
(key == #BrowseIt) ifTrue:[^ self browseIt]. |
38 | 625 |
|
626 |
" |
|
131 | 627 |
Ctrl-Fn or Cmd-Fn evaluates a key-sequence (n = 0..99) |
60 | 628 |
(I added Ctrl-Fn, because some windowmanagers already use cmd-fn) |
38 | 629 |
see TextView>>keyPress:x:y: |
630 |
" |
|
131 | 631 |
key isSymbol ifTrue:[ |
418 | 632 |
(key startsWith:'CmdF') ifTrue:[ |
633 |
fKey := key copyFrom:4 |
|
634 |
] ifFalse:[ |
|
635 |
(key startsWith:'CtrlF') ifTrue:[ |
|
636 |
fKey := key copyFrom:5 |
|
637 |
] |
|
638 |
]. |
|
131 | 639 |
]. |
640 |
fKey notNil ifTrue:[ |
|
418 | 641 |
fKey := fKey asSymbol. |
1968
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
642 |
cmd := UserPreferences current functionKeySequences at:fKey ifAbsent:nil. |
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
643 |
cmd notNil ifTrue:[ |
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
644 |
AbortSignal "ErrorSignal" handle:[:ex | |
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
645 |
self warn:'error occurred in keyboard macro'. |
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
646 |
ex return. |
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
647 |
] do:[ |
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
648 |
Parser evaluate:cmd asString |
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
649 |
receiver:self |
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
650 |
notifying:nil |
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
651 |
compile:false. |
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
652 |
]. |
5b466747dafe
ask UserPrefs for functionKeySequences (no need for a global)
Claus Gittinger <cg@exept.de>
parents:
1933
diff
changeset
|
653 |
^ self |
418 | 654 |
] |
38 | 655 |
]. |
656 |
||
0 | 657 |
super keyPress:key x:x y:y |
38 | 658 |
|
659 |
" |
|
418 | 660 |
example uses of function keys: |
38 | 661 |
|
662 |
to set tab-distance to 4-cols, |
|
663 |
select the following: |
|
664 |
||
665 |
self setTab4 |
|
666 |
||
667 |
then, press shift-F2 to define the sequence; |
|
95 | 668 |
press cmd-F2 to execute it |
38 | 669 |
voila: you have set 4-tabs. |
95 | 670 |
(some window managers (MWM, 4DWM have cmd-Fn redefined; use Ctrl-Fn then). |
38 | 671 |
|
672 |
to switch back, perform the same procedure with: |
|
673 |
||
418 | 674 |
self setTab8 |
38 | 675 |
|
60 | 676 |
Within the expression, 'self' is bound to the view. Thus, you can do |
677 |
all kinds of fancy things. |
|
678 |
For example: |
|
95 | 679 |
if you like a browser to come up on the selection when pressing Cmd-F3: |
60 | 680 |
select: |
38 | 681 |
|
418 | 682 |
|sel| |
683 |
sel := self selection asString withoutSeparators. |
|
684 |
(Smalltalk includesKey:sel asSymbol) ifTrue:[ |
|
685 |
(Smalltalk at:sel asSymbol) isClass ifTrue:[ |
|
686 |
SystemBrowser browseClass:(Smalltalk at:sel asSymbol) |
|
687 |
] |
|
688 |
] |
|
38 | 689 |
|
690 |
then, press shift-F3 to define the command. |
|
691 |
press cmd-F3 to execute it (select some classname before). |
|
60 | 692 |
(notice: on the Indy, Cmd-F3 is already used by the window manager) |
38 | 693 |
|
95 | 694 |
if you like a file-include command on Cmd-F4: |
38 | 695 |
select: |
696 |
||
418 | 697 |
|sel| |
698 |
sel := self selection. |
|
699 |
sel notNil ifTrue:[ |
|
700 |
sel := sel asString withoutSeparators. |
|
701 |
s := FileStream readonlyFileNamed:sel. |
|
702 |
s notNil ifTrue:[ |
|
703 |
self paste:(s contents asString). |
|
704 |
s close |
|
705 |
] |
|
706 |
] |
|
38 | 707 |
|
708 |
this will paste the contents of the file at the current cusor position. |
|
60 | 709 |
(select above expression, press Shift-F4, |
710 |
then select any filename and press Cmd-F4) |
|
418 | 711 |
try it here: /etc/passwd |
38 | 712 |
" |
418 | 713 |
|
922 | 714 |
"Modified: 9.1.1997 / 12:18:30 / cg" |
0 | 715 |
! ! |
201 | 716 |
|
2143 | 717 |
!Workspace methodsFor:'executing'! |
201 | 718 |
|
1501 | 719 |
do:code withValueDo:aBlock |
418 | 720 |
"helper for doIt, printIt and inspectIt. |
721 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
722 |
aBlock with the value. |
|
723 |
Most work is in preparing for proper cleanup in case of abort |
|
724 |
or other exception while the evaluation is performed. |
|
725 |
(restore cursor, selectionColors etc.)" |
|
201 | 726 |
|
1501 | 727 |
|selLine selCol endLine endCol cLine cCol cleanUp| |
201 | 728 |
|
729 |
code notNil ifTrue:[ |
|
257 | 730 |
codeStartPosition := self characterPositionOfSelection. |
201 | 731 |
|
257 | 732 |
" |
733 |
remember selection for later - if there is an error, |
|
734 |
the notification method will highlight it. |
|
735 |
thus destroying the current selection |
|
736 |
" |
|
737 |
selLine := selectionStartLine. |
|
738 |
selCol := selectionStartCol. |
|
739 |
endLine := selectionEndLine. |
|
740 |
endCol := selectionEndCol. |
|
741 |
cCol := cursorCol. |
|
742 |
cLine := cursorLine. |
|
201 | 743 |
|
257 | 744 |
" |
745 |
cleanup: restore previous selection and cursor positions |
|
746 |
" |
|
747 |
cleanUp := [ |
|
748 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
749 |
cLine notNil ifTrue:[ |
|
750 |
self cursorLine:cLine col:cCol |
|
751 |
]. |
|
752 |
]. |
|
201 | 753 |
|
257 | 754 |
" |
755 |
perform the action. |
|
756 |
Be careful to release the reference to the value; |
|
757 |
otherwise, we could keep lots of garbage from being freed |
|
758 |
until the view gets closed |
|
759 |
" |
|
760 |
self topView withExecuteCursorDo:[ |
|
761 |
[ |
|
762 |
AbortSignal handle:[:ex | |
|
763 |
ex return |
|
764 |
] do:[ |
|
929 | 765 |
|value| |
766 |
||
257 | 767 |
doItAction notNil ifTrue:[ |
929 | 768 |
value := doItAction value:(code asString). |
257 | 769 |
cleanUp value. cleanUp := nil. |
770 |
aBlock value:value. |
|
771 |
] |
|
772 |
] |
|
773 |
] valueNowOrOnUnwindDo:[ |
|
929 | 774 |
cleanUp notNil ifTrue:[ |
775 |
cleanUp value. cleanUp := nil |
|
776 |
]. |
|
257 | 777 |
] |
778 |
]. |
|
201 | 779 |
] |
257 | 780 |
|
1501 | 781 |
"Modified: / 11.1.1997 / 20:56:30 / cg" |
782 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
|
783 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
201 | 784 |
! ! |
785 |
||
786 |
!Workspace methodsFor:'initialize / release'! |
|
787 |
||
788 |
initStyle |
|
966 | 789 |
"setup viewStyle specifics" |
790 |
||
201 | 791 |
super initStyle. |
792 |
||
793 |
errorFgColor := DefaultErrorForegroundColor. |
|
794 |
errorFgColor isNil ifTrue:[errorFgColor := selectionFgColor]. |
|
795 |
errorBgColor := DefaultErrorBackgroundColor. |
|
796 |
errorBgColor isNil ifTrue:[ |
|
966 | 797 |
device hasColors ifTrue:[ |
798 |
errorBgColor := Color red |
|
799 |
] ifFalse:[ |
|
800 |
errorBgColor := selectionBgColor |
|
801 |
] |
|
201 | 802 |
]. |
966 | 803 |
|
804 |
"Modified: 22.1.1997 / 11:58:00 / cg" |
|
201 | 805 |
! |
806 |
||
807 |
initialize |
|
808 |
super initialize. |
|
809 |
||
810 |
showMatchingParenthesis := true. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
811 |
commentStrings := #( |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
812 |
'"/' |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
813 |
('"' '"') |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
814 |
). |
201 | 815 |
|
816 |
self initializeDoITAction. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
817 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
818 |
"Modified: / 9.11.1997 / 01:10:18 / cg" |
201 | 819 |
! |
820 |
||
821 |
initializeDoITAction |
|
822 |
"set up the block to be evaluated for doIts. |
|
823 |
This is done here in a separate method to allow easier |
|
824 |
redefinition in subclasses" |
|
825 |
||
826 |
doItAction := [:theCode | |
|
2303 | 827 |
self compilerClass |
828 |
evaluate:theCode |
|
829 |
in:nil |
|
830 |
receiver:nil |
|
831 |
notifying:self |
|
832 |
logged:true |
|
833 |
ifFail:nil |
|
201 | 834 |
]. |
835 |
! ! |
|
836 |
||
418 | 837 |
!Workspace methodsFor:'menu & menu actions'! |
838 |
||
2285 | 839 |
browseClass |
840 |
"user selected 'browseClass' from menu; evaluate the code |
|
841 |
and open a browser on the resulting class (if it evaluates to one)" |
|
842 |
||
843 |
^ self |
|
844 |
do:(self selection) |
|
845 |
withValueDo:[:result | result isBehavior ifTrue:[ |
|
846 |
SystemBrowser openInClass:result selector:nil |
|
847 |
] ifFalse:[ |
|
848 |
self warn:'Selection does not evaluate to a class' |
|
849 |
] |
|
850 |
]. |
|
851 |
||
852 |
! |
|
853 |
||
2307 | 854 |
browseIt |
855 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
856 |
or the class of the resulting object (if it does not evaluate to a class)" |
|
857 |
||
858 |
^ self |
|
859 |
do:(self selection) |
|
860 |
withValueDo:[:result | result isBehavior ifTrue:[ |
|
861 |
SystemBrowser openInClass:result selector:nil |
|
862 |
] ifFalse:[ |
|
863 |
SystemBrowser openInClass:(result class) selector:nil |
|
864 |
] |
|
865 |
]. |
|
866 |
! |
|
867 |
||
2285 | 868 |
browseItsClass |
869 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
870 |
and open a browser on the results class" |
|
871 |
||
872 |
^ self |
|
873 |
do:(self selection) |
|
874 |
withValueDo:[:result | SystemBrowser openInClass:result class selector:nil] |
|
875 |
||
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 |
||
489 | 893 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
894 |
<resource: #programMenu> |
489 | 895 |
|
2285 | 896 |
|m idx sensor s| |
418 | 897 |
|
898 |
m := super editMenu. |
|
899 |
||
1516 | 900 |
((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[ |
2326
1e2cf91fc2fa
browse does both browse & browse-its-class
Claus Gittinger <cg@exept.de>
parents:
2307
diff
changeset
|
901 |
m addLabels:(resources array:#('-' 'commentIt' 'uncommentIt' '-' 'browse' '-' 'timeIt' 'spyOnIt')) |
1e2cf91fc2fa
browse does both browse & browse-its-class
Claus Gittinger <cg@exept.de>
parents:
2307
diff
changeset
|
902 |
selectors:#(nil commentSelection uncommentSelection nil browseIt nil timeIt spyOnIt) |
2285 | 903 |
accelerators:#(nil CommentSelection UncommentSelection nil nil nil nil nil nil) |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
904 |
after:#again. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
905 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
906 |
self hasSelection ifFalse:[ |
2326
1e2cf91fc2fa
browse does both browse & browse-its-class
Claus Gittinger <cg@exept.de>
parents:
2307
diff
changeset
|
907 |
m disableAll:#(browseIt commentSelection uncommentSelection timeIt spyOnIt) |
2285 | 908 |
"/ ] ifTrue:[ |
909 |
"/ s := self selectionAsString. |
|
910 |
"/ (s knownAsSymbol |
|
911 |
"/ and:[(Smalltalk includesKey:(s := s asSymbol)) |
|
912 |
"/ and:[(Smalltalk at:s) isBehavior]]) |
|
913 |
"/ ifFalse:[ |
|
914 |
"/ m disableAll:#(browseClass). |
|
915 |
"/ ] |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
916 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
917 |
^ m |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
918 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
919 |
|
418 | 920 |
" |
921 |
workspaces support #doIt, #printIt and #inspectIt |
|
922 |
add them after paste. |
|
923 |
" |
|
924 |
idx := m indexOf:#paste. |
|
925 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
926 |
idx ~~ 0 ifTrue:[ |
|
430 | 927 |
m addLabels:(resources array:#('-' 'doIt' 'printIt' 'inspectIt')) |
928 |
selectors:#(nil doIt printIt inspectIt) |
|
922 | 929 |
accelerators:#(nil #DoIt #PrintIt #InspectIt) |
2277 | 930 |
after:idx. |
931 |
||
418 | 932 |
]. |
933 |
||
934 |
self hasSelection ifFalse:[ |
|
430 | 935 |
m disableAll:#(printIt doIt inspectIt) |
418 | 936 |
]. |
937 |
||
938 |
^ m. |
|
430 | 939 |
|
1501 | 940 |
"Modified: / 22.4.1998 / 21:49:06 / ca" |
1516 | 941 |
"Modified: / 7.5.1998 / 02:47:00 / cg" |
418 | 942 |
! |
943 |
||
944 |
inspectIt |
|
945 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
946 |
and start an inspector on the result" |
|
947 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
948 |
^ self |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
949 |
do:(self selection) |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
950 |
withValueDo:[:result | result inspect] |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
951 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
952 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 953 |
! |
954 |
||
955 |
printIt |
|
956 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
957 |
and insert result of evaluation into my text. |
|
958 |
If the text is readOnly, do nothing." |
|
959 |
||
1734 | 960 |
self isReadOnly ifTrue:[ |
693 | 961 |
self beep |
418 | 962 |
] ifFalse:[ |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
963 |
self |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
964 |
do:(self selection) |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
965 |
withValueDo:[:result | |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
966 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
967 |
self insertSelectedStringAtCursor:(result displayString "printString") |
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
968 |
] |
418 | 969 |
] |
970 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
971 |
"Modified: / 16.5.1998 / 16:44:44 / cg" |
1501 | 972 |
! |
973 |
||
974 |
spyOnIt |
|
975 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
976 |
and finally restore cursor; return result of evaluation" |
|
977 |
||
978 |
|code| |
|
979 |
||
980 |
code := 'MessageTally spyOn:[' , self selection asString string, ']'. |
|
981 |
self do:code withValueDo:[:result | ] |
|
982 |
||
983 |
"Modified: / 22.4.1998 / 22:03:53 / ca" |
|
984 |
! |
|
985 |
||
986 |
timeIt |
|
987 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
988 |
and finally restore cursor; return result of evaluation" |
|
989 |
||
990 |
|code| |
|
991 |
||
992 |
code := '|t| t := Time millisecondsToRun:[' , self selection asString string, ']. |
|
993 |
Transcript showCR:''execution time: '' , t printString , '' ms''.'. |
|
994 |
self do:code withValueDo:[:result | ] |
|
995 |
||
996 |
"Modified: / 22.4.1998 / 22:03:51 / ca" |
|
418 | 997 |
! ! |
998 |
||
206 | 999 |
!Workspace class methodsFor:'documentation'! |
1000 |
||
1001 |
version |
|
2338 | 1002 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.82 2001-01-11 11:17:38 cg Exp $' |
858 | 1003 |
! ! |