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