author | Claus Gittinger <cg@exept.de> |
Sat, 02 Jun 2012 00:39:47 +0200 | |
changeset 4427 | 9eb0f20e7ed8 |
parent 4416 | bbf807d487a0 |
child 4432 | 2eaf85d92e62 |
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 |
" |
|
2277 | 12 |
"{ Package: 'stx:libwidg' }" |
13 |
||
0 | 14 |
TextCollector subclass:#Workspace |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
15 |
instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor |
2679 | 16 |
commentStrings autoDefineWorkspaceVariables simulatedSelf |
3537 | 17 |
autoDefineVariables compilerClass allowValueDrop |
4391 | 18 |
poolsConsideredInDoIts namespaceForDoits' |
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
19 |
classVariableNames:'DefaultViewBackground DefaultErrorForegroundColor |
3007 | 20 |
DefaultErrorBackgroundColor DefaultWarningBackgroundColor |
3712 | 21 |
DefaultWarningForegroundColor WorkspaceVariables DoItHistory |
22 |
Sniplets' |
|
257 | 23 |
poolDictionaries:'' |
2097 | 24 |
category:'Interface-Smalltalk' |
0 | 25 |
! |
26 |
||
3155 | 27 |
Workspace comment:'declared from: ..\..\..\stx\libwidg\abbrev.stc' |
28 |
! |
|
29 |
||
32 | 30 |
!Workspace class methodsFor:'documentation'! |
31 |
||
38 | 32 |
copyright |
33 |
" |
|
34 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 35 |
All Rights Reserved |
38 | 36 |
|
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
! |
|
45 |
||
32 | 46 |
documentation |
47 |
" |
|
48 |
a view for editable text which can evaluate expressions. |
|
38 | 49 |
I.e. its basically a view for editable text, with added |
50 |
'doIt', 'printIt' and 'inspectIt' functions on the popup-menu. |
|
125 | 51 |
|
38 | 52 |
The action to be performed on doIt is defined by a block, |
58 | 53 |
which can be defined by the owner of this view. |
60 | 54 |
(thus you can put a workspace into more complex widgets, and |
55 |
control what should happen on 'doIt'). |
|
58 | 56 |
|
578 | 57 |
A useful default action is automatically defined, which simply |
58 |
evaluates the selection as a smalltalk expression. |
|
59 |
(but, a lisp or prolog workspace would define its own action, |
|
60 |
to call for another compiler/interpreter ...) |
|
32 | 61 |
|
123 | 62 |
|
63 |
Caveat: |
|
418 | 64 |
in this version, Workspace does not yet support doIt in MVC setups. |
65 |
For now, simulate this by setting the doItAction, to notify the |
|
66 |
model manually about the doIt. |
|
123 | 67 |
|
68 |
||
578 | 69 |
[instance variables:] |
32 | 70 |
|
121 | 71 |
doItAction <Block> block to evaluate for doIt |
123 | 72 |
|
121 | 73 |
errorFgColor <Color> fg-Color to be used when highlighting errors |
74 |
||
75 |
errorBgColor <Color> bg-Color to be used when highlighting errors |
|
58 | 76 |
|
578 | 77 |
codeStartPosition private temporary |
121 | 78 |
|
578 | 79 |
|
80 |
[styleSheet values:] |
|
121 | 81 |
|
82 |
codeErrorSelectionForegroundColor fg color to highlight errors |
|
418 | 83 |
(default: selection fg) |
84 |
||
121 | 85 |
codeErrorSelectionBackgroundColor bg color to highlight errors |
418 | 86 |
(default: selection bg) |
578 | 87 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
88 |
[start with:] |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
89 |
Workspace open |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
90 |
|
578 | 91 |
[see also:] |
92 |
Workspace EditTextView |
|
93 |
Parser ByteCodeCompiler |
|
583 | 94 |
|
95 |
[author:] |
|
96 |
Claus Gittinger |
|
32 | 97 |
" |
201 | 98 |
! ! |
99 |
||
3712 | 100 |
!Workspace class methodsFor:'accessing'! |
101 |
||
102 |
sniplets |
|
103 |
Sniplets isNil ifTrue:[ |
|
104 |
Sniplets := Dictionary new. |
|
3713 | 105 |
self initializeDefaultAbbreviations. |
3712 | 106 |
]. |
107 |
^ Sniplets |
|
3713 | 108 |
|
109 |
" |
|
110 |
Sniplets := nil |
|
111 |
" |
|
3712 | 112 |
! |
113 |
||
114 |
sniplets:something |
|
115 |
Sniplets := something. |
|
116 |
! ! |
|
117 |
||
201 | 118 |
!Workspace class methodsFor:'defaults'! |
119 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
120 |
defaultLabel |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
121 |
"my default window label" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
122 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
123 |
^ 'Workspace' |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
124 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
125 |
"Created: / 16.5.1998 / 16:53:37 / cg" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
126 |
! |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
127 |
|
3716 | 128 |
initializeDefaultAbbreviations |
3807 | 129 |
"default sniplets/abbreviations. TODO: save/load sniplets" |
3728 | 130 |
|
3735 | 131 |
"flush and reinitialize sniplets with: |
3807 | 132 |
Sniplets := Dictionary new. |
3741 | 133 |
" |
3807 | 134 |
"after a code change below, update with: |
135 |
self initializeDefaultAbbreviations. |
|
3735 | 136 |
" |
3807 | 137 |
|
138 |
#( |
|
139 |
't' 'true' |
|
140 |
'f' 'false' |
|
141 |
's' 'self' |
|
3876
38612526d6a2
sniplets: what was %p ? (noone knows)
Claus Gittinger <cg@exept.de>
parents:
3870
diff
changeset
|
142 |
'su' 'super' |
38612526d6a2
sniplets: what was %p ? (noone knows)
Claus Gittinger <cg@exept.de>
parents:
3870
diff
changeset
|
143 |
'ss' 'super ' |
3807 | 144 |
'n' 'nil' |
145 |
'y' 'yourself.' |
|
146 |
||
147 |
'in' 'isNil ' |
|
148 |
'nn' 'notNil ' |
|
149 |
'ie' 'isEmpty ' |
|
150 |
'ne' 'notEmpty ' |
|
151 |
'ien' 'isEmptyOrNil ' |
|
152 |
'nen' 'notEmptyOrNil ' |
|
153 |
||
4186
178e5a5da19b
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4185
diff
changeset
|
154 |
'it' 'ifTrue:[!!]' |
178e5a5da19b
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4185
diff
changeset
|
155 |
'if' 'ifFalse:[!!]' |
178e5a5da19b
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4185
diff
changeset
|
156 |
'itf' 'ifTrue:[!!] ifFalse:[]' |
178e5a5da19b
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4185
diff
changeset
|
157 |
'int' 'isNil ifTrue:[!!]' |
178e5a5da19b
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4185
diff
changeset
|
158 |
'inf' 'isNil ifFalse:[!!]' |
4158
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
159 |
'ints' 'isNil ifTrue:[^ self]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
160 |
'infs' 'isNil ifFalse:[^ self]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
161 |
'nnt' 'notNil ifTrue:[!!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
162 |
'nnf' 'notNil ifFalse:[!!]' |
4251
2e01c273519d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
163 |
'iet' 'isEmpty ifTrue:[!!]' |
2e01c273519d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
164 |
'net' 'notEmpty ifTrue:[!!]' |
2e01c273519d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
165 |
'ief' 'isEmpty ifFalse:[!!]' |
2e01c273519d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
166 |
'nef' 'notEmpty ifFalse:[!!]' |
3807 | 167 |
|
4185 | 168 |
'wt' 'whileTrue:[!!]' |
169 |
'wf' 'whileFalse:[!!]' |
|
3807 | 170 |
|
4185 | 171 |
'do' 'do:[:each |!!]' |
172 |
'd:' 'do:[:each |!!]' |
|
173 |
'kdo' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
174 |
'kvd' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
175 |
'kv:' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
4184
9879be399bcc
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4175
diff
changeset
|
176 |
'k:' 'keysDo:[:eachKey | !!]' |
4158
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
177 |
'dt' 'detect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
178 |
'de' 'detect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
179 |
'det' 'detect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
180 |
'dtn' 'detect:[:each | !!] ifNone:[]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
181 |
'cl' 'collect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
182 |
'co' 'collect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
183 |
'col' 'collect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
184 |
'sl' 'select:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
185 |
'se' 'select:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
186 |
'sel' 'select:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
187 |
'rj' 'reject:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
188 |
're' 'reject:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
189 |
'rej' 'reject:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
190 |
'inj' 'inject:!! into:[:accum :each | ]' |
3807 | 191 |
|
192 |
'ex' 'Error handle:[ex | !!] do:[]' |
|
4171
20a315cd98c4
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4170
diff
changeset
|
193 |
'sh' 'self halt' |
4186
178e5a5da19b
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4185
diff
changeset
|
194 |
'mt' 'MessageTally spyOn:[!!]' |
3807 | 195 |
|
4172
432d4d3f5717
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4171
diff
changeset
|
196 |
'ih' '!! ifTrue:[ self halt ].' |
3807 | 197 |
'ik' 'includesKey: #' |
198 |
'is' 'includesString: #' |
|
199 |
||
200 |
'af' 'asFilename ' |
|
201 |
'as' 'asString ' |
|
202 |
'aoc' 'asOrderedCollection ' |
|
203 |
||
204 |
'np' 'nextPut: ' |
|
205 |
'npa' 'nextPutAll: ' |
|
206 |
'npl' 'nextPutLine: ' |
|
207 |
||
208 |
'ps' 'printString' |
|
209 |
'sr' 'self subclassResponsibility' |
|
210 |
||
211 |
'ati' 'at:!! ifAbsent: ' |
|
212 |
'atip' 'at:!! ifAbsentPut:[ ] ' |
|
213 |
'ap' 'at:!! ' |
|
214 |
||
215 |
'st' 'Smalltalk' |
|
4158
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
216 |
'ts' 'Transcript showCR:''!!''' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
217 |
'trs' 'Transcript showCR:''!!''' |
3807 | 218 |
'abb' 'Workspace sniplets inspect' |
219 |
'ws' 'Delay waitForSeconds: 1' |
|
220 |
'wfs' 'Delay waitForSeconds: 1' |
|
221 |
'wfm' 'Delay waitForMilliseconds: 1000' |
|
222 |
'ini' 'initialize\ super initialize.\ ' |
|
223 |
'newi' 'new\ ^ super new initialize.' |
|
224 |
'upd' 'update:something with:aParameter from:changedObject\ !!\ ^ super update:something with:aParameter from:changedObject.' |
|
225 |
'OC' 'OrderedCollection' |
|
226 |
'oc' 'OrderedCollection' |
|
227 |
'SC' 'SortedCollection' |
|
228 |
'sc' 'SortedCollection' |
|
229 |
'D' 'Dictionary' |
|
230 |
'ID' 'IdentityDictionary' |
|
231 |
'Id' 'IdentityDictionary' |
|
232 |
'id' 'IdentityDictionary' |
|
233 |
'iD' 'IdentityDictionary' |
|
234 |
'OCn' 'OrderedCollection new.' |
|
235 |
'ocn' 'OrderedCollection new.' |
|
236 |
'SCn' 'SortedCollection new.' |
|
237 |
'IDn' 'IdentityDictionary new' |
|
238 |
'idn' 'IdentityDictionary new' |
|
239 |
'Dn' 'Dictionary new' |
|
240 |
'dn' 'Dictionary new' |
|
241 |
'Sn' 'Set new' |
|
242 |
'sn' 'Set new' |
|
243 |
'A' 'Array' |
|
244 |
'a' 'Array' |
|
245 |
'An' 'Array new:' |
|
246 |
'an' 'Array new:' |
|
247 |
'Aw' 'Array with:' |
|
248 |
'aw' 'Array with:' |
|
249 |
'Aww' 'Array with:!! with:' |
|
250 |
'sww' 'Array with:!! with:' |
|
251 |
'Awww' 'Array with:!! with: with:' |
|
252 |
'awww' 'Array with:!! with: with:' |
|
253 |
'Awwww' 'Array with:!! with: with: with:' |
|
254 |
'awwww' 'Array with:!! with: with: with:' |
|
255 |
'aw2' 'Array with:!! with:' |
|
256 |
'aw3' 'Array with:!! with: with:' |
|
257 |
'aw4' 'Array with:!! with: with: with:' |
|
258 |
'0' '(0.0 @ 0.0)' |
|
259 |
'1' '(1.0 @ 1.0)' |
|
260 |
'[' '[:!! ]' |
|
3876
38612526d6a2
sniplets: what was %p ? (noone knows)
Claus Gittinger <cg@exept.de>
parents:
3870
diff
changeset
|
261 |
'(' '(!! )' |
3807 | 262 |
|
263 |
"/ typos... |
|
264 |
'eslf' 'self' |
|
265 |
'slef' 'self' |
|
266 |
'sefl' 'self' |
|
267 |
'elf' 'self' |
|
268 |
'slf' 'self' |
|
269 |
'sef' 'self' |
|
270 |
||
271 |
'iftrue' 'ifTrue' |
|
272 |
'iffalse' 'ifFalse' |
|
273 |
'iftrue:' 'ifTrue:' |
|
274 |
'iffalse:' 'ifFalse:' |
|
275 |
) pairWiseDo:[:abbrev :text | |
|
276 |
Sniplets |
|
277 |
at:abbrev put:text "/ ifPresent:[ self error:'duplicate abbreviation key' ] |
|
278 |
]. |
|
4148
2fe252a82d5b
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4141
diff
changeset
|
279 |
|
4251
2e01c273519d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4250
diff
changeset
|
280 |
"Modified: / 12-05-2011 / 10:13:20 / cg" |
3716 | 281 |
! |
282 |
||
201 | 283 |
updateStyleCache |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
284 |
"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
|
285 |
|
1354 | 286 |
<resource: #style (#'codeErrorSelection.foregroundColor' |
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
287 |
#'codeErrorSelection.backgroundColor' |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
288 |
#'codeView.backgroundColor' )> |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
289 |
|
1354 | 290 |
DefaultErrorForegroundColor := StyleSheet colorAt:'codeErrorSelection.foregroundColor'. |
291 |
DefaultErrorBackgroundColor := StyleSheet colorAt:'codeErrorSelection.backgroundColor'. |
|
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
292 |
DefaultViewBackground := StyleSheet colorAt:'codeView.backgroundColor'. |
32 | 293 |
! ! |
294 |
||
2776 | 295 |
!Workspace class methodsFor:'getting a new Workspace'! |
0 | 296 |
|
32 | 297 |
open |
0 | 298 |
"launch a new workspace" |
299 |
||
418 | 300 |
|scr topView workspace f| |
0 | 301 |
|
418 | 302 |
topView := StandardSystemView |
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
303 |
label:(self classResources string:(self defaultLabel)) |
1901
b3556ff49778
removed minExtent - let topView decide.
Claus Gittinger <cg@exept.de>
parents:
1738
diff
changeset
|
304 |
" minExtent:(100 @ 100)". |
23 | 305 |
|
418 | 306 |
scr := HVScrollableView for:self in:topView. |
307 |
scr origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
308 |
workspace := scr scrolledView. |
|
0 | 309 |
|
418 | 310 |
"/ adjust topViews extent according to my font |
311 |
||
0 | 312 |
f := workspace font. |
313 |
topView extent:((f widthOf:'x') * 40) @ (f height * 10). |
|
7 | 314 |
topView open. |
131 | 315 |
^ workspace |
0 | 316 |
|
58 | 317 |
" |
318 |
Workspace open |
|
319 |
" |
|
418 | 320 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
321 |
"Modified: / 16.5.1998 / 16:53:53 / cg" |
857 | 322 |
! |
323 |
||
324 |
openForRemote:hostName |
|
325 |
"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
|
326 |
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
|
327 |
and the result is shown here. |
857 | 328 |
This requires the RemoteObjects package to be loaded." |
329 |
||
330 |
|server remoteCompiler workspace| |
|
331 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
332 |
RemoteObjectServer isNil ifTrue:[ |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
333 |
self warn:'no remoteObjectServer available'. |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
334 |
^ nil |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
335 |
]. |
857 | 336 |
|
337 |
server := RemoteObjectServer on:hostName. |
|
338 |
remoteCompiler := server get:#Compiler. |
|
339 |
||
340 |
workspace := self open. |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
341 |
workspace topView |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
342 |
label:(self classResources string:'Remote Workspace {%1}' with:hostName). |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
343 |
|
857 | 344 |
workspace doItAction: |
345 |
[:theCode | |
|
346 |
remoteCompiler |
|
347 |
evaluate:theCode |
|
348 |
in:nil |
|
349 |
receiver:nil |
|
350 |
notifying:workspace |
|
351 |
logged:true |
|
352 |
ifFail:nil |
|
353 |
] |
|
354 |
" |
|
355 |
Workspace openForRemote:'andi' |
|
356 |
" |
|
357 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
358 |
"Modified: / 16.5.1998 / 16:57:38 / cg" |
2686 | 359 |
! |
360 |
||
2794 | 361 |
openWith:initialText selected:selectedBoolean |
2686 | 362 |
"launch a new workspace with some initial contents" |
363 |
||
364 |
|workspace| |
|
365 |
||
366 |
workspace := self open. |
|
2794 | 367 |
workspace contents:initialText selected:selectedBoolean. |
2686 | 368 |
^ workspace |
369 |
||
370 |
" |
|
371 |
Workspace openWith:'Transcript showCR:''hello world''' |
|
372 |
" |
|
0 | 373 |
! ! |
374 |
||
2657 | 375 |
!Workspace class methodsFor:'history'! |
376 |
||
377 |
clearDoItHistory |
|
378 |
DoItHistory := nil |
|
379 |
! |
|
380 |
||
381 |
doItHistory |
|
382 |
^ DoItHistory |
|
383 |
! |
|
384 |
||
385 |
doItHistorySize |
|
386 |
"the number of remembered doIts" |
|
387 |
||
388 |
^ 20 |
|
389 |
! |
|
390 |
||
391 |
rememberDoIt:aString |
|
392 |
|string| |
|
393 |
||
394 |
string := aString asString string withoutSeparators. |
|
2726 | 395 |
(string asCollectionOfWords size <= 1) ifTrue:[ |
396 |
((Scanner new scanTokens:string) size <= 1) ifTrue:[ |
|
397 |
"its a variable only" |
|
398 |
^ self |
|
399 |
] |
|
400 |
]. |
|
2657 | 401 |
|
402 |
DoItHistory isNil ifTrue:[ |
|
403 |
DoItHistory := OrderedCollection new. |
|
404 |
]. |
|
405 |
DoItHistory remove:string ifAbsent:nil. |
|
406 |
DoItHistory addFirst:string. |
|
407 |
DoItHistory size > self doItHistorySize ifTrue:[ |
|
408 |
DoItHistory removeLast |
|
409 |
]. |
|
2726 | 410 |
|
411 |
Scanner |
|
2657 | 412 |
! ! |
413 |
||
1523
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
414 |
!Workspace class methodsFor:'queries'! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
415 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
416 |
isVisualStartable |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
417 |
"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
|
418 |
(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
|
419 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
420 |
^ self == Workspace |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
421 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
422 |
"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
|
423 |
"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
|
424 |
! ! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
425 |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
426 |
!Workspace class methodsFor:'workspace variables'! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
427 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
428 |
addWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
429 |
"create a new workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
430 |
|
1933 | 431 |
|holder| |
432 |
||
3325 | 433 |
holder := self workspaceVariables at:name ifAbsentPut:[ ValueHolder new ]. |
1933 | 434 |
^ holder |
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
435 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
436 |
|
3157 | 437 |
anyWorkspaceVariableIsDefined |
438 |
^ WorkspaceVariables notEmptyOrNil |
|
439 |
||
440 |
"Created: / 20-04-2005 / 11:57:53 / cg" |
|
441 |
! |
|
442 |
||
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
443 |
removeAllWorkspaceVariables |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
444 |
"delete all workspace variables" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
445 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
446 |
WorkspaceVariables := nil |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
447 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
448 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
449 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
450 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
451 |
removeWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
452 |
"delete a workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
453 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
454 |
WorkspaceVariables notNil ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
455 |
WorkspaceVariables removeKey:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
456 |
WorkspaceVariables isEmpty ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
457 |
WorkspaceVariables := nil |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
458 |
] |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
459 |
]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
460 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
461 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
462 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
463 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
464 |
workspaceVariableAt:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
465 |
"retrieve a workspace variable (actually, a holder onto it)" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
466 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
467 |
WorkspaceVariables isNil ifTrue:[^ nil]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
468 |
^ WorkspaceVariables at:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
469 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
470 |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
471 |
! |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
472 |
|
3157 | 473 |
workspaceVariableNames |
474 |
"retrieve the collection of workspace variable names" |
|
475 |
||
476 |
WorkspaceVariables isNil ifTrue:[^ #()]. |
|
477 |
^ WorkspaceVariables keys |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
478 |
|
3157 | 479 |
"Created: / 20-04-2005 / 11:42:45 / cg" |
480 |
! |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
481 |
|
3157 | 482 |
workspaceVariables |
483 |
"retrieve the collection of workspace variables. |
|
484 |
That is a dictionary associating names to values." |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
485 |
|
3325 | 486 |
WorkspaceVariables isNil ifTrue:[ |
487 |
WorkspaceVariables := Dictionary new. |
|
488 |
]. |
|
489 |
^ WorkspaceVariables |
|
3157 | 490 |
|
491 |
"Modified: / 20-04-2005 / 11:43:14 / cg" |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
492 |
! ! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
493 |
|
201 | 494 |
!Workspace methodsFor:'accessing'! |
0 | 495 |
|
3428 | 496 |
allowValueDrop:aBoolean |
497 |
"if on (the default), any smalltalk value can be dropped and leads to a workspace variable |
|
498 |
holding on to that being defined. Can be turned off, if youdont like this (for standAlone apps)" |
|
499 |
||
500 |
allowValueDrop := aBoolean. |
|
501 |
||
502 |
"Created: / 28-11-2006 / 16:13:02 / cg" |
|
503 |
! |
|
504 |
||
2679 | 505 |
autoDefineVariables |
4090 | 506 |
"undefined variables handling: |
507 |
are automatically defined as workspace variable if autoDefineVariables is #workspace. |
|
508 |
are automatically defined as doit variable if autoDefineVariables is #doit. |
|
509 |
are left undefined if autoDefineVariables is nil." |
|
510 |
||
2679 | 511 |
^ autoDefineVariables |
2535 | 512 |
! |
513 |
||
2679 | 514 |
autoDefineVariables:nilOrSymbol |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
515 |
"undefined variables handling: |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
516 |
are automatically defined as workspace variable if nilOrSymbol is #workspace. |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
517 |
are automatically defined as doit variable if nilOrSymbol is #doit. |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
518 |
are left undefined if nilOrSymbol is nil." |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
519 |
|
2679 | 520 |
autoDefineVariables := nilOrSymbol. |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
521 |
|
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
522 |
"Modified: / 28-11-2006 / 16:21:01 / cg" |
2679 | 523 |
! |
2535 | 524 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
525 |
commentStrings:anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
526 |
"define the comment strings" |
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 |
commentStrings := anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
529 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
530 |
"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
|
531 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
532 |
|
201 | 533 |
doItAction |
534 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 535 |
|
201 | 536 |
^ doItAction |
0 | 537 |
! |
538 |
||
3007 | 539 |
errorBackgroundColor |
540 |
errorBgColor notNil ifTrue:[ ^ errorBgColor ]. |
|
541 |
DefaultErrorBackgroundColor notNil ifTrue:[ ^ DefaultErrorBackgroundColor ]. |
|
542 |
device hasColors ifTrue:[ ^ Color red ]. |
|
543 |
||
544 |
^ selectionBgColor |
|
545 |
! |
|
546 |
||
547 |
errorForegroundColor |
|
548 |
errorFgColor notNil ifTrue:[ ^ errorFgColor ]. |
|
549 |
DefaultErrorForegroundColor notNil ifTrue:[ ^ DefaultErrorForegroundColor ]. |
|
550 |
^ selectionFgColor |
|
551 |
! |
|
552 |
||
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
553 |
hasSelectionOrTextInCursorLine |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
554 |
^ (self selectionOrTextOfCursorLine:false) notNil |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
555 |
! |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
556 |
|
4391 | 557 |
namespaceForDoits:aNameSpaceOrNil |
558 |
"can be used by the embedding application to control doIt execution |
|
559 |
(especially: for tools like expecco, to provide better workspaces" |
|
560 |
||
561 |
namespaceForDoits := aNameSpaceOrNil. |
|
562 |
||
563 |
"Created: / 04-03-2012 / 13:34:51 / cg" |
|
564 |
! |
|
565 |
||
566 |
poolsConsideredInDoIts:aCollectionOfPools |
|
567 |
"can be used by the embedding application to control doIt execution |
|
568 |
(especially: for tools like expecco, to provide better workspaces" |
|
569 |
||
570 |
poolsConsideredInDoIts := aCollectionOfPools. |
|
571 |
||
572 |
"Modified (format): / 04-03-2012 / 13:35:00 / cg" |
|
3537 | 573 |
! |
574 |
||
3272 | 575 |
selectionOrTextOfCursorLine |
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
576 |
^ self selectionOrTextOfCursorLine:true |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
577 |
! |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
578 |
|
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
579 |
selectionOrTextOfCursorLine:doSelect |
3272 | 580 |
|sel lNr line| |
581 |
||
582 |
sel := self selectionAsString. |
|
583 |
sel notNil ifTrue:[^ sel]. |
|
584 |
||
585 |
lNr := self cursorLine. |
|
586 |
line := self listAt:lNr. |
|
587 |
line notEmptyOrNil ifTrue:[ |
|
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
588 |
doSelect ifTrue:[ |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
589 |
self selectLine:lNr. |
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
590 |
]. |
3272 | 591 |
^ line |
592 |
]. |
|
593 |
||
594 |
^ nil |
|
595 |
! |
|
596 |
||
2601 | 597 |
simulatedSelf:anObject |
598 |
"define what self is in an evaluation" |
|
599 |
||
600 |
simulatedSelf := anObject |
|
3007 | 601 |
! |
602 |
||
603 |
warningBackgroundColor |
|
604 |
DefaultWarningBackgroundColor notNil ifTrue:[ ^ DefaultWarningBackgroundColor ]. |
|
605 |
device hasColors ifTrue:[ ^ Color orange ]. |
|
606 |
||
607 |
^ selectionBgColor |
|
608 |
! |
|
609 |
||
610 |
warningForegroundColor |
|
611 |
DefaultWarningForegroundColor notNil ifTrue:[ ^ DefaultWarningForegroundColor ]. |
|
612 |
^ selectionFgColor |
|
201 | 613 |
! ! |
614 |
||
615 |
!Workspace methodsFor:'compiler interface'! |
|
616 |
||
2303 | 617 |
compilerClass |
2980 | 618 |
^ compilerClass ? Compiler |
619 |
! |
|
620 |
||
621 |
compilerClass:aCompilerClass |
|
622 |
compilerClass := aCompilerClass |
|
2303 | 623 |
! |
624 |
||
201 | 625 |
currentSourceCode |
626 |
"special interface to compiler - called by parser |
|
627 |
to get the updated source code after a corrected error" |
|
628 |
||
629 |
^ self contents |
|
0 | 630 |
! |
631 |
||
201 | 632 |
wantChangeLog |
633 |
"sent by the compiler to ask if a changeLog entry should |
|
634 |
be written. Return true here." |
|
0 | 635 |
|
201 | 636 |
^ true |
0 | 637 |
! ! |
638 |
||
2754 | 639 |
!Workspace methodsFor:'compiler interface-error handling'! |
0 | 640 |
|
201 | 641 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
642 |
"compiler notifies us of a correctable error; |
|
643 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
644 |
this method should return true to the compiler if user wants the error |
|
645 |
to be corrected; false otherwise" |
|
646 |
||
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
647 |
|action sameForAllHolder| |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
648 |
|
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
649 |
sameForAllHolder := false asValue. |
201 | 650 |
|
651 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
3383 | 652 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
653 |
|box declareButton| |
|
654 |
||
655 |
box := ex parameter. |
|
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
656 |
|
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
657 |
SameForAllNotification isHandled ifTrue:[ |
4386 | 658 |
box addCheckBoxAtBottom:'Same action for all' on:sameForAllHolder |
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
659 |
]. |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
660 |
|
3383 | 661 |
declareButton := box buttons at:2. |
662 |
declareButton pressAction:declareButton controller releaseAction. |
|
663 |
declareButton controller beTriggerOnDown. |
|
664 |
ex proceed. |
|
665 |
] do:[ |
|
666 |
action := OptionBox |
|
667 |
request:aString |
|
3592
cb6f9f060e62
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3579
diff
changeset
|
668 |
label:(resources string:'Correctable Error') |
3383 | 669 |
image:(WarningBox iconBitmap) |
3592
cb6f9f060e62
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3579
diff
changeset
|
670 |
buttonLabels:(resources array:#('Cancel' 'Declare as...' 'Correct...' 'Continue')) |
3383 | 671 |
values:#(#abort #declare #correct #continue) |
672 |
default:#continue |
|
673 |
onCancel:#abort. |
|
674 |
]. |
|
201 | 675 |
]. |
676 |
||
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
677 |
sameForAllHolder value ifTrue:[ |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
678 |
SameForAllNotification notify |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
679 |
]. |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
680 |
|
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
681 |
action == #declare ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
682 |
^ action |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
683 |
]. |
201 | 684 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
685 |
AbortOperationRequest raise. |
368 | 686 |
^ false |
201 | 687 |
]. |
368 | 688 |
^ action == #correct |
689 |
||
4386 | 690 |
"Modified: / 28-02-2012 / 10:42:27 / cg" |
201 | 691 |
! |
692 |
||
2104 | 693 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
694 |
"compiler notifies us of a correctable selector warning; |
|
695 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
696 |
this method should return true to the compiler if user wants the error |
|
697 |
to be corrected; false otherwise" |
|
698 |
||
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
699 |
|action doNotShowAgainHolder| |
2104 | 700 |
|
3261 | 701 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
702 |
doNotShowAgainHolder := false asValue. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
703 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
4386 | 704 |
(aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
705 |
ex box addCheckBoxAtBottom:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
|
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
706 |
]. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
707 |
ex proceed. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
708 |
] do:[ |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
709 |
action := OptionBox |
2104 | 710 |
request:aString |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
711 |
label:(resources string:'Warning') |
2983
910b4d5f7b1b
dont send obsolete message (OptionBox request:..form:..)
Claus Gittinger <cg@exept.de>
parents:
2982
diff
changeset
|
712 |
image:(WarningBox iconBitmap) |
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
713 |
buttonLabels:(resources array:#('Cancel' 'Correct...' 'Generate' 'Continue')) |
2338 | 714 |
values:#(#abort #correct #generate #continue) |
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
715 |
default:#continue |
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
716 |
onCancel:#abort. |
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
717 |
]. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
718 |
doNotShowAgainHolder value == true ifTrue:[ |
4386 | 719 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
720 |
]. |
2104 | 721 |
]. |
722 |
||
2338 | 723 |
action == #generate ifTrue:[ |
724 |
^ action |
|
725 |
]. |
|
726 |
||
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
727 |
(action isNil or:[action == #abort]) ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
728 |
AbortOperationRequest raise. |
2104 | 729 |
^ false |
730 |
]. |
|
731 |
^ action == #correct |
|
732 |
||
4386 | 733 |
"Created: / 19-01-2000 / 16:27:28 / cg" |
734 |
"Modified: / 28-02-2012 / 10:42:37 / cg" |
|
2104 | 735 |
! |
736 |
||
4188
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
737 |
correctableWarning:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
738 |
"compiler notifies us of a correctable warning; |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
739 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
740 |
this method should return true to the compiler if user wants the error |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
741 |
to be corrected; false otherwise" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
742 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
743 |
^ self correctableError:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
744 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
745 |
"Created: / 02-11-2010 / 13:29:01 / cg" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
746 |
! |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
747 |
|
201 | 748 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 749 |
"obsolete - no longer invoked" |
750 |
||
751 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
752 |
! |
|
753 |
||
754 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
755 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
756 |
and show a Box asking for continue/abort. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
757 |
Return true for correction, false of not (or not possible)" |
2277 | 758 |
|
759 |
^ self error:aString position:relPos to:relEndPos from:aCompiler asWarning:false |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
760 |
|
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
761 |
"Modified (Comment): / 30-06-2011 / 19:47:36 / cg" |
2277 | 762 |
! |
763 |
||
764 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
3397 | 765 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
201 | 766 |
and show a Box asking for continue/abort." |
767 |
||
3007 | 768 |
|answer fg bg| |
201 | 769 |
|
3007 | 770 |
fg := asWarning ifTrue:[ self warningForegroundColor ] ifFalse:[ self errorForegroundColor ]. |
771 |
bg := asWarning ifTrue:[ self warningBackgroundColor ] ifFalse:[ self errorBackgroundColor ]. |
|
201 | 772 |
|
3397 | 773 |
self |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
774 |
highlightingErrorPosition:relPos to:relEndPos |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
775 |
withForeground:fg andBackground:bg |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
776 |
do:[ |
4386 | 777 |
|box lbl doNotShowAgainHolder doNotShowAgainForThisMethodHolder l1 y1 y2 l2| |
201 | 778 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
779 |
"/ Warning isHandled ifTrue:[ |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
780 |
"/ Warning raiseErrorString:aString. |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
781 |
"/ ^ false |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
782 |
"/ ]. |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
783 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
784 |
lbl := aCompiler isNil ifTrue:['Compiler'] ifFalse:[aCompiler class name]. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
785 |
asWarning ifTrue:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
786 |
lbl := lbl , ' Warning' |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
787 |
] ifFalse:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
788 |
lbl := lbl , ' Error'. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
789 |
]. |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
790 |
|
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
791 |
" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
792 |
ask if we should abort or continue |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
793 |
" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
794 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
4386 | 795 |
|box makeSpace| |
796 |
||
797 |
doNotShowAgainHolder := false asValue. |
|
798 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
799 |
||
800 |
box := ex box. |
|
801 |
box |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
802 |
label:lbl; |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
803 |
image:(WarningBox iconBitmap). |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
804 |
|
4386 | 805 |
aCompiler notNil ifTrue:[ |
806 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
807 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
808 |
makeSpace value. |
|
809 |
box verticalPanel |
|
810 |
add:(CheckBox label:'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
811 |
model:doNotShowAgainHolder). |
|
812 |
]. |
|
813 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
814 |
makeSpace value. |
|
815 |
box verticalPanel |
|
4398 | 816 |
add:(CheckBox label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
4386 | 817 |
model:doNotShowAgainForThisMethodHolder). |
818 |
]. |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
819 |
]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
820 |
ex proceed. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
821 |
] do:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
822 |
answer := OptionBox |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
823 |
request:aString |
4279
f944300bc0be
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4278
diff
changeset
|
824 |
buttonLabels:(resources array:#('Abort' "'Keep Selected'" 'Continue')) |
f944300bc0be
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4278
diff
changeset
|
825 |
values:#(false "#keepSelected" true) |
4278
b13960d1a2cc
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4274
diff
changeset
|
826 |
default:(asWarning ifTrue:true ifFalse:false). |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
827 |
]. |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
828 |
"/ box := YesNoBox |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
829 |
"/ title:aString |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
830 |
"/ yesText:(resources string:'Continue') |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
831 |
"/ noText:(resources string:'Abort'). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
832 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
833 |
"/ box label:lbl. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
834 |
"/ box image:(WarningBox iconBitmap). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
835 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
836 |
"/ (aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
837 |
"/ doNotShowAgainHolder := false asValue. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
838 |
"/ box addCheckBox:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
839 |
"/ ]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
840 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
841 |
"/ "/ answer := box confirm. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
842 |
"/ answer := box confirm. |
3007 | 843 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
844 |
doNotShowAgainHolder value == true ifTrue:[ |
4125
eeed55ffc143
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4103
diff
changeset
|
845 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
846 |
]. |
4386 | 847 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
848 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
849 |
]. |
|
3007 | 850 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
851 |
"/ box destroy. |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
852 |
]. |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
853 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
854 |
answer == #keepSelected ifTrue:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
855 |
self hideCursor. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
856 |
"redraw selection in normal color" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
857 |
self invalidate. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
858 |
AbortOperationRequest raise. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
859 |
]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
860 |
|
201 | 861 |
" |
862 |
do the abort if we have to |
|
863 |
" |
|
3397 | 864 |
answer ifFalse:[ |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
865 |
"redraw selection in normal color" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
866 |
self invalidate. |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
867 |
AbortOperationRequest raise. |
201 | 868 |
]. |
869 |
^ 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
|
870 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
871 |
"Created: / 24-11-1995 / 22:56:34 / cg" |
4398 | 872 |
"Modified: / 08-03-2012 / 10:24:21 / cg" |
201 | 873 |
! |
874 |
||
2663 | 875 |
highlightingErrorLine:lineNr do:aBlock |
876 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
877 |
||
878 |
|linePosition| |
|
879 |
||
880 |
linePosition := self characterPositionOfLine:lineNr col:1. |
|
881 |
self highlightingErrorPosition:linePosition to:nil do:aBlock |
|
882 |
! |
|
883 |
||
59 | 884 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
885 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 886 |
|
3007 | 887 |
self |
888 |
highlightingErrorPosition:relPos to:relEndPos |
|
889 |
withForeground:(self errorForegroundColor) andBackground:(self errorBackgroundColor) |
|
890 |
do:aBlock |
|
891 |
! |
|
892 |
||
893 |
highlightingErrorPosition:relPos to:relEndPos withForeground:hilightFg andBackground:hilightBg do:aBlock |
|
894 |
"evaluate aBlock while some selection is shown highlighted with colors passed as args." |
|
895 |
||
896 |
|absPosition oldFg oldBg| |
|
0 | 897 |
|
58 | 898 |
" |
899 |
change color of selection & hide cursor |
|
900 |
" |
|
3007 | 901 |
oldFg := selectionFgColor. |
902 |
oldBg := selectionBgColor. |
|
903 |
selectionBgColor := hilightBg. |
|
904 |
selectionFgColor := hilightFg. |
|
58 | 905 |
self hideCursor. |
0 | 906 |
|
58 | 907 |
" |
908 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
909 |
we have to adjust the positions given by the compiler, since they |
|
910 |
are relative to the texts start (the compiler did stream-read the code). |
|
911 |
" |
|
0 | 912 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
3427 | 913 |
absPosition := codeStartPosition + (relPos ? 1) - 1. |
0 | 914 |
relEndPos isNil ifTrue:[ |
4141
06c97cc2bf6d
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
915 |
self selectFromCharacterPosition:absPosition. |
06c97cc2bf6d
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
916 |
"/ self selectLineWhereCharacterPosition:absPosition. |
0 | 917 |
] ifFalse:[ |
3427 | 918 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + (relEndPos ? 1) - 1) |
0 | 919 |
]. |
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
920 |
expandingTop := true. "/ hack to make the top of the selection visible |
0 | 921 |
self makeSelectionVisible. |
922 |
||
155 | 923 |
device flush. |
58 | 924 |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
925 |
aBlock ensure:[ |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
926 |
" |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
927 |
undo selection color change and show cursor again |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
928 |
" |
3007 | 929 |
selectionFgColor := oldFg. |
930 |
selectionBgColor := oldBg. |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
931 |
self showCursor. |
0 | 932 |
]. |
3427 | 933 |
|
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
934 |
"Modified: / 30-06-2011 / 17:24:04 / cg" |
0 | 935 |
! |
936 |
||
3007 | 937 |
highlightingWarningPosition:relPos to:relEndPos do:aBlock |
938 |
"evaluate aBlock while some selection is shown highlighted with warning colors." |
|
939 |
||
940 |
self |
|
941 |
highlightingErrorPosition:relPos to:relEndPos |
|
942 |
withForeground:(self warningForegroundColor) andBackground:(self warningBackgroundColor) |
|
943 |
do:aBlock |
|
944 |
! |
|
945 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
946 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
947 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
948 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
949 |
this method should return true to the compiler if user wants the error |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
950 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
951 |
|
4386 | 952 |
|action doNotShowAgainHolder doNotShowAgainForThisMethodHolder| |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
953 |
|
3007 | 954 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
955 |
doNotShowAgainHolder := false asValue. |
4386 | 956 |
doNotShowAgainForThisMethodHolder := false asValue. |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
957 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
4386 | 958 |
|box makeSpace| |
959 |
||
960 |
box := ex box. |
|
961 |
aCompiler notNil ifTrue:[ |
|
962 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
963 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
964 |
makeSpace value. |
|
965 |
box verticalPanel |
|
966 |
add:(CheckBox |
|
967 |
label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
968 |
model:doNotShowAgainHolder). |
|
969 |
]. |
|
970 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
971 |
makeSpace value. |
|
972 |
box verticalPanel |
|
973 |
add:(CheckBox |
|
4398 | 974 |
label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
4386 | 975 |
model:doNotShowAgainForThisMethodHolder). |
976 |
]. |
|
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
977 |
]. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
978 |
ex proceed. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
979 |
] do:[ |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
980 |
action := OptionBox |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
981 |
request:aString |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
982 |
label:(resources string:'Warning') |
2990
1373f301a694
dont send obsolete message to OptionBox
Claus Gittinger <cg@exept.de>
parents:
2983
diff
changeset
|
983 |
image:(WarningBox iconBitmap) |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
984 |
buttonLabels:(resources array:#('Cancel' 'Remove Variable(s)' 'Continue')) |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
985 |
values:#(#abort #correct #continue) |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
986 |
default:#continue. |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
987 |
]. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
988 |
doNotShowAgainHolder value == true ifTrue:[ |
4386 | 989 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
990 |
]. |
|
991 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
992 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
993 |
]. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
994 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
995 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
996 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
997 |
AbortOperationRequest raise. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
998 |
^ false |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
999 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1000 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
1001 |
|
4398 | 1002 |
"Modified: / 08-03-2012 / 10:23:58 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1003 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1004 |
|
116 | 1005 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 1006 |
"compiler notifies us of a warning - same behavior as error" |
0 | 1007 |
|
2277 | 1008 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 1009 |
! ! |
1010 |
||
3396 | 1011 |
!Workspace methodsFor:'drag & drop'! |
1012 |
||
1013 |
canDrop:aDropContext |
|
4090 | 1014 |
"if allowValueDrop is true, any text- or file-object can be dropped into workspace |
1015 |
(printString); otherwise, only ..." |
|
1016 |
||
1017 |
self isReadOnly ifTrue:[^ false]. |
|
3396 | 1018 |
|
4090 | 1019 |
allowValueDrop ifTrue:[^ true]. |
1020 |
^ super canDrop:aDropContext |
|
3428 | 1021 |
|
4090 | 1022 |
"/ ^ aDropContext dropObjects |
1023 |
"/ contains:[:someObject| (someObject isTextObject or:[ someObject isFileObject ])]. |
|
3396 | 1024 |
|
1025 |
"Created: / 16-08-2005 / 22:01:13 / janfrog" |
|
3428 | 1026 |
"Modified: / 28-11-2006 / 16:18:51 / cg" |
3396 | 1027 |
! |
1028 |
||
3414 | 1029 |
doDrop:aDropContext |
4386 | 1030 |
|v| |
1031 |
||
3739 | 1032 |
self halt:'should no longer be reached'. |
3428 | 1033 |
self drop:aDropContext |
3414 | 1034 |
|
3428 | 1035 |
"Modified: / 28-11-2006 / 16:14:51 / cg" |
4386 | 1036 |
"Modified (format): / 28-02-2012 / 11:20:38 / cg" |
3414 | 1037 |
! |
1038 |
||
1039 |
drop:aDropContext |
|
1040 |
"Any object can be dropped into workspace..." |
|
1041 |
||
3870 | 1042 |
|textObjects nonTextObjects answer text| |
1043 |
||
1044 |
textObjects := aDropContext dropObjects |
|
3887 | 1045 |
select:[:dropObject | dropObject isTextObject |
1046 |
or:[ dropObject isFileObject ]]. |
|
3870 | 1047 |
nonTextObjects := aDropContext dropObjects |
3887 | 1048 |
reject:[:dropObject | dropObject isTextObject |
1049 |
or:[ dropObject isFileObject ]]. |
|
3870 | 1050 |
|
1051 |
self dropObjects:textObjects. |
|
3414 | 1052 |
|
3870 | 1053 |
nonTextObjects notEmpty ifTrue:[ |
1054 |
answer := Dialog |
|
1055 |
confirmWithCancel:(resources |
|
1056 |
string:'Drop as textual representation or as object reference ?') |
|
1057 |
labels:(resources array:#('Cancel' 'Reference' 'Name' 'Text')) |
|
1058 |
values:#(nil #ref #name #text) |
|
1059 |
default:4. |
|
1060 |
answer isNil ifTrue:[^ self]. |
|
1061 |
(answer == #text or:[answer == #name]) ifTrue:[ |
|
1062 |
text := String streamContents:[:s | |
|
1063 |
nonTextObjects do:[:dropObject | |
|
1064 |
|obj| |
|
1065 |
||
1066 |
obj := dropObject theObject. |
|
1067 |
obj isMethod ifTrue:[ |
|
1068 |
s nextPutAll:(answer == #name ifTrue:[obj selector] ifFalse:[obj source]). |
|
1069 |
] ifFalse:[ |
|
1070 |
obj isClass ifTrue:[ |
|
1071 |
s nextPutAll:(answer == #name ifTrue:[obj name] ifFalse:[obj source asString]) |
|
1072 |
] ifFalse:[ |
|
1073 |
s nextPutAll:(answer == #name ifTrue:[obj className] ifFalse:[obj printString]) . |
|
1074 |
]. |
|
1075 |
]. |
|
1076 |
]. |
|
1077 |
]. |
|
1078 |
self paste:text. |
|
3414 | 1079 |
] ifFalse:[ |
3870 | 1080 |
nonTextObjects do:[:dropObject | |
1081 |
name := Dialog |
|
1082 |
request:(resources |
|
1083 |
string:'Name of the new Workspace Variable (refers to the dropped %1):' |
|
1084 |
with:dropObject theObject class name allBold |
|
1085 |
) |
|
1086 |
initialAnswer:'droppedObject' |
|
1087 |
okLabel:'Add' |
|
1088 |
title:'Enter Variable Name'. |
|
3414 | 1089 |
|
3870 | 1090 |
name notEmptyOrNil ifTrue:[ |
1091 |
Workspace addWorkspaceVariable:name. |
|
1092 |
(Workspace workspaceVariableAt:name) value:dropObject theObject. |
|
1093 |
self paste:name. |
|
1094 |
]. |
|
3414 | 1095 |
]. |
3870 | 1096 |
] |
3414 | 1097 |
]. |
1098 |
||
1099 |
"Created: / 13-10-2006 / 17:34:07 / cg" |
|
3396 | 1100 |
! ! |
1101 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1102 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1103 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1104 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1105 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1106 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1107 |
in the first col |
1108 |
(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
|
1109 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1110 |
|eolComment opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1111 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1112 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1113 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1114 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1115 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1116 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1117 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1118 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1119 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1120 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1121 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1122 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1123 |
l isNil ifTrue:[l := '']. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1124 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1125 |
l := eolComment , l |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1126 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1127 |
l := opening , l , closing |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1128 |
]. |
3403 | 1129 |
self replaceLine:lineNr with:l. |
1130 |
widthOfWidestLine notNil ifTrue:[ |
|
1131 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1132 |
]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1133 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1134 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1135 |
|
3403 | 1136 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
1137 |
"Modified: / 09-10-2006 / 10:46:44 / cg" |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1138 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1139 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1140 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1141 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1142 |
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
|
1143 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1144 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1145 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1146 |
|
1481 | 1147 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3210 | 1148 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
1149 |
||
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1150 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1151 |
self |
3785 | 1152 |
undoableDo:[ self commentFrom:cursorLine to:cursorLine ] |
3543 | 1153 |
info:'Comment'. |
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1154 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1155 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1156 |
|
3129 | 1157 |
self |
1158 |
undoableDo: |
|
1159 |
[ |
|
1160 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1161 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
|
1162 |
] ifFalse:[ |
|
3210 | 1163 |
commentPair := commentStrings at:2 ifAbsent:nil. |
1164 |
commentPair isNil ifTrue:[ |
|
1165 |
self beep. |
|
1166 |
] ifFalse:[ |
|
1167 |
opening := commentPair at:1. |
|
1168 |
closing := commentPair at:2. |
|
1169 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
3129 | 1170 |
|
3210 | 1171 |
e := selectionEndCol. |
1172 |
||
1173 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
1174 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
3129 | 1175 |
|
3210 | 1176 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
1177 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1178 |
toLine:selectionEndLine col:e+closing size. |
|
1179 |
] |
|
3129 | 1180 |
] |
1181 |
] |
|
1182 |
info:'comment' |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1183 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1184 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 1185 |
"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
|
1186 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1187 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1188 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1189 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1190 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1191 |
in the first col. |
1192 |
(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
|
1193 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1194 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1195 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1196 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1197 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1198 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1199 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1200 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1201 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1202 |
rest := eolComment size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1203 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1204 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1205 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1206 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1207 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1208 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1209 |
l notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1210 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1211 |
(l startsWith:eolComment) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1212 |
l := l copyFrom:rest |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1213 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1214 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1215 |
((l startsWith:opening) |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1216 |
and:[l endsWith:closing]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1217 |
l := l copyFrom:opening size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1218 |
l := l copyWithoutLast:closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1219 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1220 |
]. |
3403 | 1221 |
self replaceLine:lineNr with:l. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1222 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1223 |
]. |
3403 | 1224 |
widthOfWidestLine := nil. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1225 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1226 |
|
3403 | 1227 |
"Created: / 09-11-1997 / 01:05:43 / cg" |
1228 |
"Modified: / 09-10-2006 / 10:46:59 / cg" |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1229 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1230 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1231 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1232 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1233 |
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
|
1234 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1235 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1236 |
|e commentPair opening closing sz1 sz2| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1237 |
|
3129 | 1238 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1239 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1240 |
self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1241 |
undoableDo:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1242 |
self uncommentFrom:cursorLine to:cursorLine |
3543 | 1243 |
] |
1244 |
info:'Uncomment'. |
|
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1245 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1246 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1247 |
|
3129 | 1248 |
self |
1249 |
undoableDo: |
|
1250 |
[ |
|
1251 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1252 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
|
1253 |
] ifFalse:[ |
|
1254 |
commentPair := commentStrings at:2. |
|
1255 |
opening := commentPair at:1. |
|
1256 |
closing := commentPair at:2. |
|
1257 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1258 |
||
1259 |
sz1 := opening size. |
|
1260 |
sz2 := closing size. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1261 |
|
3129 | 1262 |
((self |
1263 |
stringAtLine:selectionStartLine |
|
1264 |
from:selectionStartCol |
|
1265 |
to:selectionStartCol+sz1 - 1) = opening |
|
1266 |
and:[(self |
|
1267 |
stringAtLine:selectionEndLine |
|
1268 |
from:selectionEndCol - sz2 + 1 |
|
1269 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1270 |
|
3129 | 1271 |
self deleteCharsAtLine:selectionEndLine fromCol:selectionEndCol-sz2+1 toCol:selectionEndCol. |
1272 |
self deleteCharsAtLine:selectionStartLine fromCol:selectionStartCol toCol:selectionStartCol+sz1-1. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1273 |
|
3129 | 1274 |
e := selectionEndCol - sz2. |
1275 |
selectionStartLine == selectionEndLine ifTrue:[e := e - sz1]. |
|
1276 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1277 |
toLine:selectionEndLine col:e. |
|
1278 |
] |
|
1279 |
] |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1280 |
] |
3129 | 1281 |
info:'uncomment' |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1282 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1283 |
"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
|
1284 |
"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
|
1285 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1286 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1287 |
!Workspace methodsFor:'event handling'! |
3712 | 1288 |
|
0 | 1289 |
keyPress:key x:x y:y |
4252
2822c01f8582
changed resourceDescription: #keyPress:x:y:
Stefan Vogel <sv@exept.de>
parents:
4251
diff
changeset
|
1290 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #ReplaceIt #BrowseIt #ImplementorsOfIt #ExpandAbbreviation)> |
60 | 1291 |
|
3800 | 1292 |
(key == #DoIt) ifTrue:[self doIt. ^ self]. |
1293 |
(key == #InspectIt) ifTrue:[self inspectIt. ^ self]. |
|
1294 |
(key == #PrintIt) ifTrue:[self printIt. ^ self]. |
|
1295 |
(key == #ReplaceIt) ifTrue:[self replaceIt. ^ self]. |
|
1296 |
(key == #BrowseIt) ifTrue:[self browseIt. ^ self]. |
|
1297 |
(key == #ImplementorsOfIt) ifTrue:[self browseImplementorsOfIt. ^ self]. |
|
1298 |
(key == #ExpandAbbreviation) ifTrue:[self expandAbbreviation. ^ self]. |
|
38 | 1299 |
|
0 | 1300 |
super keyPress:key x:x y:y |
3511 | 1301 |
|
1302 |
"Modified: / 08-11-2007 / 11:29:45 / cg" |
|
0 | 1303 |
! ! |
201 | 1304 |
|
2143 | 1305 |
!Workspace methodsFor:'executing'! |
201 | 1306 |
|
1501 | 1307 |
do:code withValueDo:aBlock |
418 | 1308 |
"helper for doIt, printIt and inspectIt. |
1309 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
1310 |
aBlock with the value. |
|
1311 |
Most work is in preparing for proper cleanup in case of abort |
|
1312 |
or other exception while the evaluation is performed. |
|
1313 |
(restore cursor, selectionColors etc.)" |
|
201 | 1314 |
|
4149 | 1315 |
|selLine selCol endLine endCol cLine cCol cleanUp executeBlock| |
201 | 1316 |
|
1317 |
code notNil ifTrue:[ |
|
2409 | 1318 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
2408 | 1319 |
|
257 | 1320 |
codeStartPosition := self characterPositionOfSelection. |
201 | 1321 |
|
257 | 1322 |
" |
1323 |
remember selection for later - if there is an error, |
|
1324 |
the notification method will highlight it. |
|
1325 |
thus destroying the current selection |
|
1326 |
" |
|
1327 |
selLine := selectionStartLine. |
|
1328 |
selCol := selectionStartCol. |
|
1329 |
endLine := selectionEndLine. |
|
1330 |
endCol := selectionEndCol. |
|
1331 |
cCol := cursorCol. |
|
1332 |
cLine := cursorLine. |
|
201 | 1333 |
|
257 | 1334 |
" |
1335 |
cleanup: restore previous selection and cursor positions |
|
1336 |
" |
|
1337 |
cleanUp := [ |
|
1338 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
1339 |
cLine notNil ifTrue:[ |
|
1340 |
self cursorLine:cLine col:cCol |
|
1341 |
]. |
|
1342 |
]. |
|
201 | 1343 |
|
257 | 1344 |
" |
1345 |
perform the action. |
|
1346 |
Be careful to release the reference to the value; |
|
1347 |
otherwise, we could keep lots of garbage from being freed |
|
1348 |
until the view gets closed |
|
1349 |
" |
|
4149 | 1350 |
executeBlock := [ |
1351 |
[ |
|
1352 |
AbortOperationRequest handle:[:ex | |
|
1353 |
"/ aBlock value:'** Abortsignal cought **'. |
|
1354 |
ex return |
|
1355 |
] do:[ |
|
1356 |
|value| |
|
929 | 1357 |
|
4149 | 1358 |
doItAction notNil ifTrue:[ |
1359 |
value := doItAction value:(code asString). |
|
1360 |
cleanUp value. cleanUp := nil. |
|
1361 |
aBlock notNil ifTrue:[ |
|
1362 |
aBlock value:value. |
|
1363 |
]. |
|
1364 |
value := nil. |
|
1365 |
self class rememberDoIt:code. |
|
1366 |
] |
|
257 | 1367 |
] |
4149 | 1368 |
] ensure:[ |
1369 |
cleanUp notNil ifTrue:[ |
|
1370 |
cleanUp value. cleanUp := nil |
|
1371 |
]. |
|
257 | 1372 |
] |
4149 | 1373 |
]. |
1374 |
aBlock isNil ifTrue:[ |
|
1375 |
"no action is performed with the result - give the user a visible |
|
1376 |
feedback, that something has been done" |
|
1377 |
self topView withVisibleCursor:Cursor execute do:executeBlock. |
|
1378 |
] ifFalse:[ |
|
1379 |
self topView withCursor:Cursor execute do:executeBlock. |
|
257 | 1380 |
]. |
201 | 1381 |
] |
257 | 1382 |
|
1501 | 1383 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
1384 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
2409 | 1385 |
"Modified: / 26.9.2001 / 17:32:59 / cg" |
201 | 1386 |
! ! |
1387 |
||
2751 | 1388 |
!Workspace methodsFor:'initialization & release'! |
201 | 1389 |
|
2733 | 1390 |
doItAction:aOneArgBlock |
1391 |
"define the action to be performed when 'doIt' is selected. |
|
1392 |
The block will be evaluated, passing the selection as a String argument. |
|
1393 |
A default doItAction is set for you in the initialize method." |
|
1394 |
||
1395 |
doItAction := aOneArgBlock |
|
1396 |
||
1397 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
1398 |
! |
|
1399 |
||
1400 |
executeDoIt:theCode |
|
4391 | 1401 |
"the core of doIt, printIt, inspectIt, browseIt actions" |
1402 |
||
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1403 |
| result | |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1404 |
|
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1405 |
"JV@2012-03-19: Changed to reflect value of autoDefineVariables" |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1406 |
[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1407 |
result := (self compilerClass new) |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1408 |
currentNamespace:namespaceForDoits; |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1409 |
moreSharedPools:poolsConsideredInDoIts; |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1410 |
evaluate:theCode |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1411 |
in:nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1412 |
receiver:simulatedSelf |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1413 |
notifying:self |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1414 |
logged:true |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1415 |
ifFail:nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1416 |
] on: Parser undefinedVariableNotification do:[:ex| |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1417 |
autoDefineVariables notNil ifTrue:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1418 |
ex proceedWith: #declare |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1419 |
] ifFalse:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1420 |
ex proceedWith: nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1421 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1422 |
] on: Parser askForVariableTypeOfUndeclaredQuery do:[:ex| |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1423 |
autoDefineVariables == #workspace ifTrue:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1424 |
ex proceedWith:#WorkspaceVariable |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1425 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1426 |
autoDefineVariables == #doIt ifTrue:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1427 |
ex proceedWith:#DoItTemporary |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1428 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1429 |
ex pass. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1430 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1431 |
^result |
4391 | 1432 |
|
1433 |
"Modified (comment): / 04-03-2012 / 13:37:53 / cg" |
|
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1434 |
"Modified: / 19-03-2012 / 10:01:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2733 | 1435 |
! |
1436 |
||
201 | 1437 |
initStyle |
966 | 1438 |
"setup viewStyle specifics" |
1439 |
||
201 | 1440 |
super initStyle. |
1441 |
||
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1442 |
DefaultViewBackground notNil ifTrue:[ |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1443 |
viewBackground := DefaultViewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1444 |
self backgroundColor:viewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1445 |
]. |
201 | 1446 |
! |
1447 |
||
1448 |
initialize |
|
1449 |
super initialize. |
|
1450 |
||
2775 | 1451 |
scrollWhenUpdating := #beginOfText. |
201 | 1452 |
showMatchingParenthesis := true. |
3428 | 1453 |
allowValueDrop := true. |
1454 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1455 |
commentStrings := #( |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1456 |
'"/' |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1457 |
('"' '"') |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1458 |
). |
201 | 1459 |
|
1460 |
self initializeDoITAction. |
|
3396 | 1461 |
self initializeDragAndDrop. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1462 |
|
3428 | 1463 |
"Modified: / 28-11-2006 / 16:11:55 / cg" |
201 | 1464 |
! |
1465 |
||
1466 |
initializeDoITAction |
|
1467 |
"set up the block to be evaluated for doIts. |
|
1468 |
This is done here in a separate method to allow easier |
|
1469 |
redefinition in subclasses" |
|
1470 |
||
2733 | 1471 |
doItAction := [:theCode | self executeDoIt:theCode]. |
3396 | 1472 |
! |
1473 |
||
1474 |
initializeDragAndDrop |
|
1475 |
|target| |
|
1476 |
||
1477 |
target := DropTarget |
|
1478 |
receiver:self |
|
1479 |
argument:nil |
|
3411 | 1480 |
dropSelector:#drop: |
3396 | 1481 |
canDropSelector:#canDrop:. |
1482 |
self dropTarget:target |
|
1483 |
||
1484 |
"Created: / 16-08-2005 / 22:03:36 / janfrog" |
|
3411 | 1485 |
"Modified: / 13-10-2006 / 12:37:18 / cg" |
201 | 1486 |
! ! |
1487 |
||
418 | 1488 |
!Workspace methodsFor:'menu & menu actions'! |
1489 |
||
2285 | 1490 |
browseClass |
1491 |
"user selected 'browseClass' from menu; evaluate the code |
|
1492 |
and open a browser on the resulting class (if it evaluates to one)" |
|
1493 |
||
1494 |
^ self |
|
3272 | 1495 |
do:(self selectionAsString) |
3910 | 1496 |
withValueDo:[:result | |
1497 |
result isBehavior ifTrue:[ |
|
1498 |
result browserClass openInClass:result selector:nil |
|
1499 |
] ifFalse:[ |
|
1500 |
self warn:'Selection does not evaluate to a class' |
|
1501 |
] |
|
1502 |
]. |
|
2285 | 1503 |
|
2410 | 1504 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 1505 |
! |
1506 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1507 |
browseImplementorsOfIt |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1508 |
"open a browser on the implementors of the selected text" |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1509 |
|
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1510 |
|selectedText selector browserClass na| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1511 |
|
2714 | 1512 |
selectedText := self selectionAsString. |
1513 |
selectedText size > 0 ifTrue:[ |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1514 |
self windowGroup withWaitCursorDo:[ |
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1515 |
"/ hack, for now and expecco; must ask the Parser eventually... |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1516 |
(compilerClass notNil and:[compilerClass includesBehavior:JavaScriptParser]) ifTrue:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1517 |
"/ selector is in one piece anyway |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1518 |
(selectedText includes:$_) ifFalse:[ |
3896 | 1519 |
"/ zero or one args - sigh (need to parse more to figure this out) |
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1520 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:1. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1521 |
selectedText := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:0. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1522 |
] ifTrue:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1523 |
"/ count _#s plus one arg - sigh |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1524 |
na := (selectedText occurrencesOf:$_) + 1. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1525 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:na |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1526 |
]. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1527 |
] ifFalse:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1528 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1529 |
]. |
2714 | 1530 |
browserClass := UserPreferences current systemBrowserClass. |
1531 |
||
3287 | 1532 |
(selector notNil and:[selector ~= selectedText]) ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1533 |
(SystemBrowser |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1534 |
findImplementorsOfAny:(Array with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1535 |
in:(Smalltalk allClasses) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1536 |
ignoreCase:false) isEmpty ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1537 |
browserClass browseImplementorsOf:selector |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1538 |
] ifFalse:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1539 |
browserClass browseImplementorsOfAny:(Set with:selector with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1540 |
]. |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1541 |
] ifFalse:[ |
2714 | 1542 |
browserClass browseImplementorsOf:(selector ? selectedText) |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1543 |
] |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1544 |
] |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1545 |
]. |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1546 |
|
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1547 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1548 |
"Modified: / 19.11.2001 / 22:15:17 / cg" |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1549 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1550 |
|
2307 | 1551 |
browseIt |
1552 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
2713 | 1553 |
or the class of the resulting object (if it does not evaluate to a class). |
1554 |
||
1555 |
Added feature: if selection is of the form class >> selector, immediately switch to that selector." |
|
1556 |
||
4386 | 1557 |
|codeToEvaluate idx selector evaluatedValue classToBrowse gotResult| |
2713 | 1558 |
|
3596 | 1559 |
codeToEvaluate := (self selectionOrTextOfCursorLine ? '') withoutSeparators. |
2713 | 1560 |
idx := codeToEvaluate indexOfSubCollection:'>>'. |
1561 |
idx ~~ 0 ifTrue:[ |
|
2717 | 1562 |
selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string. |
3155 | 1563 |
(selector startsWith:'#') ifTrue:[ |
1564 |
selector := Symbol readFrom:selector. |
|
1565 |
]. |
|
2713 | 1566 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
1567 |
]. |
|
2307 | 1568 |
|
3910 | 1569 |
Parser parseErrorSignal handle:[:ex | |
1570 |
|className| |
|
2410 | 1571 |
|
3910 | 1572 |
"/ fallback, if garbage is selected, look for matching classes. |
1573 |
className := SystemBrowser |
|
1574 |
askForClassNameMatching:codeToEvaluate |
|
1575 |
inEnvironment:nil |
|
1576 |
for:nil. |
|
4386 | 1577 |
|
3910 | 1578 |
className isNil ifTrue:[^ self]. |
4057
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1579 |
classToBrowse := Smalltalk classNamed:className. |
3910 | 1580 |
] do:[ |
4386 | 1581 |
gotResult := false. |
1582 |
||
3910 | 1583 |
self |
1584 |
do:codeToEvaluate |
|
4386 | 1585 |
withValueDo:[:result | evaluatedValue := result. gotResult := true.]. |
4057
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1586 |
|
4386 | 1587 |
gotResult ifFalse:[^ self]. |
1588 |
||
1589 |
evaluatedValue isNil ifTrue:[ |
|
4057
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1590 |
codeToEvaluate asCollectionOfWords size == 1 ifTrue:[ |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1591 |
codeToEvaluate isUppercaseFirst ifTrue:[ |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1592 |
Dialog information:(codeToEvaluate allBold , ' is unbound or nil'). |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1593 |
^ self. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1594 |
]. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1595 |
] |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1596 |
]. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1597 |
classToBrowse := evaluatedValue isBehavior |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1598 |
ifTrue:[ evaluatedValue ] |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1599 |
ifFalse:[ evaluatedValue class ]. |
3910 | 1600 |
]. |
1601 |
||
1602 |
classToBrowse browserClass openInClass:classToBrowse selector:selector |
|
4386 | 1603 |
|
1604 |
"Modified: / 28-02-2012 / 11:23:06 / cg" |
|
2307 | 1605 |
! |
1606 |
||
2285 | 1607 |
browseItsClass |
1608 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
1609 |
and open a browser on the results class" |
|
1610 |
||
1611 |
^ self |
|
3272 | 1612 |
do:(self selectionAsString) |
2410 | 1613 |
withValueDo:[:result | |
1614 |
result class browserClass openInClass:result class selector:nil |
|
1615 |
] |
|
2285 | 1616 |
|
2410 | 1617 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 1618 |
! |
1619 |
||
2454 | 1620 |
browseReferencesToIt |
1621 |
"open a browser on all references to the selected global" |
|
1622 |
||
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1623 |
|sel| |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1624 |
|
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1625 |
sel := self selectionAsString. |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1626 |
sel size > 0 ifTrue:[ |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1627 |
self windowGroup withWaitCursorDo:[ |
3959 | 1628 |
(Smalltalk includesKey:sel asSymbol) ifFalse:[ |
1629 |
sel := ((NameSpace allNameSpaces detect:[:ns | ns includesKey:sel asSymbol]) at:sel asSymbol) name. |
|
1630 |
]. |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1631 |
(UserPreferences current systemBrowserClass) |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1632 |
browseReferendsOf:sel |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1633 |
]. |
2454 | 1634 |
]. |
1635 |
||
1636 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
1637 |
"Modified: / 5.11.2001 / 17:32:38 / cg" |
|
1638 |
! |
|
1639 |
||
2462 | 1640 |
browseSendersOfIt |
1641 |
"open a browser on the senders of the selected text" |
|
1642 |
||
2715 | 1643 |
|selectedText selector| |
2462 | 1644 |
|
2715 | 1645 |
selectedText := self selectionAsString. |
1646 |
selectedText size > 0 ifTrue:[ |
|
2462 | 1647 |
self windowGroup withWaitCursorDo:[ |
3287 | 1648 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
2462 | 1649 |
(UserPreferences current systemBrowserClass) |
2715 | 1650 |
browseAllCallsOn:(selector ? selectedText) |
2462 | 1651 |
] |
1652 |
]. |
|
1653 |
||
1654 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1655 |
"Modified: / 19.11.2001 / 22:15:27 / cg" |
2462 | 1656 |
! |
1657 |
||
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1658 |
browseSharedPoolOfIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1659 |
"open a browser on the shared pool in which the selected variable is" |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1660 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1661 |
|sel| |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1662 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1663 |
sel := self selectionAsString. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1664 |
sel isEmptyOrNil ifTrue:[^ self]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1665 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1666 |
sel := sel asSymbol. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1667 |
self windowGroup withWaitCursorDo:[ |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1668 |
SharedPool allSubclassesDo:[:eachPool | |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1669 |
(eachPool includesKey:sel) ifTrue:[ |
4211
49c61548cc53
changed: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4210
diff
changeset
|
1670 |
(UserPreferences current systemBrowserClass) |
49c61548cc53
changed: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4210
diff
changeset
|
1671 |
openInClass:eachPool class selector:#initialize |
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1672 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1673 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1674 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1675 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1676 |
"Created: / 15-01-2011 / 14:01:39 / cg" |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1677 |
! |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1678 |
|
418 | 1679 |
doIt |
1680 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
1681 |
and finally restore cursor; return result of evaluation" |
|
1682 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1683 |
^ self |
3272 | 1684 |
do:(self selectionOrTextOfCursorLine) |
4149 | 1685 |
withValueDo:nil |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1686 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1687 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 1688 |
! |
1689 |
||
1690 |
editMenu |
|
1107 | 1691 |
"return my popUpMenu; thats the superclasses menu |
1692 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
|
1693 |
||
2459 | 1694 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
1695 |
#CommentSelection #UncommentSelection |
|
2573
52c995a1ea78
accelerators for browseIt and implementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
2571
diff
changeset
|
1696 |
#BrowseIt #ImplementorsOfIt |
2459 | 1697 |
)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
1698 |
<resource: #programMenu> |
489 | 1699 |
|
2867 | 1700 |
|m sub subsub idx sensor s s2| |
418 | 1701 |
|
1702 |
m := super editMenu. |
|
3252 | 1703 |
((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
2459 | 1704 |
sub := m. |
1705 |
m := nil. |
|
1706 |
] ifFalse:[ |
|
1707 |
sub := m subMenuAt:#others. |
|
1708 |
]. |
|
418 | 1709 |
|
2459 | 1710 |
sub notNil ifTrue:[ |
2867 | 1711 |
|
2459 | 1712 |
" |
2867 | 1713 |
workspaces support #browse, implementors etc. add them after paste. |
2459 | 1714 |
" |
2867 | 1715 |
sub |
1716 |
addItemList:#( |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1717 |
('-' ) |
3910 | 1718 |
('Browse' browseIt BrowseIt ) |
4210 | 1719 |
('Browse its Pool' browseSharedPoolOfIt ) |
3910 | 1720 |
('Senders of It' browseSendersOfIt ) |
1721 |
('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
|
1722 |
('References to It' browseReferencesToIt ) |
|
1723 |
"/ ('Classes Containing It in Name' browseClassesContainingItInName ) |
|
1724 |
"/ ('Methods Contaníning It in Name' browseMethodsContainingItInName ) |
|
1725 |
"/ ('Methods Contaníning It in Source' browseMethodsContainingItInSource ) |
|
2867 | 1726 |
('-' ) |
1727 |
('TimeIt' timeIt ) |
|
1728 |
('SpyOnIt' spyOnIt )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1729 |
resources:resources |
2459 | 1730 |
after:#gotoLine. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1731 |
|
2867 | 1732 |
subsub := sub subMenuAt:#tools. |
1733 |
subsub notNil ifTrue:[ |
|
1734 |
subsub |
|
1735 |
addItemList:#( |
|
1736 |
('-' ) |
|
1737 |
('Comment' commentSelection CommentSelection ) |
|
1738 |
('Uncomment' uncommentSelection UncommentSelection )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1739 |
resources:resources |
2867 | 1740 |
after:#'indent'. |
1741 |
]. |
|
1742 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1743 |
self hasSelection ifFalse:[ |
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1744 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1745 |
browseReferencesToIt timeIt spyOnIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1746 |
browseSharedPoolOfIt |
3272 | 1747 |
commentSelection uncommentSelection ) |
2454 | 1748 |
] ifTrue:[ |
1749 |
s := self selectionAsString. |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1750 |
s notNil ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1751 |
s asSymbolIfInterned isNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1752 |
s2 := SystemBrowser extractSelectorFrom:s. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1753 |
s2 notNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1754 |
s2 := s2 asSymbolIfInterned. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1755 |
]. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1756 |
]. |
2454 | 1757 |
]. |
2487
47e0a1faf544
disabling of impl/senders menu
Claus Gittinger <cg@exept.de>
parents:
2485
diff
changeset
|
1758 |
(s2 isNil and:[s isNil]) ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1759 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1760 |
]. |
3959 | 1761 |
"/ a global or namespace-var selected ? |
1762 |
(s notNil |
|
1763 |
and:[s asSymbolIfInterned notNil |
|
1764 |
and:[ (Smalltalk includesKey:s asSymbol) |
|
1765 |
or:[ (NameSpace allNameSpaces contains:[:ns | ns includesKey:s asSymbol]) ]]]) |
|
1766 |
ifFalse:[ |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1767 |
sub disable:#browseReferencesToIt. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1768 |
]. |
4342 | 1769 |
(s notNil |
1770 |
and:[ s asSymbolIfInterned notNil |
|
1771 |
and:[ (SharedPool allSubclasses contains:[:pool | pool includesKey:s asSymbol]) ]]) ifFalse:[ |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1772 |
sub disable:#browseSharedPoolOfIt. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1773 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1774 |
|
2595 | 1775 |
self isReadOnly ifTrue:[ |
2641 | 1776 |
sub disableAll:#(commentSelection uncommentSelection) |
2595 | 1777 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1778 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1779 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1780 |
|
2459 | 1781 |
m notNil ifTrue:[ |
1782 |
" |
|
1783 |
workspaces support #doIt, #printIt and #inspectIt |
|
1784 |
add them after paste. |
|
1785 |
" |
|
1786 |
idx := m indexOf:#paste. |
|
1787 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
1788 |
idx ~~ 0 ifTrue:[ |
|
2867 | 1789 |
m |
1790 |
addItemList:#( |
|
1791 |
('-' ) |
|
1792 |
('DoIt' doIt DoIt ) |
|
1793 |
('PrintIt' printIt PrintIt ) |
|
1794 |
('InspectIt' inspectIt InspectIt)) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1795 |
resources:resources |
2459 | 1796 |
after:idx. |
1797 |
||
1798 |
]. |
|
1799 |
||
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
1800 |
(self hasSelectionOrTextInCursorLine) ifFalse:[ |
3272 | 1801 |
|lNr line| |
1802 |
||
1803 |
lNr := self cursorLine. |
|
1804 |
line := self listAt:lNr. |
|
1805 |
line isEmptyOrNil ifTrue:[ |
|
1806 |
m disableAll:#(printIt doIt inspectIt browseIt) |
|
1807 |
]. |
|
2459 | 1808 |
]. |
2595 | 1809 |
self isReadOnly ifTrue:[ |
1810 |
m disable:#printIt |
|
1811 |
]. |
|
418 | 1812 |
]. |
1813 |
||
2459 | 1814 |
^ m ? sub. |
430 | 1815 |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1816 |
"Modified: / 22-04-1998 / 21:49:06 / ca" |
4342 | 1817 |
"Modified: / 20-12-2011 / 11:22:20 / cg" |
418 | 1818 |
! |
1819 |
||
1820 |
inspectIt |
|
1821 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
1822 |
and start an inspector on the result" |
|
1823 |
||
2981
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1824 |
|shifted| |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1825 |
|
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1826 |
shifted := self sensor shiftDown. |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1827 |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1828 |
^ self |
3272 | 1829 |
do:(self selectionOrTextOfCursorLine) |
2982
9a831ab53acc
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2981
diff
changeset
|
1830 |
withValueDo:[:result | shifted ifTrue:[result basicInspect] ifFalse:[result inspect] ] |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1831 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1832 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 1833 |
! |
1834 |
||
1835 |
printIt |
|
1836 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
1837 |
and insert result of evaluation into my text. |
|
1838 |
If the text is readOnly, do nothing." |
|
1839 |
||
1734 | 1840 |
self isReadOnly ifTrue:[ |
3511 | 1841 |
self beep. |
1842 |
^ self. |
|
1843 |
]. |
|
1844 |
self |
|
1845 |
undoableDo:[ |
|
1846 |
self |
|
1847 |
do:(self selectionOrTextOfCursorLine) |
|
4367 | 1848 |
withValueDo:[:result | |
1849 |
|s| |
|
1850 |
||
3511 | 1851 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
4367 | 1852 |
(result isInteger |
1853 |
and:[ result > 10 |
|
4401 | 1854 |
and:[ InspectorView defaultIntegerDisplayRadix ~= 10 ]]) ifTrue:[ |
1855 |
s := result displayString , ' "',(result radixPrintStringRadix: InspectorView defaultIntegerDisplayRadix),'"'. |
|
4367 | 1856 |
] ifFalse:[ |
1857 |
s := result displayString "printString" |
|
1858 |
]. |
|
1859 |
self insertSelectedStringAtCursor:s |
|
3511 | 1860 |
] |
1861 |
] |
|
1862 |
info:'PrintIt' |
|
1863 |
||
4401 | 1864 |
"Modified: / 08-03-2012 / 16:14:34 / cg" |
3511 | 1865 |
! |
418 | 1866 |
|
3511 | 1867 |
replaceIt |
1868 |
"like printIt, but replace the selection with the result, instead of |
|
1869 |
pasting it after the selection." |
|
1870 |
||
1871 |
self isReadOnly ifTrue:[ |
|
1872 |
self beep. |
|
1873 |
^ self |
|
1874 |
]. |
|
1875 |
||
1876 |
self |
|
1877 |
undoableDo:[ |
|
1878 |
self |
|
1879 |
do:(self selectionOrTextOfCursorLine) |
|
1880 |
withValueDo:[:result | |
|
1881 |
self replaceSelectionBy:(result displayString "printString") |
|
1882 |
]. |
|
1883 |
undoSupport actionInfo:'ReplaceIt'. |
|
1884 |
] |
|
1885 |
info:'ReplaceIt' |
|
1886 |
||
1887 |
"Created: / 08-11-2007 / 11:31:54 / cg" |
|
1501 | 1888 |
! |
1889 |
||
1890 |
spyOnIt |
|
1891 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
1892 |
and finally restore cursor; return result of evaluation" |
|
1893 |
||
1894 |
|code| |
|
1895 |
||
4427 | 1896 |
compilerClass == Smalltalk::Compiler ifFalse:[ |
1897 |
"sigh - this measurement will include the time to compile - sigh" |
|
1898 |
MessageTally spyDetailedOn:[ self doIt ]. |
|
1899 |
^ self. |
|
1900 |
]. |
|
1901 |
||
4416 | 1902 |
code := 'MessageTally spyDetailedOn:[' , self selectionAsString, ']'. |
4149 | 1903 |
self do:code withValueDo:[:value| ]. |
1501 | 1904 |
|
3511 | 1905 |
"Modified: / 22-04-1998 / 22:03:53 / ca" |
4427 | 1906 |
"Modified: / 02-06-2012 / 00:39:13 / cg" |
1501 | 1907 |
! |
1908 |
||
1909 |
timeIt |
|
1910 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
1911 |
and finally restore cursor; return result of evaluation" |
|
1912 |
||
4427 | 1913 |
|code t| |
1914 |
||
1915 |
compilerClass == Smalltalk::Compiler ifFalse:[ |
|
1916 |
"sigh - this measurement will include the time to compile - sigh" |
|
1917 |
t := Time millisecondsToRun:[ self doIt ]. |
|
1918 |
Transcript showCR:'execution time: ' , t printString , ' ms'. |
|
1919 |
^ self. |
|
1920 |
]. |
|
1501 | 1921 |
|
3272 | 1922 |
code := '|t| t := Time millisecondsToRun:[' , self selectionAsString, ']. |
4149 | 1923 |
Transcript showCR:''execution time: '' , t printString , '' ms''.'. |
1924 |
self do:code withValueDo:[:value | ]. |
|
1501 | 1925 |
|
4427 | 1926 |
"Modified: / 22-04-1998 / 22:03:51 / ca" |
1927 |
"Modified (format): / 02-06-2012 / 00:38:51 / cg" |
|
418 | 1928 |
! ! |
1929 |
||
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1930 |
!Workspace methodsFor:'misc'! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1931 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1932 |
expandAbbreviation |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1933 |
"after receiving an Alt-shift key-event, look for the string before the |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1934 |
cursor, find an abbrev for it and expand." |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1935 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1936 |
|expandedString abortExpandAction oldSelectionStartLine oldSelectionStartCol oldSelectionEndLine oldSelectionEndCol oldCursorLine oldCursorCol |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1937 |
newCursorPos replStartCol| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1938 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1939 |
oldCursorLine := self cursorLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1940 |
oldCursorCol := self cursorCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1941 |
oldSelectionStartLine := self selectionStartLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1942 |
oldSelectionStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1943 |
oldSelectionEndLine := self selectionEndLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1944 |
oldSelectionEndCol := self selectionEndCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1945 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1946 |
abortExpandAction := [ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1947 |
self selectFromLine:oldSelectionStartLine |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1948 |
col:oldSelectionStartCol |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1949 |
toLine:oldSelectionEndLine |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1950 |
col:oldSelectionEndCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1951 |
self cursorLine: oldCursorLine col: oldCursorCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1952 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1953 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1954 |
expandedString := self findAbbreviationKeyBeforeCursor. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1955 |
expandedString isNil ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1956 |
abortExpandAction value. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1957 |
^ self |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1958 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1959 |
newCursorPos := expandedString indexOf:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1960 |
newCursorPos ~~ 0 ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1961 |
expandedString := expandedString copyWithout:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1962 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1963 |
replStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1964 |
self |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1965 |
undoableDo:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1966 |
self replaceSelectionWith: expandedString] |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1967 |
info:'Replace'. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1968 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1969 |
newCursorPos == 0 ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1970 |
"/ cursor already fine (at the end) |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1971 |
] ifFalse:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1972 |
self cursorCol:replStartCol+newCursorPos-1 |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1973 |
] |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1974 |
! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1975 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1976 |
findAbbreviationKeyBeforeCursor |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1977 |
"after receiving an Alt-shift key-event, look for the string before the |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1978 |
cursor, find an abbrev for it and expand." |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1979 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1980 |
|sniplets keys minMax maxKeyLen minKeyLen line stringBeforeCursor| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1981 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1982 |
sniplets := self class sniplets. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1983 |
keys := sniplets keys. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1984 |
minMax := (keys collect:[:k | k size]) minMax. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1985 |
minKeyLen := minMax first. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1986 |
maxKeyLen := minMax second. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1987 |
line := (self at:cursorLine) ? ''. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1988 |
stringBeforeCursor := line string copyTo:((cursorCol-1) min:line size). |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1989 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1990 |
maxKeyLen := maxKeyLen min:stringBeforeCursor size. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1991 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1992 |
(maxKeyLen to:minKeyLen by:-1) do:[:l | |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1993 |
|lCharactersBeforeCursor expandedString| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1994 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1995 |
lCharactersBeforeCursor := stringBeforeCursor last:l. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1996 |
expandedString := sniplets at:lCharactersBeforeCursor ifAbsent:nil. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1997 |
expandedString notNil ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1998 |
self selectFromLine:cursorLine col:cursorCol-l toLine:cursorLine col:cursorCol-1. |
4185 | 1999 |
^ expandedString withCRs |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2000 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2001 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2002 |
^ nil. |
4185 | 2003 |
|
2004 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2005 |
! ! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2006 |
|
2646 | 2007 |
!Workspace methodsFor:'queries'! |
2008 |
||
2009 |
isWorkspace |
|
4395 | 2010 |
"back-query from the compiler to ask if this is an interactive view |
2011 |
(for error feedback)" |
|
2012 |
||
2646 | 2013 |
^ true |
4395 | 2014 |
|
2015 |
"Modified (comment): / 07-03-2012 / 17:52:59 / cg" |
|
2646 | 2016 |
! ! |
2017 |
||
206 | 2018 |
!Workspace class methodsFor:'documentation'! |
2019 |
||
4402 | 2020 |
version |
4427 | 2021 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.249 2012-06-01 22:39:47 cg Exp $' |
4402 | 2022 |
! |
2023 |
||
3959 | 2024 |
version_CVS |
4427 | 2025 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.249 2012-06-01 22:39:47 cg Exp $' |
858 | 2026 |
! ! |