author | Claus Gittinger <cg@exept.de> |
Thu, 27 Jun 2013 22:01:43 +0200 | |
changeset 4638 | 99ab02c595bb |
parent 4631 | e1e810a69059 |
child 4656 | 8e48e4c556b6 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
4619 | 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 |
4631 | 15 |
instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor |
16 |
commentStrings autoDefineWorkspaceVariables simulatedSelf |
|
17 |
autoDefineVariables compilerClass allowValueDrop |
|
18 |
poolsConsideredInDoIts namespaceForDoits editedMethodOrClass' |
|
19 |
classVariableNames:'DefaultViewBackground DefaultErrorForegroundColor |
|
20 |
DefaultErrorBackgroundColor DefaultWarningBackgroundColor |
|
21 |
DefaultWarningForegroundColor WorkspaceVariables DoItHistory |
|
22 |
Sniplets' |
|
23 |
poolDictionaries:'' |
|
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 |
|
4619 | 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 |
||
4453
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
154 |
'it' 'ifTrue:[!!' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
155 |
'if' 'ifFalse:[!!' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
156 |
'itf' 'ifTrue:[!!] ifFalse:[].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
157 |
'int' 'isNil ifTrue:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
158 |
'inf' 'isNil ifFalse:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
159 |
'ints' 'isNil ifTrue:[^ self].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
160 |
'infs' 'isNil ifFalse:[^ self].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
161 |
'nnt' 'notNil ifTrue:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
162 |
'nnf' 'notNil ifFalse:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
163 |
'iet' 'isEmpty ifTrue:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
164 |
'net' 'notEmpty ifTrue:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
165 |
'ief' 'isEmpty ifFalse:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
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 |
|
4453
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
192 |
'ex' 'Error handle:[ex | !!] do:[].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
193 |
'sh' 'self halt.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
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' |
|
4453
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
209 |
'sr' 'self subclassResponsibility.' |
3807 | 210 |
|
211 |
'ati' 'at:!! ifAbsent: ' |
|
212 |
'atip' 'at:!! ifAbsentPut:[ ] ' |
|
213 |
'ap' 'at:!! ' |
|
214 |
||
215 |
'st' 'Smalltalk' |
|
4453
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
216 |
'ts' 'Transcript showCR:''!!''.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
217 |
'trs' 'Transcript showCR:''!!''.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
218 |
'abb' 'Workspace sniplets inspect.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
219 |
'ws' 'Delay waitForSeconds: 1.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
220 |
'wfs' 'Delay waitForSeconds: 1.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
221 |
'wfm' 'Delay waitForMilliseconds: 1000.' |
3807 | 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 |
|
4453
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
280 |
"Modified: / 26-09-2012 / 14:48:42 / 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:[ |
|
4542 | 397 |
"it's a variable only" |
2726 | 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 |
]. |
|
410 |
! ! |
|
411 |
||
1523
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
412 |
!Workspace class methodsFor:'queries'! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
413 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
414 |
isVisualStartable |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
415 |
"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
|
416 |
(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
|
417 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
418 |
^ self == Workspace |
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 |
"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
|
421 |
"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
|
422 |
! ! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
423 |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
424 |
!Workspace class methodsFor:'workspace variables'! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
425 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
426 |
addWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
427 |
"create a new workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
428 |
|
1933 | 429 |
|holder| |
430 |
||
3325 | 431 |
holder := self workspaceVariables at:name ifAbsentPut:[ ValueHolder new ]. |
1933 | 432 |
^ holder |
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
433 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
434 |
|
3157 | 435 |
anyWorkspaceVariableIsDefined |
436 |
^ WorkspaceVariables notEmptyOrNil |
|
437 |
||
438 |
"Created: / 20-04-2005 / 11:57:53 / cg" |
|
439 |
! |
|
440 |
||
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
441 |
removeAllWorkspaceVariables |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
442 |
"delete all workspace variables" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
443 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
444 |
WorkspaceVariables := nil |
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 |
|
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 |
removeWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
450 |
"delete a workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
451 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
452 |
WorkspaceVariables notNil ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
453 |
WorkspaceVariables removeKey:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
454 |
WorkspaceVariables isEmpty ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
455 |
WorkspaceVariables := nil |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
456 |
] |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
457 |
]. |
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 |
workspaceVariableAt:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
463 |
"retrieve a workspace variable (actually, a holder onto it)" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
464 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
465 |
WorkspaceVariables isNil ifTrue:[^ nil]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
466 |
^ WorkspaceVariables at:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
467 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
468 |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
469 |
! |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
470 |
|
3157 | 471 |
workspaceVariableNames |
472 |
"retrieve the collection of workspace variable names" |
|
473 |
||
474 |
WorkspaceVariables isNil ifTrue:[^ #()]. |
|
475 |
^ WorkspaceVariables keys |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
476 |
|
3157 | 477 |
"Created: / 20-04-2005 / 11:42:45 / cg" |
478 |
! |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
479 |
|
3157 | 480 |
workspaceVariables |
481 |
"retrieve the collection of workspace variables. |
|
482 |
That is a dictionary associating names to values." |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
483 |
|
3325 | 484 |
WorkspaceVariables isNil ifTrue:[ |
485 |
WorkspaceVariables := Dictionary new. |
|
486 |
]. |
|
487 |
^ WorkspaceVariables |
|
3157 | 488 |
|
489 |
"Modified: / 20-04-2005 / 11:43:14 / cg" |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
490 |
! ! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
491 |
|
201 | 492 |
!Workspace methodsFor:'accessing'! |
0 | 493 |
|
3428 | 494 |
allowValueDrop:aBoolean |
495 |
"if on (the default), any smalltalk value can be dropped and leads to a workspace variable |
|
496 |
holding on to that being defined. Can be turned off, if youdont like this (for standAlone apps)" |
|
497 |
||
498 |
allowValueDrop := aBoolean. |
|
499 |
||
500 |
"Created: / 28-11-2006 / 16:13:02 / cg" |
|
501 |
! |
|
502 |
||
2679 | 503 |
autoDefineVariables |
4090 | 504 |
"undefined variables handling: |
505 |
are automatically defined as workspace variable if autoDefineVariables is #workspace. |
|
506 |
are automatically defined as doit variable if autoDefineVariables is #doit. |
|
507 |
are left undefined if autoDefineVariables is nil." |
|
508 |
||
2679 | 509 |
^ autoDefineVariables |
2535 | 510 |
! |
511 |
||
2679 | 512 |
autoDefineVariables:nilOrSymbol |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
513 |
"undefined variables handling: |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
514 |
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
|
515 |
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
|
516 |
are left undefined if nilOrSymbol is nil." |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
517 |
|
2679 | 518 |
autoDefineVariables := nilOrSymbol. |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
519 |
|
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
520 |
"Modified: / 28-11-2006 / 16:21:01 / cg" |
2679 | 521 |
! |
2535 | 522 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
523 |
commentStrings:anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
524 |
"define the comment strings" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
525 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
526 |
commentStrings := anArrayOfCommentStrings |
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 |
"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
|
529 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
530 |
|
201 | 531 |
doItAction |
532 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 533 |
|
201 | 534 |
^ doItAction |
0 | 535 |
! |
536 |
||
4584 | 537 |
doItAction:aOneArgBlock |
538 |
"define the action to be performed when 'doIt' is selected. |
|
539 |
The block will be evaluated, passing the selection as a String argument. |
|
540 |
A default doItAction is set for you in the initialize method." |
|
541 |
||
542 |
doItAction := aOneArgBlock |
|
543 |
||
544 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
545 |
! |
|
546 |
||
4606 | 547 |
editedMethodOrClass |
548 |
"for the code completion" |
|
549 |
||
550 |
^ editedMethodOrClass. |
|
551 |
! |
|
552 |
||
553 |
editedMethodOrClass:aMethodOrClass |
|
554 |
"for the code completion" |
|
555 |
||
556 |
editedMethodOrClass := aMethodOrClass. |
|
557 |
! |
|
558 |
||
3007 | 559 |
errorBackgroundColor |
560 |
errorBgColor notNil ifTrue:[ ^ errorBgColor ]. |
|
561 |
DefaultErrorBackgroundColor notNil ifTrue:[ ^ DefaultErrorBackgroundColor ]. |
|
562 |
device hasColors ifTrue:[ ^ Color red ]. |
|
563 |
||
564 |
^ selectionBgColor |
|
565 |
! |
|
566 |
||
567 |
errorForegroundColor |
|
568 |
errorFgColor notNil ifTrue:[ ^ errorFgColor ]. |
|
569 |
DefaultErrorForegroundColor notNil ifTrue:[ ^ DefaultErrorForegroundColor ]. |
|
570 |
^ selectionFgColor |
|
571 |
! |
|
572 |
||
4436 | 573 |
nameSpaceForDoits:aNameSpaceOrNil |
574 |
"can be used by the embedding application to control doIt execution |
|
575 |
(especially: for tools like expecco, to provide better workspaces" |
|
576 |
||
577 |
namespaceForDoits := aNameSpaceOrNil. |
|
578 |
||
579 |
"Created: / 26-07-2012 / 23:06:04 / cg" |
|
580 |
! |
|
581 |
||
4391 | 582 |
namespaceForDoits:aNameSpaceOrNil |
583 |
"can be used by the embedding application to control doIt execution |
|
584 |
(especially: for tools like expecco, to provide better workspaces" |
|
585 |
||
4436 | 586 |
<resource: #obsolete> |
587 |
||
4391 | 588 |
namespaceForDoits := aNameSpaceOrNil. |
589 |
||
590 |
"Created: / 04-03-2012 / 13:34:51 / cg" |
|
591 |
! |
|
592 |
||
593 |
poolsConsideredInDoIts:aCollectionOfPools |
|
594 |
"can be used by the embedding application to control doIt execution |
|
595 |
(especially: for tools like expecco, to provide better workspaces" |
|
596 |
||
597 |
poolsConsideredInDoIts := aCollectionOfPools. |
|
598 |
||
599 |
"Modified (format): / 04-03-2012 / 13:35:00 / cg" |
|
3537 | 600 |
! |
601 |
||
2601 | 602 |
simulatedSelf:anObject |
603 |
"define what self is in an evaluation" |
|
604 |
||
605 |
simulatedSelf := anObject |
|
3007 | 606 |
! |
607 |
||
608 |
warningBackgroundColor |
|
609 |
DefaultWarningBackgroundColor notNil ifTrue:[ ^ DefaultWarningBackgroundColor ]. |
|
610 |
device hasColors ifTrue:[ ^ Color orange ]. |
|
611 |
||
612 |
^ selectionBgColor |
|
613 |
! |
|
614 |
||
615 |
warningForegroundColor |
|
616 |
DefaultWarningForegroundColor notNil ifTrue:[ ^ DefaultWarningForegroundColor ]. |
|
617 |
^ selectionFgColor |
|
201 | 618 |
! ! |
619 |
||
620 |
!Workspace methodsFor:'compiler interface'! |
|
621 |
||
2303 | 622 |
compilerClass |
4432
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
623 |
^ compilerClass "? Compiler" |
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
624 |
|
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
625 |
"Modified: / 19-07-2012 / 17:04:35 / cg" |
2980 | 626 |
! |
627 |
||
628 |
compilerClass:aCompilerClass |
|
629 |
compilerClass := aCompilerClass |
|
2303 | 630 |
! |
631 |
||
201 | 632 |
currentSourceCode |
633 |
"special interface to compiler - called by parser |
|
634 |
to get the updated source code after a corrected error" |
|
635 |
||
636 |
^ self contents |
|
0 | 637 |
! |
638 |
||
201 | 639 |
wantChangeLog |
640 |
"sent by the compiler to ask if a changeLog entry should |
|
641 |
be written. Return true here." |
|
0 | 642 |
|
201 | 643 |
^ true |
0 | 644 |
! ! |
645 |
||
2754 | 646 |
!Workspace methodsFor:'compiler interface-error handling'! |
0 | 647 |
|
201 | 648 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
649 |
"compiler notifies us of a correctable error; |
|
650 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
651 |
this method should return true to the compiler if user wants the error |
|
652 |
to be corrected; false otherwise" |
|
653 |
||
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
654 |
|action sameForAllHolder| |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
655 |
|
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
656 |
sameForAllHolder := false asValue. |
201 | 657 |
|
658 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
3383 | 659 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
660 |
|box declareButton| |
|
661 |
||
662 |
box := ex parameter. |
|
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
663 |
|
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
664 |
SameForAllNotification isHandled ifTrue:[ |
4386 | 665 |
box addCheckBoxAtBottom:'Same action for all' on:sameForAllHolder |
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
666 |
]. |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
667 |
|
3383 | 668 |
declareButton := box buttons at:2. |
669 |
declareButton pressAction:declareButton controller releaseAction. |
|
670 |
declareButton controller beTriggerOnDown. |
|
671 |
ex proceed. |
|
672 |
] do:[ |
|
673 |
action := OptionBox |
|
674 |
request:aString |
|
3592
cb6f9f060e62
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3579
diff
changeset
|
675 |
label:(resources string:'Correctable Error') |
3383 | 676 |
image:(WarningBox iconBitmap) |
3592
cb6f9f060e62
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3579
diff
changeset
|
677 |
buttonLabels:(resources array:#('Cancel' 'Declare as...' 'Correct...' 'Continue')) |
3383 | 678 |
values:#(#abort #declare #correct #continue) |
679 |
default:#continue |
|
680 |
onCancel:#abort. |
|
681 |
]. |
|
201 | 682 |
]. |
683 |
||
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
684 |
sameForAllHolder value ifTrue:[ |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
685 |
SameForAllNotification notify |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
686 |
]. |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
687 |
|
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
688 |
action == #declare ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
689 |
^ action |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
690 |
]. |
201 | 691 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
692 |
AbortOperationRequest raise. |
368 | 693 |
^ false |
201 | 694 |
]. |
368 | 695 |
^ action == #correct |
696 |
||
4386 | 697 |
"Modified: / 28-02-2012 / 10:42:27 / cg" |
201 | 698 |
! |
699 |
||
2104 | 700 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
701 |
"compiler notifies us of a correctable selector warning; |
|
702 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
703 |
this method should return true to the compiler if user wants the error |
|
704 |
to be corrected; false otherwise" |
|
705 |
||
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
706 |
|action doNotShowAgainHolder| |
2104 | 707 |
|
3261 | 708 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
709 |
doNotShowAgainHolder := false asValue. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
710 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
4617 | 711 |
MessageNotUnderstood catch:[ |
712 |
(aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
|
713 |
ex box addCheckBoxAtBottom:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
|
714 |
]. |
|
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
715 |
]. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
716 |
ex proceed. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
717 |
] do:[ |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
718 |
action := OptionBox |
2104 | 719 |
request:aString |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
720 |
label:(resources string:'Warning') |
2983
910b4d5f7b1b
dont send obsolete message (OptionBox request:..form:..)
Claus Gittinger <cg@exept.de>
parents:
2982
diff
changeset
|
721 |
image:(WarningBox iconBitmap) |
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
722 |
buttonLabels:(resources array:#('Cancel' 'Correct...' 'Generate' 'Continue')) |
2338 | 723 |
values:#(#abort #correct #generate #continue) |
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
724 |
default:#continue |
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
725 |
onCancel:#abort. |
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
726 |
]. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
727 |
doNotShowAgainHolder value == true ifTrue:[ |
4386 | 728 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
729 |
]. |
2104 | 730 |
]. |
731 |
||
2338 | 732 |
action == #generate ifTrue:[ |
733 |
^ action |
|
734 |
]. |
|
735 |
||
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
736 |
(action isNil or:[action == #abort]) ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
737 |
AbortOperationRequest raise. |
2104 | 738 |
^ false |
739 |
]. |
|
740 |
^ action == #correct |
|
741 |
||
4386 | 742 |
"Created: / 19-01-2000 / 16:27:28 / cg" |
743 |
"Modified: / 28-02-2012 / 10:42:37 / cg" |
|
2104 | 744 |
! |
745 |
||
4188
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
746 |
correctableWarning:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
747 |
"compiler notifies us of a correctable warning; |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
748 |
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
|
749 |
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
|
750 |
to be corrected; false otherwise" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
751 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
752 |
^ self correctableError:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
753 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
754 |
"Created: / 02-11-2010 / 13:29:01 / cg" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
755 |
! |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
756 |
|
201 | 757 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 758 |
"obsolete - no longer invoked" |
759 |
||
760 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
761 |
! |
|
762 |
||
763 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
764 |
"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
|
765 |
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
|
766 |
Return true for correction, false of not (or not possible)" |
2277 | 767 |
|
768 |
^ 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
|
769 |
|
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
770 |
"Modified (Comment): / 30-06-2011 / 19:47:36 / cg" |
2277 | 771 |
! |
772 |
||
773 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
3397 | 774 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
201 | 775 |
and show a Box asking for continue/abort." |
776 |
||
3007 | 777 |
|answer fg bg| |
201 | 778 |
|
3007 | 779 |
fg := asWarning ifTrue:[ self warningForegroundColor ] ifFalse:[ self errorForegroundColor ]. |
780 |
bg := asWarning ifTrue:[ self warningBackgroundColor ] ifFalse:[ self errorBackgroundColor ]. |
|
201 | 781 |
|
3397 | 782 |
self |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
783 |
highlightingErrorPosition:relPos to:relEndPos |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
784 |
withForeground:fg andBackground:bg |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
785 |
do:[ |
4386 | 786 |
|box lbl doNotShowAgainHolder doNotShowAgainForThisMethodHolder l1 y1 y2 l2| |
201 | 787 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
788 |
"/ Warning isHandled ifTrue:[ |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
789 |
"/ Warning raiseErrorString:aString. |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
790 |
"/ ^ false |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
791 |
"/ ]. |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
792 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
793 |
lbl := aCompiler isNil ifTrue:['Compiler'] ifFalse:[aCompiler class name]. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
794 |
asWarning ifTrue:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
795 |
lbl := lbl , ' Warning' |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
796 |
] ifFalse:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
797 |
lbl := lbl , ' Error'. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
798 |
]. |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
799 |
|
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
800 |
" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
801 |
ask if we should abort or continue |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
802 |
" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
803 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
4386 | 804 |
|box makeSpace| |
805 |
||
806 |
doNotShowAgainHolder := false asValue. |
|
807 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
808 |
||
809 |
box := ex box. |
|
4504 | 810 |
box label:lbl. |
811 |
box perform:#image: with:(WarningBox iconBitmap) ifNotUnderstood:[]. |
|
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
812 |
|
4386 | 813 |
aCompiler notNil ifTrue:[ |
814 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
815 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
816 |
makeSpace value. |
|
817 |
box verticalPanel |
|
818 |
add:(CheckBox label:'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
819 |
model:doNotShowAgainHolder). |
|
820 |
]. |
|
821 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
822 |
makeSpace value. |
|
823 |
box verticalPanel |
|
4398 | 824 |
add:(CheckBox label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
4386 | 825 |
model:doNotShowAgainForThisMethodHolder). |
826 |
]. |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
827 |
]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
828 |
ex proceed. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
829 |
] do:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
830 |
answer := OptionBox |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
831 |
request:aString |
4279
f944300bc0be
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4278
diff
changeset
|
832 |
buttonLabels:(resources array:#('Abort' "'Keep Selected'" 'Continue')) |
f944300bc0be
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4278
diff
changeset
|
833 |
values:#(false "#keepSelected" true) |
4278
b13960d1a2cc
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4274
diff
changeset
|
834 |
default:(asWarning ifTrue:true ifFalse:false). |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
835 |
]. |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
836 |
"/ box := YesNoBox |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
837 |
"/ title:aString |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
838 |
"/ yesText:(resources string:'Continue') |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
839 |
"/ noText:(resources string:'Abort'). |
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 |
"/ box label:lbl. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
842 |
"/ box image:(WarningBox iconBitmap). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
843 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
844 |
"/ (aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
845 |
"/ doNotShowAgainHolder := false asValue. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
846 |
"/ 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
|
847 |
"/ ]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
848 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
849 |
"/ "/ answer := box confirm. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
850 |
"/ answer := box confirm. |
3007 | 851 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
852 |
doNotShowAgainHolder value == true ifTrue:[ |
4125
eeed55ffc143
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4103
diff
changeset
|
853 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
854 |
]. |
4386 | 855 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
856 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
857 |
]. |
|
3007 | 858 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
859 |
"/ box destroy. |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
860 |
]. |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
861 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
862 |
answer == #keepSelected ifTrue:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
863 |
self hideCursor. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
864 |
"redraw selection in normal color" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
865 |
self invalidate. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
866 |
AbortOperationRequest raise. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
867 |
]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
868 |
|
201 | 869 |
" |
870 |
do the abort if we have to |
|
871 |
" |
|
3397 | 872 |
answer ifFalse:[ |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
873 |
"redraw selection in normal color" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
874 |
self invalidate. |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
875 |
AbortOperationRequest raise. |
201 | 876 |
]. |
877 |
^ 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
|
878 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
879 |
"Created: / 24-11-1995 / 22:56:34 / cg" |
4398 | 880 |
"Modified: / 08-03-2012 / 10:24:21 / cg" |
201 | 881 |
! |
882 |
||
2663 | 883 |
highlightingErrorLine:lineNr do:aBlock |
884 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
885 |
||
886 |
|linePosition| |
|
887 |
||
888 |
linePosition := self characterPositionOfLine:lineNr col:1. |
|
889 |
self highlightingErrorPosition:linePosition to:nil do:aBlock |
|
890 |
! |
|
891 |
||
59 | 892 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
893 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 894 |
|
3007 | 895 |
self |
896 |
highlightingErrorPosition:relPos to:relEndPos |
|
897 |
withForeground:(self errorForegroundColor) andBackground:(self errorBackgroundColor) |
|
898 |
do:aBlock |
|
899 |
! |
|
900 |
||
901 |
highlightingErrorPosition:relPos to:relEndPos withForeground:hilightFg andBackground:hilightBg do:aBlock |
|
902 |
"evaluate aBlock while some selection is shown highlighted with colors passed as args." |
|
903 |
||
904 |
|absPosition oldFg oldBg| |
|
0 | 905 |
|
58 | 906 |
" |
907 |
change color of selection & hide cursor |
|
908 |
" |
|
3007 | 909 |
oldFg := selectionFgColor. |
910 |
oldBg := selectionBgColor. |
|
911 |
selectionBgColor := hilightBg. |
|
912 |
selectionFgColor := hilightFg. |
|
58 | 913 |
self hideCursor. |
0 | 914 |
|
58 | 915 |
" |
916 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
917 |
we have to adjust the positions given by the compiler, since they |
|
918 |
are relative to the texts start (the compiler did stream-read the code). |
|
919 |
" |
|
0 | 920 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
3427 | 921 |
absPosition := codeStartPosition + (relPos ? 1) - 1. |
0 | 922 |
relEndPos isNil ifTrue:[ |
4141
06c97cc2bf6d
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
923 |
self selectFromCharacterPosition:absPosition. |
06c97cc2bf6d
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
924 |
"/ self selectLineWhereCharacterPosition:absPosition. |
0 | 925 |
] ifFalse:[ |
3427 | 926 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + (relEndPos ? 1) - 1) |
0 | 927 |
]. |
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
928 |
expandingTop := true. "/ hack to make the top of the selection visible |
0 | 929 |
self makeSelectionVisible. |
930 |
||
155 | 931 |
device flush. |
58 | 932 |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
933 |
aBlock ensure:[ |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
934 |
" |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
935 |
undo selection color change and show cursor again |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
936 |
" |
3007 | 937 |
selectionFgColor := oldFg. |
938 |
selectionBgColor := oldBg. |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
939 |
self showCursor. |
0 | 940 |
]. |
3427 | 941 |
|
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
942 |
"Modified: / 30-06-2011 / 17:24:04 / cg" |
0 | 943 |
! |
944 |
||
3007 | 945 |
highlightingWarningPosition:relPos to:relEndPos do:aBlock |
946 |
"evaluate aBlock while some selection is shown highlighted with warning colors." |
|
947 |
||
948 |
self |
|
949 |
highlightingErrorPosition:relPos to:relEndPos |
|
950 |
withForeground:(self warningForegroundColor) andBackground:(self warningBackgroundColor) |
|
951 |
do:aBlock |
|
952 |
! |
|
953 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
954 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
955 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
956 |
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
|
957 |
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
|
958 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
959 |
|
4386 | 960 |
|action doNotShowAgainHolder doNotShowAgainForThisMethodHolder| |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
961 |
|
3007 | 962 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
963 |
doNotShowAgainHolder := false asValue. |
4386 | 964 |
doNotShowAgainForThisMethodHolder := false asValue. |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
965 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
4386 | 966 |
|box makeSpace| |
967 |
||
968 |
box := ex box. |
|
969 |
aCompiler notNil ifTrue:[ |
|
970 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
971 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
972 |
makeSpace value. |
|
973 |
box verticalPanel |
|
974 |
add:(CheckBox |
|
975 |
label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
976 |
model:doNotShowAgainHolder). |
|
977 |
]. |
|
978 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
979 |
makeSpace value. |
|
980 |
box verticalPanel |
|
981 |
add:(CheckBox |
|
4398 | 982 |
label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
4386 | 983 |
model:doNotShowAgainForThisMethodHolder). |
984 |
]. |
|
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
985 |
]. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
986 |
ex proceed. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
987 |
] do:[ |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
988 |
action := OptionBox |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
989 |
request:aString |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
990 |
label:(resources string:'Warning') |
2990
1373f301a694
dont send obsolete message to OptionBox
Claus Gittinger <cg@exept.de>
parents:
2983
diff
changeset
|
991 |
image:(WarningBox iconBitmap) |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
992 |
buttonLabels:(resources array:#('Cancel' 'Remove Variable(s)' 'Continue')) |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
993 |
values:#(#abort #correct #continue) |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
994 |
default:#continue. |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
995 |
]. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
996 |
doNotShowAgainHolder value == true ifTrue:[ |
4386 | 997 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
998 |
]. |
|
999 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
1000 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1001 |
]. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1002 |
]. |
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 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
1005 |
AbortOperationRequest raise. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1006 |
^ false |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1007 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1008 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
1009 |
|
4398 | 1010 |
"Modified: / 08-03-2012 / 10:23:58 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1011 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1012 |
|
116 | 1013 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 1014 |
"compiler notifies us of a warning - same behavior as error" |
0 | 1015 |
|
2277 | 1016 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 1017 |
! ! |
1018 |
||
3396 | 1019 |
!Workspace methodsFor:'drag & drop'! |
1020 |
||
1021 |
canDrop:aDropContext |
|
4090 | 1022 |
"if allowValueDrop is true, any text- or file-object can be dropped into workspace |
1023 |
(printString); otherwise, only ..." |
|
1024 |
||
1025 |
self isReadOnly ifTrue:[^ false]. |
|
3396 | 1026 |
|
4090 | 1027 |
allowValueDrop ifTrue:[^ true]. |
1028 |
^ super canDrop:aDropContext |
|
3428 | 1029 |
|
4090 | 1030 |
"/ ^ aDropContext dropObjects |
1031 |
"/ contains:[:someObject| (someObject isTextObject or:[ someObject isFileObject ])]. |
|
3396 | 1032 |
|
1033 |
"Created: / 16-08-2005 / 22:01:13 / janfrog" |
|
3428 | 1034 |
"Modified: / 28-11-2006 / 16:18:51 / cg" |
3396 | 1035 |
! |
1036 |
||
3414 | 1037 |
doDrop:aDropContext |
4631 | 1038 |
<resource: #obsolete> |
1039 |
self obsoleteMethodWarning:'should no longer be reached'. |
|
3428 | 1040 |
self drop:aDropContext |
3414 | 1041 |
|
3428 | 1042 |
"Modified: / 28-11-2006 / 16:14:51 / cg" |
4386 | 1043 |
"Modified (format): / 28-02-2012 / 11:20:38 / cg" |
3414 | 1044 |
! |
1045 |
||
1046 |
drop:aDropContext |
|
1047 |
"Any object can be dropped into workspace..." |
|
1048 |
||
3870 | 1049 |
|textObjects nonTextObjects answer text| |
1050 |
||
1051 |
textObjects := aDropContext dropObjects |
|
3887 | 1052 |
select:[:dropObject | dropObject isTextObject |
1053 |
or:[ dropObject isFileObject ]]. |
|
3870 | 1054 |
nonTextObjects := aDropContext dropObjects |
3887 | 1055 |
reject:[:dropObject | dropObject isTextObject |
1056 |
or:[ dropObject isFileObject ]]. |
|
3870 | 1057 |
|
1058 |
self dropObjects:textObjects. |
|
3414 | 1059 |
|
3870 | 1060 |
nonTextObjects notEmpty ifTrue:[ |
1061 |
answer := Dialog |
|
1062 |
confirmWithCancel:(resources |
|
1063 |
string:'Drop as textual representation or as object reference ?') |
|
1064 |
labels:(resources array:#('Cancel' 'Reference' 'Name' 'Text')) |
|
1065 |
values:#(nil #ref #name #text) |
|
1066 |
default:4. |
|
1067 |
answer isNil ifTrue:[^ self]. |
|
1068 |
(answer == #text or:[answer == #name]) ifTrue:[ |
|
1069 |
text := String streamContents:[:s | |
|
1070 |
nonTextObjects do:[:dropObject | |
|
1071 |
|obj| |
|
1072 |
||
1073 |
obj := dropObject theObject. |
|
1074 |
obj isMethod ifTrue:[ |
|
1075 |
s nextPutAll:(answer == #name ifTrue:[obj selector] ifFalse:[obj source]). |
|
1076 |
] ifFalse:[ |
|
1077 |
obj isClass ifTrue:[ |
|
1078 |
s nextPutAll:(answer == #name ifTrue:[obj name] ifFalse:[obj source asString]) |
|
1079 |
] ifFalse:[ |
|
1080 |
s nextPutAll:(answer == #name ifTrue:[obj className] ifFalse:[obj printString]) . |
|
1081 |
]. |
|
1082 |
]. |
|
1083 |
]. |
|
1084 |
]. |
|
1085 |
self paste:text. |
|
3414 | 1086 |
] ifFalse:[ |
3870 | 1087 |
nonTextObjects do:[:dropObject | |
1088 |
name := Dialog |
|
1089 |
request:(resources |
|
1090 |
string:'Name of the new Workspace Variable (refers to the dropped %1):' |
|
1091 |
with:dropObject theObject class name allBold |
|
1092 |
) |
|
1093 |
initialAnswer:'droppedObject' |
|
1094 |
okLabel:'Add' |
|
1095 |
title:'Enter Variable Name'. |
|
3414 | 1096 |
|
3870 | 1097 |
name notEmptyOrNil ifTrue:[ |
1098 |
Workspace addWorkspaceVariable:name. |
|
1099 |
(Workspace workspaceVariableAt:name) value:dropObject theObject. |
|
1100 |
self paste:name. |
|
1101 |
]. |
|
3414 | 1102 |
]. |
3870 | 1103 |
] |
3414 | 1104 |
]. |
1105 |
||
1106 |
"Created: / 13-10-2006 / 17:34:07 / cg" |
|
3396 | 1107 |
! ! |
1108 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1109 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1110 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1111 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1112 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1113 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1114 |
in the first col |
1115 |
(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
|
1116 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1117 |
|eolComment opening closing| |
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 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1120 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1121 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1122 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1123 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1124 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1125 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1126 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1127 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1128 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1129 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1130 |
l isNil ifTrue:[l := '']. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1131 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1132 |
l := eolComment , l |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1133 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1134 |
l := opening , l , closing |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1135 |
]. |
3403 | 1136 |
self replaceLine:lineNr with:l. |
1137 |
widthOfWidestLine notNil ifTrue:[ |
|
1138 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1139 |
]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1140 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1141 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1142 |
|
3403 | 1143 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
1144 |
"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
|
1145 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1146 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1147 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1148 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1149 |
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
|
1150 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1151 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1152 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1153 |
|
1481 | 1154 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3210 | 1155 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
1156 |
||
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1157 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1158 |
self |
3785 | 1159 |
undoableDo:[ self commentFrom:cursorLine to:cursorLine ] |
3543 | 1160 |
info:'Comment'. |
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1161 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1162 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1163 |
|
3129 | 1164 |
self |
1165 |
undoableDo: |
|
1166 |
[ |
|
1167 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1168 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
|
1169 |
] ifFalse:[ |
|
3210 | 1170 |
commentPair := commentStrings at:2 ifAbsent:nil. |
1171 |
commentPair isNil ifTrue:[ |
|
1172 |
self beep. |
|
1173 |
] ifFalse:[ |
|
1174 |
opening := commentPair at:1. |
|
1175 |
closing := commentPair at:2. |
|
1176 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
3129 | 1177 |
|
3210 | 1178 |
e := selectionEndCol. |
1179 |
||
1180 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
1181 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
3129 | 1182 |
|
3210 | 1183 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
1184 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1185 |
toLine:selectionEndLine col:e+closing size. |
|
1186 |
] |
|
3129 | 1187 |
] |
1188 |
] |
|
1189 |
info:'comment' |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1190 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1191 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 1192 |
"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
|
1193 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1194 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1195 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1196 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1197 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1198 |
in the first col. |
1199 |
(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
|
1200 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1201 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1202 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1203 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1204 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1205 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1206 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1207 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1208 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1209 |
rest := eolComment size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1210 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1211 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1212 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1213 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1214 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1215 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1216 |
l notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1217 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1218 |
(l startsWith:eolComment) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1219 |
l := l copyFrom:rest |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1220 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1221 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1222 |
((l startsWith:opening) |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1223 |
and:[l endsWith:closing]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1224 |
l := l copyFrom:opening size + 1. |
4568
cf9f6fd6d174
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4542
diff
changeset
|
1225 |
l := l copyButLast:closing size. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1226 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1227 |
]. |
3403 | 1228 |
self replaceLine:lineNr with:l. |
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 |
]. |
3403 | 1231 |
widthOfWidestLine := nil. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1232 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1233 |
|
3403 | 1234 |
"Created: / 09-11-1997 / 01:05:43 / cg" |
1235 |
"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
|
1236 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1237 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1238 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1239 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1240 |
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
|
1241 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1242 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1243 |
|e commentPair opening closing sz1 sz2| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1244 |
|
3129 | 1245 |
(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
|
1246 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1247 |
self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1248 |
undoableDo:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1249 |
self uncommentFrom:cursorLine to:cursorLine |
3543 | 1250 |
] |
1251 |
info:'Uncomment'. |
|
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1252 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1253 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1254 |
|
3129 | 1255 |
self |
1256 |
undoableDo: |
|
1257 |
[ |
|
1258 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1259 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
|
1260 |
] ifFalse:[ |
|
1261 |
commentPair := commentStrings at:2. |
|
1262 |
opening := commentPair at:1. |
|
1263 |
closing := commentPair at:2. |
|
1264 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1265 |
||
1266 |
sz1 := opening size. |
|
1267 |
sz2 := closing size. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1268 |
|
3129 | 1269 |
((self |
1270 |
stringAtLine:selectionStartLine |
|
1271 |
from:selectionStartCol |
|
1272 |
to:selectionStartCol+sz1 - 1) = opening |
|
1273 |
and:[(self |
|
1274 |
stringAtLine:selectionEndLine |
|
1275 |
from:selectionEndCol - sz2 + 1 |
|
1276 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1277 |
|
3129 | 1278 |
self deleteCharsAtLine:selectionEndLine fromCol:selectionEndCol-sz2+1 toCol:selectionEndCol. |
1279 |
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
|
1280 |
|
3129 | 1281 |
e := selectionEndCol - sz2. |
1282 |
selectionStartLine == selectionEndLine ifTrue:[e := e - sz1]. |
|
1283 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1284 |
toLine:selectionEndLine col:e. |
|
1285 |
] |
|
1286 |
] |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1287 |
] |
3129 | 1288 |
info:'uncomment' |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1289 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1290 |
"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
|
1291 |
"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
|
1292 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1293 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1294 |
!Workspace methodsFor:'event handling'! |
3712 | 1295 |
|
0 | 1296 |
keyPress:key x:x y:y |
4587 | 1297 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #ReplaceIt |
1298 |
#BrowseIt #ImplementorsOfIt #ExpandAbbreviation |
|
1299 |
#CommentSelection #UncommentSelection)> |
|
60 | 1300 |
|
3800 | 1301 |
(key == #DoIt) ifTrue:[self doIt. ^ self]. |
1302 |
(key == #InspectIt) ifTrue:[self inspectIt. ^ self]. |
|
1303 |
(key == #PrintIt) ifTrue:[self printIt. ^ self]. |
|
1304 |
(key == #ReplaceIt) ifTrue:[self replaceIt. ^ self]. |
|
1305 |
(key == #BrowseIt) ifTrue:[self browseIt. ^ self]. |
|
1306 |
(key == #ImplementorsOfIt) ifTrue:[self browseImplementorsOfIt. ^ self]. |
|
1307 |
(key == #ExpandAbbreviation) ifTrue:[self expandAbbreviation. ^ self]. |
|
4587 | 1308 |
(key == #CommentSelection) ifTrue:[self commentSelection. ^ self]. |
1309 |
(key == #UncommentSelection) ifTrue:[self uncommentSelection. ^ self]. |
|
38 | 1310 |
|
0 | 1311 |
super keyPress:key x:x y:y |
3511 | 1312 |
|
1313 |
"Modified: / 08-11-2007 / 11:29:45 / cg" |
|
0 | 1314 |
! ! |
201 | 1315 |
|
2143 | 1316 |
!Workspace methodsFor:'executing'! |
201 | 1317 |
|
1501 | 1318 |
do:code withValueDo:aBlock |
418 | 1319 |
"helper for doIt, printIt and inspectIt. |
1320 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
1321 |
aBlock with the value. |
|
1322 |
Most work is in preparing for proper cleanup in case of abort |
|
1323 |
or other exception while the evaluation is performed. |
|
1324 |
(restore cursor, selectionColors etc.)" |
|
201 | 1325 |
|
4149 | 1326 |
|selLine selCol endLine endCol cLine cCol cleanUp executeBlock| |
201 | 1327 |
|
1328 |
code notNil ifTrue:[ |
|
2409 | 1329 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
2408 | 1330 |
|
257 | 1331 |
codeStartPosition := self characterPositionOfSelection. |
201 | 1332 |
|
257 | 1333 |
" |
1334 |
remember selection for later - if there is an error, |
|
1335 |
the notification method will highlight it. |
|
1336 |
thus destroying the current selection |
|
1337 |
" |
|
1338 |
selLine := selectionStartLine. |
|
1339 |
selCol := selectionStartCol. |
|
1340 |
endLine := selectionEndLine. |
|
1341 |
endCol := selectionEndCol. |
|
1342 |
cCol := cursorCol. |
|
1343 |
cLine := cursorLine. |
|
201 | 1344 |
|
257 | 1345 |
" |
1346 |
cleanup: restore previous selection and cursor positions |
|
1347 |
" |
|
1348 |
cleanUp := [ |
|
1349 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
1350 |
cLine notNil ifTrue:[ |
|
1351 |
self cursorLine:cLine col:cCol |
|
1352 |
]. |
|
1353 |
]. |
|
201 | 1354 |
|
257 | 1355 |
" |
1356 |
perform the action. |
|
1357 |
Be careful to release the reference to the value; |
|
1358 |
otherwise, we could keep lots of garbage from being freed |
|
1359 |
until the view gets closed |
|
1360 |
" |
|
4149 | 1361 |
executeBlock := [ |
1362 |
[ |
|
1363 |
AbortOperationRequest handle:[:ex | |
|
1364 |
"/ aBlock value:'** Abortsignal cought **'. |
|
1365 |
ex return |
|
1366 |
] do:[ |
|
1367 |
|value| |
|
929 | 1368 |
|
4149 | 1369 |
doItAction notNil ifTrue:[ |
1370 |
value := doItAction value:(code asString). |
|
1371 |
cleanUp value. cleanUp := nil. |
|
1372 |
aBlock notNil ifTrue:[ |
|
1373 |
aBlock value:value. |
|
1374 |
]. |
|
1375 |
value := nil. |
|
1376 |
self class rememberDoIt:code. |
|
1377 |
] |
|
257 | 1378 |
] |
4149 | 1379 |
] ensure:[ |
1380 |
cleanUp notNil ifTrue:[ |
|
1381 |
cleanUp value. cleanUp := nil |
|
1382 |
]. |
|
257 | 1383 |
] |
4149 | 1384 |
]. |
1385 |
aBlock isNil ifTrue:[ |
|
1386 |
"no action is performed with the result - give the user a visible |
|
1387 |
feedback, that something has been done" |
|
1388 |
self topView withVisibleCursor:Cursor execute do:executeBlock. |
|
1389 |
] ifFalse:[ |
|
1390 |
self topView withCursor:Cursor execute do:executeBlock. |
|
257 | 1391 |
]. |
201 | 1392 |
] |
257 | 1393 |
|
1501 | 1394 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
1395 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
2409 | 1396 |
"Modified: / 26.9.2001 / 17:32:59 / cg" |
201 | 1397 |
! ! |
1398 |
||
2751 | 1399 |
!Workspace methodsFor:'initialization & release'! |
201 | 1400 |
|
2733 | 1401 |
executeDoIt:theCode |
4391 | 1402 |
"the core of doIt, printIt, inspectIt, browseIt actions" |
1403 |
||
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1404 |
| result compiler | |
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1405 |
|
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1406 |
"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
|
1407 |
[ |
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1408 |
result := ( compiler := (self compilerClass ? Compiler) new ) |
4438 | 1409 |
currentNameSpace:namespaceForDoits; |
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1410 |
moreSharedPools:poolsConsideredInDoIts; |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1411 |
evaluate:theCode |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1412 |
in:nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1413 |
receiver:simulatedSelf |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1414 |
notifying:self |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1415 |
logged:true |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1416 |
ifFail:nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1417 |
] on: Parser undefinedVariableNotification do:[:ex| |
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1418 |
(ex parser == compiler and:[autoDefineVariables notNil]) ifTrue:[ |
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1419 |
ex proceedWith: #declare |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1420 |
] ifFalse:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1421 |
ex proceedWith: nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1422 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1423 |
] on: Parser askForVariableTypeOfUndeclaredQuery do:[:ex| |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1424 |
autoDefineVariables == #workspace ifTrue:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1425 |
ex proceedWith:#WorkspaceVariable |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1426 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1427 |
autoDefineVariables == #doIt ifTrue:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1428 |
ex proceedWith:#DoItTemporary |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1429 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1430 |
ex pass. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1431 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1432 |
^result |
4391 | 1433 |
|
4438 | 1434 |
"Modified: / 27-07-2012 / 09:33:39 / cg" |
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1435 |
"Modified: / 24-06-2013 / 15:31:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2733 | 1436 |
! |
1437 |
||
201 | 1438 |
initStyle |
966 | 1439 |
"setup viewStyle specifics" |
1440 |
||
201 | 1441 |
super initStyle. |
1442 |
||
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1443 |
DefaultViewBackground notNil ifTrue:[ |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1444 |
viewBackground := DefaultViewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1445 |
self backgroundColor:viewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1446 |
]. |
201 | 1447 |
! |
1448 |
||
1449 |
initialize |
|
1450 |
super initialize. |
|
1451 |
||
4593 | 1452 |
autoIndent := UserPreferences current autoIndentInCodeView. |
2775 | 1453 |
scrollWhenUpdating := #beginOfText. |
201 | 1454 |
showMatchingParenthesis := true. |
3428 | 1455 |
allowValueDrop := true. |
1456 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1457 |
commentStrings := #( |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1458 |
'"/' |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1459 |
('"' '"') |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1460 |
). |
201 | 1461 |
|
1462 |
self initializeDoITAction. |
|
3396 | 1463 |
self initializeDragAndDrop. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1464 |
|
3428 | 1465 |
"Modified: / 28-11-2006 / 16:11:55 / cg" |
201 | 1466 |
! |
1467 |
||
1468 |
initializeDoITAction |
|
1469 |
"set up the block to be evaluated for doIts. |
|
1470 |
This is done here in a separate method to allow easier |
|
1471 |
redefinition in subclasses" |
|
1472 |
||
2733 | 1473 |
doItAction := [:theCode | self executeDoIt:theCode]. |
3396 | 1474 |
! |
1475 |
||
1476 |
initializeDragAndDrop |
|
1477 |
|target| |
|
1478 |
||
1479 |
target := DropTarget |
|
1480 |
receiver:self |
|
1481 |
argument:nil |
|
3411 | 1482 |
dropSelector:#drop: |
3396 | 1483 |
canDropSelector:#canDrop:. |
1484 |
self dropTarget:target |
|
1485 |
||
1486 |
"Created: / 16-08-2005 / 22:03:36 / janfrog" |
|
3411 | 1487 |
"Modified: / 13-10-2006 / 12:37:18 / cg" |
201 | 1488 |
! ! |
1489 |
||
418 | 1490 |
!Workspace methodsFor:'menu & menu actions'! |
1491 |
||
2285 | 1492 |
browseClass |
1493 |
"user selected 'browseClass' from menu; evaluate the code |
|
1494 |
and open a browser on the resulting class (if it evaluates to one)" |
|
1495 |
||
1496 |
^ self |
|
3272 | 1497 |
do:(self selectionAsString) |
3910 | 1498 |
withValueDo:[:result | |
1499 |
result isBehavior ifTrue:[ |
|
1500 |
result browserClass openInClass:result selector:nil |
|
1501 |
] ifFalse:[ |
|
1502 |
self warn:'Selection does not evaluate to a class' |
|
1503 |
] |
|
1504 |
]. |
|
2285 | 1505 |
|
2410 | 1506 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 1507 |
! |
1508 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1509 |
browseImplementorsOfIt |
4617 | 1510 |
"open a browser on the implementors of the selected text, |
1511 |
or - if I support syntax elements, on the syntax element at the cursor position" |
|
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1512 |
|
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1513 |
|selectedText selector browserClass na| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1514 |
|
4617 | 1515 |
selectedText := self selectedTextOrSyntaxElement. |
1516 |
selectedText notEmptyOrNil ifTrue:[ |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1517 |
self windowGroup withWaitCursorDo:[ |
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1518 |
"/ 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
|
1519 |
(compilerClass notNil and:[compilerClass includesBehavior:JavaScriptParser]) ifTrue:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1520 |
"/ selector is in one piece anyway |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1521 |
(selectedText includes:$_) ifFalse:[ |
3896 | 1522 |
"/ 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
|
1523 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:1. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1524 |
selectedText := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:0. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1525 |
] ifTrue:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1526 |
"/ count _#s plus one arg - sigh |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1527 |
na := (selectedText occurrencesOf:$_) + 1. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1528 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:na |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1529 |
]. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1530 |
] ifFalse:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1531 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1532 |
]. |
4619 | 1533 |
browserClass := UserPreferences systemBrowserClass. |
2714 | 1534 |
|
3287 | 1535 |
(selector notNil and:[selector ~= selectedText]) ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1536 |
(SystemBrowser |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1537 |
findImplementorsOfAny:(Array with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1538 |
in:(Smalltalk allClasses) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1539 |
ignoreCase:false) isEmpty ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1540 |
browserClass browseImplementorsOf:selector |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1541 |
] ifFalse:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1542 |
browserClass browseImplementorsOfAny:(Set with:selector with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1543 |
]. |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1544 |
] ifFalse:[ |
2714 | 1545 |
browserClass browseImplementorsOf:(selector ? selectedText) |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1546 |
] |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1547 |
] |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1548 |
]. |
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 |
"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
|
1551 |
"Modified: / 19.11.2001 / 22:15:17 / cg" |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1552 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1553 |
|
2307 | 1554 |
browseIt |
1555 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
2713 | 1556 |
or the class of the resulting object (if it does not evaluate to a class). |
1557 |
||
1558 |
Added feature: if selection is of the form class >> selector, immediately switch to that selector." |
|
1559 |
||
4617 | 1560 |
|codeToEvaluate el idx selector evaluatedValue classToBrowse gotResult| |
2713 | 1561 |
|
4617 | 1562 |
(self selection isEmptyOrNil |
1563 |
and:[ self supportsSyntaxElements |
|
1564 |
and:[ (el := self syntaxElementForVariableUnderCursor) notNil ]]) |
|
1565 |
ifTrue:[ |
|
1566 |
codeToEvaluate := el name |
|
1567 |
] ifFalse:[ |
|
1568 |
codeToEvaluate := (self selectionOrTextOfCursorLine ? '') withoutSeparators. |
|
1569 |
]. |
|
2713 | 1570 |
idx := codeToEvaluate indexOfSubCollection:'>>'. |
1571 |
idx ~~ 0 ifTrue:[ |
|
2717 | 1572 |
selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string. |
3155 | 1573 |
(selector startsWith:'#') ifTrue:[ |
1574 |
selector := Symbol readFrom:selector. |
|
1575 |
]. |
|
2713 | 1576 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
1577 |
]. |
|
2307 | 1578 |
|
3910 | 1579 |
Parser parseErrorSignal handle:[:ex | |
1580 |
|className| |
|
2410 | 1581 |
|
3910 | 1582 |
"/ fallback, if garbage is selected, look for matching classes. |
1583 |
className := SystemBrowser |
|
1584 |
askForClassNameMatching:codeToEvaluate |
|
1585 |
inEnvironment:nil |
|
1586 |
for:nil. |
|
4386 | 1587 |
|
3910 | 1588 |
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
|
1589 |
classToBrowse := Smalltalk classNamed:className. |
3910 | 1590 |
] do:[ |
4386 | 1591 |
gotResult := false. |
1592 |
||
3910 | 1593 |
self |
1594 |
do:codeToEvaluate |
|
4386 | 1595 |
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
|
1596 |
|
4386 | 1597 |
gotResult ifFalse:[^ self]. |
1598 |
||
1599 |
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
|
1600 |
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
|
1601 |
codeToEvaluate isUppercaseFirst ifTrue:[ |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1602 |
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
|
1603 |
^ self. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1604 |
]. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1605 |
] |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1606 |
]. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1607 |
classToBrowse := evaluatedValue isBehavior |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1608 |
ifTrue:[ evaluatedValue ] |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1609 |
ifFalse:[ evaluatedValue class ]. |
3910 | 1610 |
]. |
1611 |
||
1612 |
classToBrowse browserClass openInClass:classToBrowse selector:selector |
|
4386 | 1613 |
|
1614 |
"Modified: / 28-02-2012 / 11:23:06 / cg" |
|
2307 | 1615 |
! |
1616 |
||
2285 | 1617 |
browseItsClass |
1618 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
1619 |
and open a browser on the results class" |
|
1620 |
||
1621 |
^ self |
|
3272 | 1622 |
do:(self selectionAsString) |
2410 | 1623 |
withValueDo:[:result | |
1624 |
result class browserClass openInClass:result class selector:nil |
|
1625 |
] |
|
2285 | 1626 |
|
2410 | 1627 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 1628 |
! |
1629 |
||
2454 | 1630 |
browseReferencesToIt |
1631 |
"open a browser on all references to the selected global" |
|
1632 |
||
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1633 |
|sel| |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1634 |
|
4617 | 1635 |
sel := self selectedTextOrSyntaxElement. |
1636 |
sel notEmptyOrNil ifTrue:[ |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1637 |
self windowGroup withWaitCursorDo:[ |
3959 | 1638 |
(Smalltalk includesKey:sel asSymbol) ifFalse:[ |
1639 |
sel := ((NameSpace allNameSpaces detect:[:ns | ns includesKey:sel asSymbol]) at:sel asSymbol) name. |
|
1640 |
]. |
|
4619 | 1641 |
(UserPreferences systemBrowserClass) |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1642 |
browseReferendsOf:sel |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1643 |
]. |
2454 | 1644 |
]. |
1645 |
||
1646 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
1647 |
"Modified: / 5.11.2001 / 17:32:38 / cg" |
|
1648 |
! |
|
1649 |
||
2462 | 1650 |
browseSendersOfIt |
1651 |
"open a browser on the senders of the selected text" |
|
1652 |
||
2715 | 1653 |
|selectedText selector| |
2462 | 1654 |
|
4617 | 1655 |
selectedText := self selectedTextOrSyntaxElement. |
1656 |
selectedText notEmptyOrNil ifTrue:[ |
|
2462 | 1657 |
self windowGroup withWaitCursorDo:[ |
3287 | 1658 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
4619 | 1659 |
(UserPreferences systemBrowserClass) |
2715 | 1660 |
browseAllCallsOn:(selector ? selectedText) |
2462 | 1661 |
] |
1662 |
]. |
|
1663 |
||
1664 |
"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
|
1665 |
"Modified: / 19.11.2001 / 22:15:27 / cg" |
2462 | 1666 |
! |
1667 |
||
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1668 |
browseSharedPoolOfIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1669 |
"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
|
1670 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1671 |
|sel| |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1672 |
|
4617 | 1673 |
sel := self selectedTextOrSyntaxElement. |
1674 |
sel notEmptyOrNil ifTrue:[ |
|
1675 |
sel := sel asSymbol. |
|
1676 |
self windowGroup withWaitCursorDo:[ |
|
1677 |
SharedPool allSubclassesDo:[:eachPool | |
|
1678 |
(eachPool includesKey:sel) ifTrue:[ |
|
4619 | 1679 |
(UserPreferences systemBrowserClass) |
4617 | 1680 |
openInClass:eachPool class selector:#initialize |
1681 |
]. |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1682 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1683 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1684 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1685 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1686 |
"Created: / 15-01-2011 / 14:01:39 / cg" |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1687 |
! |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1688 |
|
418 | 1689 |
doIt |
1690 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
1691 |
and finally restore cursor; return result of evaluation" |
|
1692 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1693 |
^ self |
3272 | 1694 |
do:(self selectionOrTextOfCursorLine) |
4149 | 1695 |
withValueDo:nil |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1696 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1697 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 1698 |
! |
1699 |
||
1700 |
editMenu |
|
1107 | 1701 |
"return my popUpMenu; thats the superclasses menu |
1702 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
|
1703 |
||
2459 | 1704 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
1705 |
#CommentSelection #UncommentSelection |
|
2573
52c995a1ea78
accelerators for browseIt and implementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
2571
diff
changeset
|
1706 |
#BrowseIt #ImplementorsOfIt |
2459 | 1707 |
)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
1708 |
<resource: #programMenu> |
489 | 1709 |
|
2867 | 1710 |
|m sub subsub idx sensor s s2| |
418 | 1711 |
|
1712 |
m := super editMenu. |
|
3252 | 1713 |
((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
2459 | 1714 |
sub := m. |
1715 |
m := nil. |
|
1716 |
] ifFalse:[ |
|
1717 |
sub := m subMenuAt:#others. |
|
1718 |
]. |
|
418 | 1719 |
|
2459 | 1720 |
sub notNil ifTrue:[ |
2867 | 1721 |
|
2459 | 1722 |
" |
2867 | 1723 |
workspaces support #browse, implementors etc. add them after paste. |
2459 | 1724 |
" |
2867 | 1725 |
sub |
1726 |
addItemList:#( |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1727 |
('-' ) |
3910 | 1728 |
('Browse' browseIt BrowseIt ) |
4617 | 1729 |
('Browse Pool' browseSharedPoolOfIt ) |
3910 | 1730 |
('Senders of It' browseSendersOfIt ) |
1731 |
('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
|
1732 |
('References to It' browseReferencesToIt ) |
|
1733 |
"/ ('Classes Containing It in Name' browseClassesContainingItInName ) |
|
1734 |
"/ ('Methods Contaníning It in Name' browseMethodsContainingItInName ) |
|
1735 |
"/ ('Methods Contaníning It in Source' browseMethodsContainingItInSource ) |
|
2867 | 1736 |
('-' ) |
1737 |
('TimeIt' timeIt ) |
|
1738 |
('SpyOnIt' spyOnIt )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1739 |
resources:resources |
2459 | 1740 |
after:#gotoLine. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1741 |
|
2867 | 1742 |
subsub := sub subMenuAt:#tools. |
1743 |
subsub notNil ifTrue:[ |
|
1744 |
subsub |
|
1745 |
addItemList:#( |
|
1746 |
('-' ) |
|
1747 |
('Comment' commentSelection CommentSelection ) |
|
1748 |
('Uncomment' uncommentSelection UncommentSelection )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1749 |
resources:resources |
2867 | 1750 |
after:#'indent'. |
1751 |
]. |
|
1752 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1753 |
self hasSelection ifFalse:[ |
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1754 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1755 |
browseReferencesToIt timeIt spyOnIt |
4617 | 1756 |
browseSharedPoolOfIt browseIt). |
1757 |
self supportsSyntaxElements ifTrue:[ |
|
1758 |
self syntaxElementForSelectorUnderCursor notNil ifTrue:[ |
|
1759 |
sub enableAll:#(browseImplementorsOfIt browseSendersOfIt ) |
|
1760 |
] ifFalse:[ |
|
1761 |
|el| |
|
1762 |
||
1763 |
(el := self syntaxElementForVariableUnderCursor) notNil ifTrue:[ |
|
1764 |
el isGlobal ifTrue:[ |
|
1765 |
sub enable: #browseReferencesToIt |
|
1766 |
]. |
|
1767 |
el isClass ifTrue:[ |
|
1768 |
sub enable:#browseIt |
|
1769 |
] |
|
1770 |
] |
|
1771 |
] |
|
1772 |
]. |
|
2454 | 1773 |
] ifTrue:[ |
1774 |
s := self selectionAsString. |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1775 |
s notNil ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1776 |
s asSymbolIfInterned isNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1777 |
s2 := SystemBrowser extractSelectorFrom:s. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1778 |
s2 notNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1779 |
s2 := s2 asSymbolIfInterned. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1780 |
]. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1781 |
]. |
2454 | 1782 |
]. |
2487
47e0a1faf544
disabling of impl/senders menu
Claus Gittinger <cg@exept.de>
parents:
2485
diff
changeset
|
1783 |
(s2 isNil and:[s isNil]) ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1784 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1785 |
]. |
3959 | 1786 |
"/ a global or namespace-var selected ? |
4459 | 1787 |
s isNil ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1788 |
sub disable:#browseReferencesToIt. |
4459 | 1789 |
] ifFalse:[ |
1790 |
(s asSymbolIfInterned notNil |
|
1791 |
and:[ (Smalltalk includesKey:s asSymbol) |
|
4617 | 1792 |
or:[ (NameSpace allNameSpaces contains:[:ns | ns includesKey:s asSymbol]) ]] |
1793 |
) ifTrue:[ |
|
1794 |
"/ a global or namespace var selected |
|
4459 | 1795 |
] ifFalse:[ |
1796 |
"/ todo: an instvar selected? |
|
1797 |
sub disable:#browseReferencesToIt. |
|
1798 |
]. |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1799 |
]. |
4342 | 1800 |
(s notNil |
1801 |
and:[ s asSymbolIfInterned notNil |
|
1802 |
and:[ (SharedPool allSubclasses contains:[:pool | pool includesKey:s asSymbol]) ]]) ifFalse:[ |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1803 |
sub disable:#browseSharedPoolOfIt. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1804 |
]. |
4584 | 1805 |
]. |
1806 |
self isReadOnly ifTrue:[ |
|
1807 |
sub disableAll:#(commentSelection uncommentSelection) |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1808 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1809 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1810 |
|
2459 | 1811 |
m notNil ifTrue:[ |
1812 |
" |
|
1813 |
workspaces support #doIt, #printIt and #inspectIt |
|
1814 |
add them after paste. |
|
1815 |
" |
|
1816 |
idx := m indexOf:#paste. |
|
1817 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
1818 |
idx ~~ 0 ifTrue:[ |
|
2867 | 1819 |
m |
1820 |
addItemList:#( |
|
1821 |
('-' ) |
|
1822 |
('DoIt' doIt DoIt ) |
|
1823 |
('PrintIt' printIt PrintIt ) |
|
1824 |
('InspectIt' inspectIt InspectIt)) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1825 |
resources:resources |
2459 | 1826 |
after:idx. |
1827 |
||
1828 |
]. |
|
1829 |
||
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
1830 |
(self hasSelectionOrTextInCursorLine) ifFalse:[ |
3272 | 1831 |
|lNr line| |
1832 |
||
1833 |
lNr := self cursorLine. |
|
1834 |
line := self listAt:lNr. |
|
1835 |
line isEmptyOrNil ifTrue:[ |
|
1836 |
m disableAll:#(printIt doIt inspectIt browseIt) |
|
1837 |
]. |
|
2459 | 1838 |
]. |
2595 | 1839 |
self isReadOnly ifTrue:[ |
1840 |
m disable:#printIt |
|
1841 |
]. |
|
418 | 1842 |
]. |
1843 |
||
2459 | 1844 |
^ m ? sub. |
430 | 1845 |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1846 |
"Modified: / 22-04-1998 / 21:49:06 / ca" |
4342 | 1847 |
"Modified: / 20-12-2011 / 11:22:20 / cg" |
418 | 1848 |
! |
1849 |
||
1850 |
inspectIt |
|
1851 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
1852 |
and start an inspector on the result" |
|
1853 |
||
2981
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1854 |
|shifted| |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1855 |
|
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1856 |
shifted := self sensor shiftDown. |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1857 |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1858 |
^ self |
3272 | 1859 |
do:(self selectionOrTextOfCursorLine) |
2982
9a831ab53acc
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2981
diff
changeset
|
1860 |
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
|
1861 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1862 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 1863 |
! |
1864 |
||
1865 |
printIt |
|
1866 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
1867 |
and insert result of evaluation into my text. |
|
1868 |
If the text is readOnly, do nothing." |
|
1869 |
||
1734 | 1870 |
self isReadOnly ifTrue:[ |
3511 | 1871 |
self beep. |
1872 |
^ self. |
|
1873 |
]. |
|
1874 |
self |
|
1875 |
undoableDo:[ |
|
1876 |
self |
|
1877 |
do:(self selectionOrTextOfCursorLine) |
|
4367 | 1878 |
withValueDo:[:result | |
1879 |
|s| |
|
1880 |
||
3511 | 1881 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
4367 | 1882 |
(result isInteger |
1883 |
and:[ result > 10 |
|
4401 | 1884 |
and:[ InspectorView defaultIntegerDisplayRadix ~= 10 ]]) ifTrue:[ |
1885 |
s := result displayString , ' "',(result radixPrintStringRadix: InspectorView defaultIntegerDisplayRadix),'"'. |
|
4367 | 1886 |
] ifFalse:[ |
1887 |
s := result displayString "printString" |
|
1888 |
]. |
|
1889 |
self insertSelectedStringAtCursor:s |
|
3511 | 1890 |
] |
1891 |
] |
|
1892 |
info:'PrintIt' |
|
1893 |
||
4401 | 1894 |
"Modified: / 08-03-2012 / 16:14:34 / cg" |
3511 | 1895 |
! |
418 | 1896 |
|
4471 | 1897 |
profileIt |
1898 |
"user selected 'profileIt' from menu; show a wait-cursor, profile the code |
|
4472 | 1899 |
and finally restore the cursor. Open a visual profiler on the sample data." |
4471 | 1900 |
|
4472 | 1901 |
self spyOnItUsing:Tools::Profiler |
4471 | 1902 |
! |
1903 |
||
3511 | 1904 |
replaceIt |
1905 |
"like printIt, but replace the selection with the result, instead of |
|
1906 |
pasting it after the selection." |
|
1907 |
||
1908 |
self isReadOnly ifTrue:[ |
|
1909 |
self beep. |
|
1910 |
^ self |
|
1911 |
]. |
|
1912 |
||
1913 |
self |
|
1914 |
undoableDo:[ |
|
1915 |
self |
|
1916 |
do:(self selectionOrTextOfCursorLine) |
|
1917 |
withValueDo:[:result | |
|
1918 |
self replaceSelectionBy:(result displayString "printString") |
|
1919 |
]. |
|
1920 |
undoSupport actionInfo:'ReplaceIt'. |
|
1921 |
] |
|
1922 |
info:'ReplaceIt' |
|
1923 |
||
1924 |
"Created: / 08-11-2007 / 11:31:54 / cg" |
|
1501 | 1925 |
! |
1926 |
||
1927 |
spyOnIt |
|
1928 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
4472 | 1929 |
and finally restore the cursor. Show profile data on the Transcript" |
1930 |
||
1931 |
self spyOnItUsing:MessageTally |
|
1932 |
! |
|
1933 |
||
1934 |
spyOnItUsing:aProfiler |
|
1935 |
"common code for spyOnIt / profileIt. |
|
1936 |
Show a wait-cursor, evaluate the code with profier on it, |
|
1937 |
and finally restore the cursor. Show profile data as per profiler" |
|
1501 | 1938 |
|
1939 |
|code| |
|
1940 |
||
4427 | 1941 |
compilerClass == Smalltalk::Compiler ifFalse:[ |
1942 |
"sigh - this measurement will include the time to compile - sigh" |
|
4472 | 1943 |
aProfiler spyDetailedOn:[ self doIt ]. |
4427 | 1944 |
^ self. |
1945 |
]. |
|
1946 |
||
4472 | 1947 |
code := aProfiler name,' spyDetailedOn:[' , self selectionAsString, ']'. |
4149 | 1948 |
self do:code withValueDo:[:value| ]. |
1501 | 1949 |
! |
1950 |
||
1951 |
timeIt |
|
1952 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
1953 |
and finally restore cursor; return result of evaluation" |
|
1954 |
||
4427 | 1955 |
|code t| |
1956 |
||
1957 |
compilerClass == Smalltalk::Compiler ifFalse:[ |
|
1958 |
"sigh - this measurement will include the time to compile - sigh" |
|
1959 |
t := Time millisecondsToRun:[ self doIt ]. |
|
1960 |
Transcript showCR:'execution time: ' , t printString , ' ms'. |
|
1961 |
^ self. |
|
1962 |
]. |
|
1501 | 1963 |
|
3272 | 1964 |
code := '|t| t := Time millisecondsToRun:[' , self selectionAsString, ']. |
4149 | 1965 |
Transcript showCR:''execution time: '' , t printString , '' ms''.'. |
1966 |
self do:code withValueDo:[:value | ]. |
|
1501 | 1967 |
|
4427 | 1968 |
"Modified: / 22-04-1998 / 22:03:51 / ca" |
1969 |
"Modified (format): / 02-06-2012 / 00:38:51 / cg" |
|
418 | 1970 |
! ! |
1971 |
||
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1972 |
!Workspace methodsFor:'misc'! |
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 |
expandAbbreviation |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1975 |
"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
|
1976 |
cursor, find an abbrev for it and expand." |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1977 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1978 |
|expandedString abortExpandAction oldSelectionStartLine oldSelectionStartCol oldSelectionEndLine oldSelectionEndCol oldCursorLine oldCursorCol |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1979 |
newCursorPos replStartCol| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1980 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1981 |
oldCursorLine := self cursorLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1982 |
oldCursorCol := self cursorCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1983 |
oldSelectionStartLine := self selectionStartLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1984 |
oldSelectionStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1985 |
oldSelectionEndLine := self selectionEndLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1986 |
oldSelectionEndCol := self selectionEndCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1987 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1988 |
abortExpandAction := [ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1989 |
self selectFromLine:oldSelectionStartLine |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1990 |
col:oldSelectionStartCol |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1991 |
toLine:oldSelectionEndLine |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1992 |
col:oldSelectionEndCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1993 |
self cursorLine: oldCursorLine col: oldCursorCol. |
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 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1996 |
expandedString := self findAbbreviationKeyBeforeCursor. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1997 |
expandedString isNil ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1998 |
abortExpandAction value. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1999 |
^ self |
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 |
newCursorPos := expandedString indexOf:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2002 |
newCursorPos ~~ 0 ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2003 |
expandedString := expandedString copyWithout:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2004 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2005 |
replStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2006 |
self |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2007 |
undoableDo:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2008 |
self replaceSelectionWith: expandedString] |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2009 |
info:'Replace'. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2010 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2011 |
newCursorPos == 0 ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2012 |
"/ cursor already fine (at the end) |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2013 |
] ifFalse:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2014 |
self cursorCol:replStartCol+newCursorPos-1 |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2015 |
] |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2016 |
! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2017 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2018 |
findAbbreviationKeyBeforeCursor |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2019 |
"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
|
2020 |
cursor, find an abbrev for it and expand." |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2021 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2022 |
|sniplets keys minMax maxKeyLen minKeyLen line stringBeforeCursor| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2023 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2024 |
sniplets := self class sniplets. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2025 |
keys := sniplets keys. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2026 |
minMax := (keys collect:[:k | k size]) minMax. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2027 |
minKeyLen := minMax first. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2028 |
maxKeyLen := minMax second. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2029 |
line := (self at:cursorLine) ? ''. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2030 |
stringBeforeCursor := line string copyTo:((cursorCol-1) min:line size). |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2031 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2032 |
maxKeyLen := maxKeyLen min:stringBeforeCursor size. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2033 |
|
4631 | 2034 |
maxKeyLen to:minKeyLen by:-1 do:[:l | |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2035 |
|lCharactersBeforeCursor expandedString| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2036 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2037 |
lCharactersBeforeCursor := stringBeforeCursor last:l. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2038 |
expandedString := sniplets at:lCharactersBeforeCursor ifAbsent:nil. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2039 |
expandedString notNil ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2040 |
self selectFromLine:cursorLine col:cursorCol-l toLine:cursorLine col:cursorCol-1. |
4185 | 2041 |
^ expandedString withCRs |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2042 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2043 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2044 |
^ nil. |
4185 | 2045 |
|
2046 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
4617 | 2047 |
! |
2048 |
||
2049 |
selectedTextOrSyntaxElement |
|
2050 |
|selectedText el| |
|
2051 |
||
2052 |
selectedText := self selectionAsString. |
|
2053 |
selectedText isEmptyOrNil ifTrue:[ |
|
2054 |
self supportsSyntaxElements ifTrue:[ |
|
2055 |
el := self syntaxElementForSelectorUnderCursor. |
|
2056 |
el notNil ifTrue:[ selectedText := el value ]. |
|
2057 |
] |
|
2058 |
]. |
|
2059 |
^ selectedText |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2060 |
! ! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2061 |
|
2646 | 2062 |
!Workspace methodsFor:'queries'! |
2063 |
||
2064 |
isWorkspace |
|
4395 | 2065 |
"back-query from the compiler to ask if this is an interactive view |
2066 |
(for error feedback)" |
|
2067 |
||
2646 | 2068 |
^ true |
4395 | 2069 |
|
2070 |
"Modified (comment): / 07-03-2012 / 17:52:59 / cg" |
|
2646 | 2071 |
! ! |
2072 |
||
206 | 2073 |
!Workspace class methodsFor:'documentation'! |
2074 |
||
4402 | 2075 |
version |
4631 | 2076 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.268 2013-06-26 08:16:45 stefan Exp $' |
4402 | 2077 |
! |
2078 |
||
3959 | 2079 |
version_CVS |
4631 | 2080 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.268 2013-06-26 08:16:45 stefan Exp $' |
858 | 2081 |
! ! |
4504 | 2082 |