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