author | ab |
Tue, 10 Sep 2013 21:49:18 +0200 | |
changeset 4762 | 3e6cde30b237 |
parent 4761 | 10a72ce3c6ef |
child 4766 | 7e97352b1f95 |
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 |
|
4725 | 18 |
poolsConsideredInDoIts namespaceForDoits editedMethodOrClass |
19 |
editedClass editedMethod' |
|
4631 | 20 |
classVariableNames:'DefaultViewBackground DefaultErrorForegroundColor |
21 |
DefaultErrorBackgroundColor DefaultWarningBackgroundColor |
|
22 |
DefaultWarningForegroundColor WorkspaceVariables DoItHistory |
|
23 |
Sniplets' |
|
24 |
poolDictionaries:'' |
|
25 |
category:'Interface-Smalltalk' |
|
0 | 26 |
! |
27 |
||
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
28 |
Object subclass:#CodeCompletionService |
4737 | 29 |
instanceVariableNames:'completionView completionProcess editView autoSelect' |
4735 | 30 |
classVariableNames:'LastCompletions' |
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
31 |
poolDictionaries:'' |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
32 |
privateIn:Workspace |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
33 |
! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
34 |
|
4726 | 35 |
Workspace comment:'' |
3155 | 36 |
! |
37 |
||
32 | 38 |
!Workspace class methodsFor:'documentation'! |
39 |
||
38 | 40 |
copyright |
41 |
" |
|
42 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
4619 | 43 |
All Rights Reserved |
38 | 44 |
|
45 |
This software is furnished under a license and may be used |
|
46 |
only in accordance with the terms of that license and with the |
|
47 |
inclusion of the above copyright notice. This software may not |
|
48 |
be provided or otherwise made available to, or used by, any |
|
49 |
other person. No title to or ownership of the software is |
|
50 |
hereby transferred. |
|
51 |
" |
|
52 |
! |
|
53 |
||
32 | 54 |
documentation |
55 |
" |
|
56 |
a view for editable text which can evaluate expressions. |
|
38 | 57 |
I.e. its basically a view for editable text, with added |
58 |
'doIt', 'printIt' and 'inspectIt' functions on the popup-menu. |
|
125 | 59 |
|
38 | 60 |
The action to be performed on doIt is defined by a block, |
58 | 61 |
which can be defined by the owner of this view. |
60 | 62 |
(thus you can put a workspace into more complex widgets, and |
63 |
control what should happen on 'doIt'). |
|
58 | 64 |
|
578 | 65 |
A useful default action is automatically defined, which simply |
66 |
evaluates the selection as a smalltalk expression. |
|
67 |
(but, a lisp or prolog workspace would define its own action, |
|
68 |
to call for another compiler/interpreter ...) |
|
32 | 69 |
|
123 | 70 |
|
71 |
Caveat: |
|
418 | 72 |
in this version, Workspace does not yet support doIt in MVC setups. |
73 |
For now, simulate this by setting the doItAction, to notify the |
|
74 |
model manually about the doIt. |
|
123 | 75 |
|
76 |
||
578 | 77 |
[instance variables:] |
32 | 78 |
|
121 | 79 |
doItAction <Block> block to evaluate for doIt |
123 | 80 |
|
121 | 81 |
errorFgColor <Color> fg-Color to be used when highlighting errors |
82 |
||
83 |
errorBgColor <Color> bg-Color to be used when highlighting errors |
|
58 | 84 |
|
578 | 85 |
codeStartPosition private temporary |
121 | 86 |
|
578 | 87 |
|
88 |
[styleSheet values:] |
|
121 | 89 |
|
90 |
codeErrorSelectionForegroundColor fg color to highlight errors |
|
418 | 91 |
(default: selection fg) |
92 |
||
121 | 93 |
codeErrorSelectionBackgroundColor bg color to highlight errors |
418 | 94 |
(default: selection bg) |
578 | 95 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
96 |
[start with:] |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
97 |
Workspace open |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
98 |
|
578 | 99 |
[see also:] |
100 |
Workspace EditTextView |
|
101 |
Parser ByteCodeCompiler |
|
583 | 102 |
|
103 |
[author:] |
|
104 |
Claus Gittinger |
|
32 | 105 |
" |
201 | 106 |
! ! |
107 |
||
3712 | 108 |
!Workspace class methodsFor:'accessing'! |
109 |
||
110 |
sniplets |
|
111 |
Sniplets isNil ifTrue:[ |
|
112 |
Sniplets := Dictionary new. |
|
3713 | 113 |
self initializeDefaultAbbreviations. |
3712 | 114 |
]. |
115 |
^ Sniplets |
|
3713 | 116 |
|
117 |
" |
|
118 |
Sniplets := nil |
|
119 |
" |
|
3712 | 120 |
! |
121 |
||
122 |
sniplets:something |
|
123 |
Sniplets := something. |
|
124 |
! ! |
|
125 |
||
201 | 126 |
!Workspace class methodsFor:'defaults'! |
127 |
||
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
128 |
codeCompletionServiceClass |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
129 |
^ CodeCompletionService |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
130 |
! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
131 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
132 |
defaultLabel |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
133 |
"my default window label" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
134 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
135 |
^ 'Workspace' |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
136 |
|
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
137 |
"Created: / 16.5.1998 / 16:53:37 / cg" |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
138 |
! |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
139 |
|
3716 | 140 |
initializeDefaultAbbreviations |
4745 | 141 |
"default snippets/abbreviations. TODO: save/load sniplets" |
3728 | 142 |
|
3735 | 143 |
"flush and reinitialize sniplets with: |
3807 | 144 |
Sniplets := Dictionary new. |
3741 | 145 |
" |
3807 | 146 |
"after a code change below, update with: |
147 |
self initializeDefaultAbbreviations. |
|
3735 | 148 |
" |
3807 | 149 |
|
150 |
#( |
|
151 |
't' 'true' |
|
152 |
'f' 'false' |
|
153 |
's' 'self' |
|
3876
38612526d6a2
sniplets: what was %p ? (noone knows)
Claus Gittinger <cg@exept.de>
parents:
3870
diff
changeset
|
154 |
'su' 'super' |
38612526d6a2
sniplets: what was %p ? (noone knows)
Claus Gittinger <cg@exept.de>
parents:
3870
diff
changeset
|
155 |
'ss' 'super ' |
3807 | 156 |
'n' 'nil' |
157 |
'y' 'yourself.' |
|
158 |
||
159 |
'in' 'isNil ' |
|
160 |
'nn' 'notNil ' |
|
161 |
'ie' 'isEmpty ' |
|
162 |
'ne' 'notEmpty ' |
|
163 |
'ien' 'isEmptyOrNil ' |
|
164 |
'nen' 'notEmptyOrNil ' |
|
165 |
||
4453
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
166 |
'it' 'ifTrue:[!!' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
167 |
'if' 'ifFalse:[!!' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
168 |
'itf' 'ifTrue:[!!] ifFalse:[].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
169 |
'int' 'isNil ifTrue:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
170 |
'inf' 'isNil ifFalse:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
171 |
'ints' 'isNil ifTrue:[^ self].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
172 |
'infs' 'isNil ifFalse:[^ self].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
173 |
'nnt' 'notNil ifTrue:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
174 |
'nnf' 'notNil ifFalse:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
175 |
'iet' 'isEmpty ifTrue:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
176 |
'net' 'notEmpty ifTrue:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
177 |
'ief' 'isEmpty ifFalse:[!!].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
178 |
'nef' 'notEmpty ifFalse:[!!].' |
3807 | 179 |
|
4185 | 180 |
'wt' 'whileTrue:[!!]' |
181 |
'wf' 'whileFalse:[!!]' |
|
3807 | 182 |
|
4185 | 183 |
'do' 'do:[:each |!!]' |
184 |
'd:' 'do:[:each |!!]' |
|
185 |
'kdo' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
186 |
'kvd' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
187 |
'kv:' 'keysAndValuesDo:[:eachKey :eachValue |!!]' |
|
4184
9879be399bcc
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4175
diff
changeset
|
188 |
'k:' 'keysDo:[:eachKey | !!]' |
4158
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
189 |
'dt' 'detect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
190 |
'de' 'detect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
191 |
'det' 'detect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
192 |
'dtn' 'detect:[:each | !!] ifNone:[]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
193 |
'cl' 'collect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
194 |
'co' 'collect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
195 |
'col' 'collect:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
196 |
'sl' 'select:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
197 |
'se' 'select:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
198 |
'sel' 'select:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
199 |
'rj' 'reject:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
200 |
're' 'reject:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
201 |
'rej' 'reject:[:each | !!]' |
502e6898c82d
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4154
diff
changeset
|
202 |
'inj' 'inject:!! into:[:accum :each | ]' |
3807 | 203 |
|
4453
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
204 |
'ex' 'Error handle:[ex | !!] do:[].' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
205 |
'sh' 'self halt.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
206 |
'mt' 'MessageTally spyOn:[!!].' |
3807 | 207 |
|
4172
432d4d3f5717
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4171
diff
changeset
|
208 |
'ih' '!! ifTrue:[ self halt ].' |
3807 | 209 |
'ik' 'includesKey: #' |
210 |
'is' 'includesString: #' |
|
211 |
||
212 |
'af' 'asFilename ' |
|
213 |
'as' 'asString ' |
|
214 |
'aoc' 'asOrderedCollection ' |
|
215 |
||
216 |
'np' 'nextPut: ' |
|
217 |
'npa' 'nextPutAll: ' |
|
218 |
'npl' 'nextPutLine: ' |
|
219 |
||
220 |
'ps' 'printString' |
|
4453
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
221 |
'sr' 'self subclassResponsibility.' |
3807 | 222 |
|
223 |
'ati' 'at:!! ifAbsent: ' |
|
224 |
'atip' 'at:!! ifAbsentPut:[ ] ' |
|
225 |
'ap' 'at:!! ' |
|
226 |
||
227 |
'st' 'Smalltalk' |
|
4453
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
228 |
'ts' 'Transcript showCR:''!!''.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
229 |
'trs' 'Transcript showCR:''!!''.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
230 |
'abb' 'Workspace sniplets inspect.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
231 |
'ws' 'Delay waitForSeconds: 1.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
232 |
'wfs' 'Delay waitForSeconds: 1.' |
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
233 |
'wfm' 'Delay waitForMilliseconds: 1000.' |
3807 | 234 |
'ini' 'initialize\ super initialize.\ ' |
235 |
'newi' 'new\ ^ super new initialize.' |
|
236 |
'upd' 'update:something with:aParameter from:changedObject\ !!\ ^ super update:something with:aParameter from:changedObject.' |
|
237 |
'OC' 'OrderedCollection' |
|
238 |
'oc' 'OrderedCollection' |
|
239 |
'SC' 'SortedCollection' |
|
240 |
'sc' 'SortedCollection' |
|
241 |
'D' 'Dictionary' |
|
242 |
'ID' 'IdentityDictionary' |
|
243 |
'Id' 'IdentityDictionary' |
|
244 |
'id' 'IdentityDictionary' |
|
245 |
'iD' 'IdentityDictionary' |
|
246 |
'OCn' 'OrderedCollection new.' |
|
247 |
'ocn' 'OrderedCollection new.' |
|
248 |
'SCn' 'SortedCollection new.' |
|
249 |
'IDn' 'IdentityDictionary new' |
|
250 |
'idn' 'IdentityDictionary new' |
|
251 |
'Dn' 'Dictionary new' |
|
252 |
'dn' 'Dictionary new' |
|
253 |
'Sn' 'Set new' |
|
254 |
'sn' 'Set new' |
|
255 |
'A' 'Array' |
|
256 |
'a' 'Array' |
|
257 |
'An' 'Array new:' |
|
258 |
'an' 'Array new:' |
|
259 |
'Aw' 'Array with:' |
|
260 |
'aw' 'Array with:' |
|
261 |
'Aww' 'Array with:!! with:' |
|
262 |
'sww' 'Array with:!! with:' |
|
263 |
'Awww' 'Array with:!! with: with:' |
|
264 |
'awww' 'Array with:!! with: with:' |
|
265 |
'Awwww' 'Array with:!! with: with: with:' |
|
266 |
'awwww' 'Array with:!! with: with: with:' |
|
267 |
'aw2' 'Array with:!! with:' |
|
268 |
'aw3' 'Array with:!! with: with:' |
|
269 |
'aw4' 'Array with:!! with: with: with:' |
|
270 |
'0' '(0.0 @ 0.0)' |
|
271 |
'1' '(1.0 @ 1.0)' |
|
272 |
'[' '[:!! ]' |
|
3876
38612526d6a2
sniplets: what was %p ? (noone knows)
Claus Gittinger <cg@exept.de>
parents:
3870
diff
changeset
|
273 |
'(' '(!! )' |
3807 | 274 |
|
275 |
"/ typos... |
|
276 |
'eslf' 'self' |
|
277 |
'slef' 'self' |
|
278 |
'sefl' 'self' |
|
279 |
'elf' 'self' |
|
280 |
'slf' 'self' |
|
281 |
'sef' 'self' |
|
282 |
||
283 |
'iftrue' 'ifTrue' |
|
284 |
'iffalse' 'ifFalse' |
|
285 |
'iftrue:' 'ifTrue:' |
|
286 |
'iffalse:' 'ifFalse:' |
|
287 |
) pairWiseDo:[:abbrev :text | |
|
288 |
Sniplets |
|
289 |
at:abbrev put:text "/ ifPresent:[ self error:'duplicate abbreviation key' ] |
|
290 |
]. |
|
4148
2fe252a82d5b
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4141
diff
changeset
|
291 |
|
4453
c0cee00a50f6
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4438
diff
changeset
|
292 |
"Modified: / 26-09-2012 / 14:48:42 / cg" |
3716 | 293 |
! |
294 |
||
201 | 295 |
updateStyleCache |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
296 |
"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
|
297 |
|
1354 | 298 |
<resource: #style (#'codeErrorSelection.foregroundColor' |
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
299 |
#'codeErrorSelection.backgroundColor' |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
300 |
#'codeView.backgroundColor' )> |
444
ef26eba8c854
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
430
diff
changeset
|
301 |
|
1354 | 302 |
DefaultErrorForegroundColor := StyleSheet colorAt:'codeErrorSelection.foregroundColor'. |
303 |
DefaultErrorBackgroundColor := StyleSheet colorAt:'codeErrorSelection.backgroundColor'. |
|
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
304 |
DefaultViewBackground := StyleSheet colorAt:'codeView.backgroundColor'. |
32 | 305 |
! ! |
306 |
||
2776 | 307 |
!Workspace class methodsFor:'getting a new Workspace'! |
0 | 308 |
|
32 | 309 |
open |
0 | 310 |
"launch a new workspace" |
311 |
||
418 | 312 |
|scr topView workspace f| |
0 | 313 |
|
418 | 314 |
topView := StandardSystemView |
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
315 |
label:(self classResources string:(self defaultLabel)) |
1901
b3556ff49778
removed minExtent - let topView decide.
Claus Gittinger <cg@exept.de>
parents:
1738
diff
changeset
|
316 |
" minExtent:(100 @ 100)". |
23 | 317 |
|
418 | 318 |
scr := HVScrollableView for:self in:topView. |
319 |
scr origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
320 |
workspace := scr scrolledView. |
|
0 | 321 |
|
418 | 322 |
"/ adjust topViews extent according to my font |
323 |
||
0 | 324 |
f := workspace font. |
325 |
topView extent:((f widthOf:'x') * 40) @ (f height * 10). |
|
7 | 326 |
topView open. |
131 | 327 |
^ workspace |
0 | 328 |
|
58 | 329 |
" |
330 |
Workspace open |
|
331 |
" |
|
418 | 332 |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
333 |
"Modified: / 16.5.1998 / 16:53:53 / cg" |
857 | 334 |
! |
335 |
||
336 |
openForRemote:hostName |
|
337 |
"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
|
338 |
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
|
339 |
and the result is shown here. |
857 | 340 |
This requires the RemoteObjects package to be loaded." |
341 |
||
342 |
|server remoteCompiler workspace| |
|
343 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
344 |
RemoteObjectServer isNil ifTrue:[ |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
345 |
self warn:'no remoteObjectServer available'. |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
346 |
^ nil |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
347 |
]. |
857 | 348 |
|
349 |
server := RemoteObjectServer on:hostName. |
|
350 |
remoteCompiler := server get:#Compiler. |
|
351 |
||
352 |
workspace := self open. |
|
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
353 |
workspace topView |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
354 |
label:(self classResources string:'Remote Workspace {%1}' with:hostName). |
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
355 |
|
857 | 356 |
workspace doItAction: |
357 |
[:theCode | |
|
358 |
remoteCompiler |
|
359 |
evaluate:theCode |
|
360 |
in:nil |
|
361 |
receiver:nil |
|
362 |
notifying:workspace |
|
363 |
logged:true |
|
364 |
ifFail:nil |
|
365 |
] |
|
366 |
" |
|
367 |
Workspace openForRemote:'andi' |
|
368 |
" |
|
369 |
||
1522
b9b131f6c959
made defaultLabel a class method
Claus Gittinger <cg@exept.de>
parents:
1521
diff
changeset
|
370 |
"Modified: / 16.5.1998 / 16:57:38 / cg" |
2686 | 371 |
! |
372 |
||
2794 | 373 |
openWith:initialText selected:selectedBoolean |
2686 | 374 |
"launch a new workspace with some initial contents" |
375 |
||
376 |
|workspace| |
|
377 |
||
378 |
workspace := self open. |
|
2794 | 379 |
workspace contents:initialText selected:selectedBoolean. |
2686 | 380 |
^ workspace |
381 |
||
382 |
" |
|
383 |
Workspace openWith:'Transcript showCR:''hello world''' |
|
384 |
" |
|
0 | 385 |
! ! |
386 |
||
2657 | 387 |
!Workspace class methodsFor:'history'! |
388 |
||
389 |
clearDoItHistory |
|
390 |
DoItHistory := nil |
|
391 |
! |
|
392 |
||
393 |
doItHistory |
|
394 |
^ DoItHistory |
|
395 |
! |
|
396 |
||
397 |
doItHistorySize |
|
398 |
"the number of remembered doIts" |
|
399 |
||
400 |
^ 20 |
|
401 |
! |
|
402 |
||
403 |
rememberDoIt:aString |
|
404 |
|string| |
|
405 |
||
406 |
string := aString asString string withoutSeparators. |
|
2726 | 407 |
(string asCollectionOfWords size <= 1) ifTrue:[ |
408 |
((Scanner new scanTokens:string) size <= 1) ifTrue:[ |
|
4542 | 409 |
"it's a variable only" |
2726 | 410 |
^ self |
411 |
] |
|
412 |
]. |
|
2657 | 413 |
|
414 |
DoItHistory isNil ifTrue:[ |
|
415 |
DoItHistory := OrderedCollection new. |
|
416 |
]. |
|
417 |
DoItHistory remove:string ifAbsent:nil. |
|
418 |
DoItHistory addFirst:string. |
|
419 |
DoItHistory size > self doItHistorySize ifTrue:[ |
|
420 |
DoItHistory removeLast |
|
421 |
]. |
|
422 |
! ! |
|
423 |
||
1523
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
424 |
!Workspace class methodsFor:'queries'! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
425 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
426 |
isVisualStartable |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
427 |
"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
|
428 |
(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
|
429 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
430 |
^ self == Workspace |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
431 |
|
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
432 |
"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
|
433 |
"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
|
434 |
! ! |
6c0045d6a91f
open workspace via double-click in the browser
Claus Gittinger <cg@exept.de>
parents:
1522
diff
changeset
|
435 |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
436 |
!Workspace class methodsFor:'workspace variables'! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
437 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
438 |
addWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
439 |
"create a new workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
440 |
|
1933 | 441 |
|holder| |
442 |
||
3325 | 443 |
holder := self workspaceVariables at:name ifAbsentPut:[ ValueHolder new ]. |
1933 | 444 |
^ holder |
1931
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 |
|
3157 | 447 |
anyWorkspaceVariableIsDefined |
448 |
^ WorkspaceVariables notEmptyOrNil |
|
449 |
||
450 |
"Created: / 20-04-2005 / 11:57:53 / cg" |
|
451 |
! |
|
452 |
||
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
453 |
removeAllWorkspaceVariables |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
454 |
"delete all workspace variables" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
455 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
456 |
WorkspaceVariables := nil |
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 |
removeWorkspaceVariable:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
462 |
"delete a workspace variable" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
463 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
464 |
WorkspaceVariables notNil ifTrue:[ |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
465 |
WorkspaceVariables removeKey:name ifAbsent:nil. |
4656 | 466 |
WorkspaceVariables := WorkspaceVariables asNilIfEmpty. |
1931
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 |
! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
469 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
470 |
workspaceVariableAt:name |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
471 |
"retrieve a workspace variable (actually, a holder onto it)" |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
472 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
473 |
WorkspaceVariables isNil ifTrue:[^ nil]. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
474 |
^ WorkspaceVariables at:name ifAbsent:nil. |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
475 |
|
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
476 |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
477 |
! |
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
478 |
|
3157 | 479 |
workspaceVariableNames |
480 |
"retrieve the collection of workspace variable names" |
|
481 |
||
482 |
WorkspaceVariables isNil ifTrue:[^ #()]. |
|
483 |
^ WorkspaceVariables keys |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
484 |
|
3157 | 485 |
"Created: / 20-04-2005 / 11:42:45 / cg" |
486 |
! |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
487 |
|
3157 | 488 |
workspaceVariables |
489 |
"retrieve the collection of workspace variables. |
|
490 |
That is a dictionary associating names to values." |
|
1932
a898c608fb9a
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1931
diff
changeset
|
491 |
|
3325 | 492 |
WorkspaceVariables isNil ifTrue:[ |
493 |
WorkspaceVariables := Dictionary new. |
|
494 |
]. |
|
495 |
^ WorkspaceVariables |
|
3157 | 496 |
|
497 |
"Modified: / 20-04-2005 / 11:43:14 / cg" |
|
1931
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
498 |
! ! |
06cbb886dd10
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1930
diff
changeset
|
499 |
|
201 | 500 |
!Workspace methodsFor:'accessing'! |
0 | 501 |
|
3428 | 502 |
allowValueDrop:aBoolean |
503 |
"if on (the default), any smalltalk value can be dropped and leads to a workspace variable |
|
504 |
holding on to that being defined. Can be turned off, if youdont like this (for standAlone apps)" |
|
505 |
||
506 |
allowValueDrop := aBoolean. |
|
507 |
||
508 |
"Created: / 28-11-2006 / 16:13:02 / cg" |
|
509 |
! |
|
510 |
||
2679 | 511 |
autoDefineVariables |
4090 | 512 |
"undefined variables handling: |
513 |
are automatically defined as workspace variable if autoDefineVariables is #workspace. |
|
514 |
are automatically defined as doit variable if autoDefineVariables is #doit. |
|
515 |
are left undefined if autoDefineVariables is nil." |
|
516 |
||
2679 | 517 |
^ autoDefineVariables |
2535 | 518 |
! |
519 |
||
2679 | 520 |
autoDefineVariables:nilOrSymbol |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
521 |
"undefined variables handling: |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
522 |
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
|
523 |
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
|
524 |
are left undefined if nilOrSymbol is nil." |
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
525 |
|
2679 | 526 |
autoDefineVariables := nilOrSymbol. |
3429
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
527 |
|
670414b849dd
allow value drop to be disabled
Claus Gittinger <cg@exept.de>
parents:
3428
diff
changeset
|
528 |
"Modified: / 28-11-2006 / 16:21:01 / cg" |
2679 | 529 |
! |
2535 | 530 |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
531 |
commentStrings:anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
532 |
"define the comment strings" |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
533 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
534 |
commentStrings := anArrayOfCommentStrings |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
535 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
536 |
"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
|
537 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
538 |
|
201 | 539 |
doItAction |
540 |
"return the action to be performed when 'doIt' is selected" |
|
32 | 541 |
|
201 | 542 |
^ doItAction |
0 | 543 |
! |
544 |
||
4584 | 545 |
doItAction:aOneArgBlock |
546 |
"define the action to be performed when 'doIt' is selected. |
|
547 |
The block will be evaluated, passing the selection as a String argument. |
|
548 |
A default doItAction is set for you in the initialize method." |
|
549 |
||
550 |
doItAction := aOneArgBlock |
|
551 |
||
552 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
553 |
! |
|
554 |
||
4675 | 555 |
editedClass |
556 |
"for the code completion" |
|
557 |
||
558 |
editedMethodOrClass isNil ifTrue:[^ nil]. |
|
559 |
^ editedMethodOrClass isBehavior ifTrue:[editedMethodOrClass] ifFalse:[editedMethodOrClass mclass] |
|
560 |
! |
|
561 |
||
562 |
editedMethod |
|
563 |
"for the code completion" |
|
564 |
||
565 |
editedMethodOrClass isNil ifTrue:[^ nil]. |
|
566 |
^ editedMethodOrClass isBehavior ifTrue:[nil] ifFalse:[editedMethodOrClass] |
|
567 |
! |
|
568 |
||
4606 | 569 |
editedMethodOrClass |
570 |
"for the code completion" |
|
571 |
||
572 |
^ editedMethodOrClass. |
|
573 |
! |
|
574 |
||
575 |
editedMethodOrClass:aMethodOrClass |
|
576 |
"for the code completion" |
|
577 |
||
578 |
editedMethodOrClass := aMethodOrClass. |
|
579 |
! |
|
580 |
||
3007 | 581 |
errorBackgroundColor |
582 |
errorBgColor notNil ifTrue:[ ^ errorBgColor ]. |
|
583 |
DefaultErrorBackgroundColor notNil ifTrue:[ ^ DefaultErrorBackgroundColor ]. |
|
584 |
device hasColors ifTrue:[ ^ Color red ]. |
|
585 |
||
586 |
^ selectionBgColor |
|
587 |
! |
|
588 |
||
589 |
errorForegroundColor |
|
590 |
errorFgColor notNil ifTrue:[ ^ errorFgColor ]. |
|
591 |
DefaultErrorForegroundColor notNil ifTrue:[ ^ DefaultErrorForegroundColor ]. |
|
592 |
^ selectionFgColor |
|
593 |
! |
|
594 |
||
4436 | 595 |
nameSpaceForDoits:aNameSpaceOrNil |
596 |
"can be used by the embedding application to control doIt execution |
|
597 |
(especially: for tools like expecco, to provide better workspaces" |
|
598 |
||
599 |
namespaceForDoits := aNameSpaceOrNil. |
|
600 |
||
601 |
"Created: / 26-07-2012 / 23:06:04 / cg" |
|
602 |
! |
|
603 |
||
4391 | 604 |
namespaceForDoits:aNameSpaceOrNil |
605 |
"can be used by the embedding application to control doIt execution |
|
606 |
(especially: for tools like expecco, to provide better workspaces" |
|
607 |
||
4436 | 608 |
<resource: #obsolete> |
609 |
||
4391 | 610 |
namespaceForDoits := aNameSpaceOrNil. |
611 |
||
612 |
"Created: / 04-03-2012 / 13:34:51 / cg" |
|
613 |
! |
|
614 |
||
615 |
poolsConsideredInDoIts:aCollectionOfPools |
|
616 |
"can be used by the embedding application to control doIt execution |
|
617 |
(especially: for tools like expecco, to provide better workspaces" |
|
618 |
||
619 |
poolsConsideredInDoIts := aCollectionOfPools. |
|
620 |
||
621 |
"Modified (format): / 04-03-2012 / 13:35:00 / cg" |
|
3537 | 622 |
! |
623 |
||
2601 | 624 |
simulatedSelf:anObject |
625 |
"define what self is in an evaluation" |
|
626 |
||
627 |
simulatedSelf := anObject |
|
3007 | 628 |
! |
629 |
||
630 |
warningBackgroundColor |
|
631 |
DefaultWarningBackgroundColor notNil ifTrue:[ ^ DefaultWarningBackgroundColor ]. |
|
632 |
device hasColors ifTrue:[ ^ Color orange ]. |
|
633 |
||
634 |
^ selectionBgColor |
|
635 |
! |
|
636 |
||
637 |
warningForegroundColor |
|
638 |
DefaultWarningForegroundColor notNil ifTrue:[ ^ DefaultWarningForegroundColor ]. |
|
639 |
^ selectionFgColor |
|
201 | 640 |
! ! |
641 |
||
642 |
!Workspace methodsFor:'compiler interface'! |
|
643 |
||
2303 | 644 |
compilerClass |
4432
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
645 |
^ compilerClass "? Compiler" |
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
646 |
|
2eaf85d92e62
corrected switching languages between tabs
Claus Gittinger <cg@exept.de>
parents:
4427
diff
changeset
|
647 |
"Modified: / 19-07-2012 / 17:04:35 / cg" |
2980 | 648 |
! |
649 |
||
650 |
compilerClass:aCompilerClass |
|
651 |
compilerClass := aCompilerClass |
|
2303 | 652 |
! |
653 |
||
201 | 654 |
currentSourceCode |
655 |
"special interface to compiler - called by parser |
|
656 |
to get the updated source code after a corrected error" |
|
657 |
||
658 |
^ self contents |
|
0 | 659 |
! |
660 |
||
201 | 661 |
wantChangeLog |
662 |
"sent by the compiler to ask if a changeLog entry should |
|
663 |
be written. Return true here." |
|
0 | 664 |
|
201 | 665 |
^ true |
0 | 666 |
! ! |
667 |
||
2754 | 668 |
!Workspace methodsFor:'compiler interface-error handling'! |
0 | 669 |
|
201 | 670 |
correctableError:aString position:relPos to:relEndPos from:aCompiler |
671 |
"compiler notifies us of a correctable error; |
|
672 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
673 |
this method should return true to the compiler if user wants the error |
|
674 |
to be corrected; false otherwise" |
|
675 |
||
4675 | 676 |
|action sameForAllHolder possibleFixes doNotShowAgainHolder doNotShowAgainForThisMethodHolder| |
677 |
||
678 |
"/ the declare/correct fixes are here for backward compatibility |
|
679 |
"/ (in previous versions, these two were always offered as fix, |
|
680 |
"/ and compilers which honor the old interface will not anwer the PossibleCorrectionsQuery) |
|
681 |
possibleFixes := Parser possibleCorrectionsQuery query. |
|
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
682 |
|
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
683 |
sameForAllHolder := false asValue. |
201 | 684 |
|
685 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
4675 | 686 |
doNotShowAgainHolder := false asValue. |
687 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
688 |
||
3383 | 689 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
4675 | 690 |
|box declareButton makeSpaceOnlyOnce| |
3383 | 691 |
|
4669 | 692 |
box := ex box. |
4675 | 693 |
makeSpaceOnlyOnce := [ box addVerticalSpace:10. makeSpaceOnlyOnce := nil ]. |
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
694 |
|
4675 | 695 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
696 |
makeSpaceOnlyOnce value. |
|
697 |
box verticalPanel |
|
698 |
add:(CheckBox |
|
699 |
label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
700 |
model:doNotShowAgainHolder). |
|
701 |
]. |
|
702 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
703 |
makeSpaceOnlyOnce value. |
|
704 |
box verticalPanel |
|
705 |
add:(CheckBox |
|
706 |
label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
|
707 |
model:doNotShowAgainForThisMethodHolder). |
|
708 |
]. |
|
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
709 |
SameForAllNotification isHandled ifTrue:[ |
4675 | 710 |
box addVerticalSpace:10. |
4386 | 711 |
box addCheckBoxAtBottom:'Same action for all' on:sameForAllHolder |
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
712 |
]. |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
713 |
|
3383 | 714 |
declareButton := box buttons at:2. |
715 |
declareButton pressAction:declareButton controller releaseAction. |
|
716 |
declareButton controller beTriggerOnDown. |
|
717 |
] do:[ |
|
4675 | 718 |
|buttonLabels actions| |
719 |
||
720 |
buttonLabels := OrderedCollection new. |
|
721 |
actions := OrderedCollection new. |
|
722 |
buttonLabels add:'Cancel'. actions add:#abort. |
|
723 |
possibleFixes do:[:each | |
|
724 |
buttonLabels add:(each buttonLabel). actions add:each. |
|
725 |
]. |
|
726 |
buttonLabels add:'Continue'. actions add:#continue. |
|
727 |
||
3383 | 728 |
action := OptionBox |
729 |
request:aString |
|
3592
cb6f9f060e62
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3579
diff
changeset
|
730 |
label:(resources string:'Correctable Error') |
3383 | 731 |
image:(WarningBox iconBitmap) |
4675 | 732 |
buttonLabels:(resources array:buttonLabels) |
733 |
values:actions |
|
3383 | 734 |
default:#continue |
735 |
onCancel:#abort. |
|
736 |
]. |
|
201 | 737 |
]. |
738 |
||
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
739 |
sameForAllHolder value ifTrue:[ |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
740 |
SameForAllNotification notify |
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
741 |
]. |
4691 | 742 |
doNotShowAgainHolder value == true ifTrue:[ |
743 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
|
744 |
]. |
|
745 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
746 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
747 |
]. |
|
748 |
||
4675 | 749 |
action == #cancel ifTrue:[ |
750 |
^ false |
|
751 |
]. |
|
4175
e7063a3e7ec5
changed: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4172
diff
changeset
|
752 |
|
201 | 753 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
754 |
AbortOperationRequest raise. |
368 | 755 |
^ false |
201 | 756 |
]. |
4675 | 757 |
^ action |
368 | 758 |
|
4386 | 759 |
"Modified: / 28-02-2012 / 10:42:27 / cg" |
201 | 760 |
! |
761 |
||
2104 | 762 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
763 |
"compiler notifies us of a correctable selector warning; |
|
764 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
765 |
this method should return true to the compiler if user wants the error |
|
766 |
to be corrected; false otherwise" |
|
767 |
||
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
768 |
|action doNotShowAgainHolder| |
2104 | 769 |
|
3261 | 770 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
771 |
doNotShowAgainHolder := false asValue. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
772 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
4617 | 773 |
MessageNotUnderstood catch:[ |
774 |
(aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
|
775 |
ex box addCheckBoxAtBottom:'Do not show this dialog again (reenable via Launchers Settings Dialog)' on:doNotShowAgainHolder. |
|
776 |
]. |
|
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
777 |
]. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
778 |
] do:[ |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
779 |
action := OptionBox |
2104 | 780 |
request:aString |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
781 |
label:(resources string:'Warning') |
2983
910b4d5f7b1b
dont send obsolete message (OptionBox request:..form:..)
Claus Gittinger <cg@exept.de>
parents:
2982
diff
changeset
|
782 |
image:(WarningBox iconBitmap) |
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
783 |
buttonLabels:(resources array:#('Cancel' 'Correct...' 'Generate' 'Continue')) |
2338 | 784 |
values:#(#abort #correct #generate #continue) |
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
785 |
default:#continue |
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
786 |
onCancel:#abort. |
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
787 |
]. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
788 |
doNotShowAgainHolder value == true ifTrue:[ |
4386 | 789 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
790 |
]. |
2104 | 791 |
]. |
792 |
||
2338 | 793 |
action == #generate ifTrue:[ |
794 |
^ action |
|
795 |
]. |
|
796 |
||
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
797 |
(action isNil or:[action == #abort]) ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
798 |
AbortOperationRequest raise. |
2104 | 799 |
^ false |
800 |
]. |
|
801 |
^ action == #correct |
|
802 |
||
4386 | 803 |
"Created: / 19-01-2000 / 16:27:28 / cg" |
804 |
"Modified: / 28-02-2012 / 10:42:37 / cg" |
|
2104 | 805 |
! |
806 |
||
4188
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
807 |
correctableWarning:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
808 |
"compiler notifies us of a correctable warning; |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
809 |
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
|
810 |
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
|
811 |
to be corrected; false otherwise" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
812 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
813 |
^ self correctableError:aString position:relPos to:relEndPos from:aCompiler |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
814 |
|
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
815 |
"Created: / 02-11-2010 / 13:29:01 / cg" |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
816 |
! |
601acd1e72fe
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
817 |
|
201 | 818 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 819 |
"obsolete - no longer invoked" |
820 |
||
821 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
822 |
! |
|
823 |
||
824 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
825 |
"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
|
826 |
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
|
827 |
Return true for correction, false of not (or not possible)" |
2277 | 828 |
|
829 |
^ 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
|
830 |
|
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
831 |
"Modified (Comment): / 30-06-2011 / 19:47:36 / cg" |
2277 | 832 |
! |
833 |
||
834 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
3397 | 835 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
201 | 836 |
and show a Box asking for continue/abort." |
837 |
||
3007 | 838 |
|answer fg bg| |
201 | 839 |
|
3007 | 840 |
fg := asWarning ifTrue:[ self warningForegroundColor ] ifFalse:[ self errorForegroundColor ]. |
841 |
bg := asWarning ifTrue:[ self warningBackgroundColor ] ifFalse:[ self errorBackgroundColor ]. |
|
201 | 842 |
|
3397 | 843 |
self |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
844 |
highlightingErrorPosition:relPos to:relEndPos |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
845 |
withForeground:fg andBackground:bg |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
846 |
do:[ |
4386 | 847 |
|box lbl doNotShowAgainHolder doNotShowAgainForThisMethodHolder l1 y1 y2 l2| |
201 | 848 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
849 |
"/ Warning isHandled ifTrue:[ |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
850 |
"/ Warning raiseErrorString:aString. |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
851 |
"/ ^ false |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
852 |
"/ ]. |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
853 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
854 |
lbl := aCompiler isNil ifTrue:['Compiler'] ifFalse:[aCompiler class name]. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
855 |
asWarning ifTrue:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
856 |
lbl := lbl , ' Warning' |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
857 |
] ifFalse:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
858 |
lbl := lbl , ' Error'. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
859 |
]. |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
860 |
|
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
861 |
" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
862 |
ask if we should abort or continue |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
863 |
" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
864 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
4386 | 865 |
|box makeSpace| |
866 |
||
867 |
doNotShowAgainHolder := false asValue. |
|
868 |
doNotShowAgainForThisMethodHolder := false asValue. |
|
869 |
||
870 |
box := ex box. |
|
4504 | 871 |
box label:lbl. |
872 |
box perform:#image: with:(WarningBox iconBitmap) ifNotUnderstood:[]. |
|
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
873 |
|
4386 | 874 |
aCompiler notNil ifTrue:[ |
875 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
876 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
877 |
makeSpace value. |
|
878 |
box verticalPanel |
|
879 |
add:(CheckBox label:'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
880 |
model:doNotShowAgainHolder). |
|
881 |
]. |
|
882 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
883 |
makeSpace value. |
|
884 |
box verticalPanel |
|
4398 | 885 |
add:(CheckBox label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
4386 | 886 |
model:doNotShowAgainForThisMethodHolder). |
887 |
]. |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
888 |
]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
889 |
] do:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
890 |
answer := OptionBox |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
891 |
request:aString |
4279
f944300bc0be
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4278
diff
changeset
|
892 |
buttonLabels:(resources array:#('Abort' "'Keep Selected'" 'Continue')) |
f944300bc0be
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4278
diff
changeset
|
893 |
values:#(false "#keepSelected" true) |
4278
b13960d1a2cc
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4274
diff
changeset
|
894 |
default:(asWarning ifTrue:true ifFalse:false). |
4750 | 895 |
answer := answer ? false. "/ if escaped |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
896 |
]. |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
897 |
"/ box := YesNoBox |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
898 |
"/ title:aString |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
899 |
"/ yesText:(resources string:'Continue') |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
900 |
"/ noText:(resources string:'Abort'). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
901 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
902 |
"/ box label:lbl. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
903 |
"/ box image:(WarningBox iconBitmap). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
904 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
905 |
"/ (aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
906 |
"/ doNotShowAgainHolder := false asValue. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
907 |
"/ 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
|
908 |
"/ ]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
909 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
910 |
"/ "/ answer := box confirm. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
911 |
"/ answer := box confirm. |
3007 | 912 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
913 |
doNotShowAgainHolder value == true ifTrue:[ |
4125
eeed55ffc143
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4103
diff
changeset
|
914 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
915 |
]. |
4386 | 916 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
917 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
918 |
]. |
|
3007 | 919 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
920 |
"/ box destroy. |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
921 |
]. |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
922 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
923 |
answer == #keepSelected ifTrue:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
924 |
self hideCursor. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
925 |
"redraw selection in normal color" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
926 |
self invalidate. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
927 |
AbortOperationRequest raise. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
928 |
]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
929 |
|
201 | 930 |
" |
931 |
do the abort if we have to |
|
932 |
" |
|
3397 | 933 |
answer ifFalse:[ |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
934 |
"redraw selection in normal color" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
935 |
self invalidate. |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
936 |
AbortOperationRequest raise. |
201 | 937 |
]. |
938 |
^ 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
|
939 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
940 |
"Created: / 24-11-1995 / 22:56:34 / cg" |
4398 | 941 |
"Modified: / 08-03-2012 / 10:24:21 / cg" |
201 | 942 |
! |
943 |
||
2663 | 944 |
highlightingErrorLine:lineNr do:aBlock |
945 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
946 |
||
947 |
|linePosition| |
|
948 |
||
949 |
linePosition := self characterPositionOfLine:lineNr col:1. |
|
950 |
self highlightingErrorPosition:linePosition to:nil do:aBlock |
|
951 |
! |
|
952 |
||
59 | 953 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
954 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 955 |
|
3007 | 956 |
self |
957 |
highlightingErrorPosition:relPos to:relEndPos |
|
958 |
withForeground:(self errorForegroundColor) andBackground:(self errorBackgroundColor) |
|
959 |
do:aBlock |
|
960 |
! |
|
961 |
||
962 |
highlightingErrorPosition:relPos to:relEndPos withForeground:hilightFg andBackground:hilightBg do:aBlock |
|
963 |
"evaluate aBlock while some selection is shown highlighted with colors passed as args." |
|
964 |
||
965 |
|absPosition oldFg oldBg| |
|
0 | 966 |
|
58 | 967 |
" |
968 |
change color of selection & hide cursor |
|
969 |
" |
|
3007 | 970 |
oldFg := selectionFgColor. |
971 |
oldBg := selectionBgColor. |
|
972 |
selectionBgColor := hilightBg. |
|
973 |
selectionFgColor := hilightFg. |
|
58 | 974 |
self hideCursor. |
0 | 975 |
|
58 | 976 |
" |
977 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
978 |
we have to adjust the positions given by the compiler, since they |
|
979 |
are relative to the texts start (the compiler did stream-read the code). |
|
980 |
" |
|
0 | 981 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
3427 | 982 |
absPosition := codeStartPosition + (relPos ? 1) - 1. |
0 | 983 |
relEndPos isNil ifTrue:[ |
4141
06c97cc2bf6d
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
984 |
self selectFromCharacterPosition:absPosition. |
06c97cc2bf6d
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
985 |
"/ self selectLineWhereCharacterPosition:absPosition. |
0 | 986 |
] ifFalse:[ |
3427 | 987 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + (relEndPos ? 1) - 1) |
0 | 988 |
]. |
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
989 |
expandingTop := true. "/ hack to make the top of the selection visible |
0 | 990 |
self makeSelectionVisible. |
991 |
||
155 | 992 |
device flush. |
58 | 993 |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
994 |
aBlock ensure:[ |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
995 |
" |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
996 |
undo selection color change and show cursor again |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
997 |
" |
3007 | 998 |
selectionFgColor := oldFg. |
999 |
selectionBgColor := oldBg. |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
1000 |
self showCursor. |
0 | 1001 |
]. |
3427 | 1002 |
|
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
1003 |
"Modified: / 30-06-2011 / 17:24:04 / cg" |
0 | 1004 |
! |
1005 |
||
3007 | 1006 |
highlightingWarningPosition:relPos to:relEndPos do:aBlock |
1007 |
"evaluate aBlock while some selection is shown highlighted with warning colors." |
|
1008 |
||
1009 |
self |
|
1010 |
highlightingErrorPosition:relPos to:relEndPos |
|
1011 |
withForeground:(self warningForegroundColor) andBackground:(self warningBackgroundColor) |
|
1012 |
do:aBlock |
|
1013 |
! |
|
1014 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1015 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1016 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1017 |
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
|
1018 |
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
|
1019 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1020 |
|
4386 | 1021 |
|action doNotShowAgainHolder doNotShowAgainForThisMethodHolder| |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1022 |
|
3007 | 1023 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1024 |
doNotShowAgainHolder := false asValue. |
4386 | 1025 |
doNotShowAgainForThisMethodHolder := false asValue. |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1026 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
4386 | 1027 |
|box makeSpace| |
1028 |
||
1029 |
box := ex box. |
|
1030 |
aCompiler notNil ifTrue:[ |
|
1031 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
1032 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
1033 |
makeSpace value. |
|
1034 |
box verticalPanel |
|
1035 |
add:(CheckBox |
|
1036 |
label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
1037 |
model:doNotShowAgainHolder). |
|
1038 |
]. |
|
1039 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
1040 |
makeSpace value. |
|
1041 |
box verticalPanel |
|
1042 |
add:(CheckBox |
|
4398 | 1043 |
label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
4386 | 1044 |
model:doNotShowAgainForThisMethodHolder). |
1045 |
]. |
|
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1046 |
]. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1047 |
] do:[ |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1048 |
action := OptionBox |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1049 |
request:aString |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
1050 |
label:(resources string:'Warning') |
2990
1373f301a694
dont send obsolete message to OptionBox
Claus Gittinger <cg@exept.de>
parents:
2983
diff
changeset
|
1051 |
image:(WarningBox iconBitmap) |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
1052 |
buttonLabels:(resources array:#('Cancel' 'Remove Variable(s)' 'Continue')) |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
1053 |
values:#(#abort #correct #continue) |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1054 |
default:#continue. |
4679 | 1055 |
action isNil ifTrue:[ action := #abort]. |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1056 |
]. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1057 |
doNotShowAgainHolder value == true ifTrue:[ |
4386 | 1058 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
1059 |
]. |
|
1060 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
1061 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1062 |
]. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1063 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1064 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1065 |
action == #abort ifTrue:[ |
4703 | 1066 |
"/ self halt. |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
1067 |
AbortOperationRequest raise. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1068 |
^ false |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1069 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1070 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
1071 |
|
4398 | 1072 |
"Modified: / 08-03-2012 / 10:23:58 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1073 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1074 |
|
116 | 1075 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 1076 |
"compiler notifies us of a warning - same behavior as error" |
0 | 1077 |
|
2277 | 1078 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 1079 |
! ! |
1080 |
||
3396 | 1081 |
!Workspace methodsFor:'drag & drop'! |
1082 |
||
1083 |
canDrop:aDropContext |
|
4090 | 1084 |
"if allowValueDrop is true, any text- or file-object can be dropped into workspace |
1085 |
(printString); otherwise, only ..." |
|
1086 |
||
1087 |
self isReadOnly ifTrue:[^ false]. |
|
3396 | 1088 |
|
4090 | 1089 |
allowValueDrop ifTrue:[^ true]. |
1090 |
^ super canDrop:aDropContext |
|
3428 | 1091 |
|
4090 | 1092 |
"/ ^ aDropContext dropObjects |
1093 |
"/ contains:[:someObject| (someObject isTextObject or:[ someObject isFileObject ])]. |
|
3396 | 1094 |
|
1095 |
"Created: / 16-08-2005 / 22:01:13 / janfrog" |
|
3428 | 1096 |
"Modified: / 28-11-2006 / 16:18:51 / cg" |
3396 | 1097 |
! |
1098 |
||
3414 | 1099 |
doDrop:aDropContext |
4631 | 1100 |
<resource: #obsolete> |
1101 |
self obsoleteMethodWarning:'should no longer be reached'. |
|
3428 | 1102 |
self drop:aDropContext |
3414 | 1103 |
|
3428 | 1104 |
"Modified: / 28-11-2006 / 16:14:51 / cg" |
4386 | 1105 |
"Modified (format): / 28-02-2012 / 11:20:38 / cg" |
3414 | 1106 |
! |
1107 |
||
1108 |
drop:aDropContext |
|
1109 |
"Any object can be dropped into workspace..." |
|
1110 |
||
3870 | 1111 |
|textObjects nonTextObjects answer text| |
1112 |
||
1113 |
textObjects := aDropContext dropObjects |
|
3887 | 1114 |
select:[:dropObject | dropObject isTextObject |
1115 |
or:[ dropObject isFileObject ]]. |
|
3870 | 1116 |
nonTextObjects := aDropContext dropObjects |
3887 | 1117 |
reject:[:dropObject | dropObject isTextObject |
1118 |
or:[ dropObject isFileObject ]]. |
|
3870 | 1119 |
|
1120 |
self dropObjects:textObjects. |
|
3414 | 1121 |
|
3870 | 1122 |
nonTextObjects notEmpty ifTrue:[ |
1123 |
answer := Dialog |
|
1124 |
confirmWithCancel:(resources |
|
1125 |
string:'Drop as textual representation or as object reference ?') |
|
1126 |
labels:(resources array:#('Cancel' 'Reference' 'Name' 'Text')) |
|
1127 |
values:#(nil #ref #name #text) |
|
1128 |
default:4. |
|
1129 |
answer isNil ifTrue:[^ self]. |
|
1130 |
(answer == #text or:[answer == #name]) ifTrue:[ |
|
1131 |
text := String streamContents:[:s | |
|
1132 |
nonTextObjects do:[:dropObject | |
|
1133 |
|obj| |
|
1134 |
||
1135 |
obj := dropObject theObject. |
|
1136 |
obj isMethod ifTrue:[ |
|
1137 |
s nextPutAll:(answer == #name ifTrue:[obj selector] ifFalse:[obj source]). |
|
1138 |
] ifFalse:[ |
|
1139 |
obj isClass ifTrue:[ |
|
1140 |
s nextPutAll:(answer == #name ifTrue:[obj name] ifFalse:[obj source asString]) |
|
1141 |
] ifFalse:[ |
|
1142 |
s nextPutAll:(answer == #name ifTrue:[obj className] ifFalse:[obj printString]) . |
|
1143 |
]. |
|
1144 |
]. |
|
1145 |
]. |
|
1146 |
]. |
|
1147 |
self paste:text. |
|
3414 | 1148 |
] ifFalse:[ |
3870 | 1149 |
nonTextObjects do:[:dropObject | |
1150 |
name := Dialog |
|
1151 |
request:(resources |
|
1152 |
string:'Name of the new Workspace Variable (refers to the dropped %1):' |
|
1153 |
with:dropObject theObject class name allBold |
|
1154 |
) |
|
1155 |
initialAnswer:'droppedObject' |
|
1156 |
okLabel:'Add' |
|
1157 |
title:'Enter Variable Name'. |
|
3414 | 1158 |
|
3870 | 1159 |
name notEmptyOrNil ifTrue:[ |
1160 |
Workspace addWorkspaceVariable:name. |
|
1161 |
(Workspace workspaceVariableAt:name) value:dropObject theObject. |
|
1162 |
self paste:name. |
|
1163 |
]. |
|
3414 | 1164 |
]. |
3870 | 1165 |
] |
3414 | 1166 |
]. |
1167 |
||
1168 |
"Created: / 13-10-2006 / 17:34:07 / cg" |
|
3396 | 1169 |
! ! |
1170 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1171 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1172 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1173 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1174 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1175 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1176 |
in the first col |
1177 |
(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
|
1178 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1179 |
|eolComment opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1180 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1181 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1182 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1183 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1184 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1185 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1186 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1187 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1188 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1189 |
|l| |
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 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1192 |
l isNil ifTrue:[l := '']. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1193 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1194 |
l := eolComment , l |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1195 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1196 |
l := opening , l , closing |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1197 |
]. |
3403 | 1198 |
self replaceLine:lineNr with:l. |
1199 |
widthOfWidestLine notNil ifTrue:[ |
|
1200 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1201 |
]. |
|
1395
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 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1204 |
|
3403 | 1205 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
1206 |
"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
|
1207 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1208 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1209 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1210 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1211 |
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
|
1212 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1213 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1214 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1215 |
|
1481 | 1216 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3210 | 1217 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
1218 |
||
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1219 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1220 |
self |
3785 | 1221 |
undoableDo:[ self commentFrom:cursorLine to:cursorLine ] |
3543 | 1222 |
info:'Comment'. |
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1223 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1224 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1225 |
|
3129 | 1226 |
self |
1227 |
undoableDo: |
|
1228 |
[ |
|
1229 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1230 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
|
1231 |
] ifFalse:[ |
|
3210 | 1232 |
commentPair := commentStrings at:2 ifAbsent:nil. |
1233 |
commentPair isNil ifTrue:[ |
|
1234 |
self beep. |
|
1235 |
] ifFalse:[ |
|
1236 |
opening := commentPair at:1. |
|
1237 |
closing := commentPair at:2. |
|
1238 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
3129 | 1239 |
|
3210 | 1240 |
e := selectionEndCol. |
1241 |
||
1242 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
1243 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
3129 | 1244 |
|
3210 | 1245 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
1246 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1247 |
toLine:selectionEndLine col:e+closing size. |
|
1248 |
] |
|
3129 | 1249 |
] |
1250 |
] |
|
1251 |
info:'comment' |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1252 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1253 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 1254 |
"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
|
1255 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1256 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1257 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1258 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1259 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1260 |
in the first col. |
1261 |
(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
|
1262 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1263 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1264 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1265 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1266 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1267 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1268 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1269 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1270 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1271 |
rest := eolComment size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1272 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1273 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1274 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1275 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1276 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1277 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1278 |
l notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1279 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1280 |
(l startsWith:eolComment) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1281 |
l := l copyFrom:rest |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1282 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1283 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1284 |
((l startsWith:opening) |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1285 |
and:[l endsWith:closing]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1286 |
l := l copyFrom:opening size + 1. |
4568
cf9f6fd6d174
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4542
diff
changeset
|
1287 |
l := l copyButLast:closing size. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1288 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1289 |
]. |
3403 | 1290 |
self replaceLine:lineNr with:l. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1291 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1292 |
]. |
3403 | 1293 |
widthOfWidestLine := nil. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1294 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1295 |
|
3403 | 1296 |
"Created: / 09-11-1997 / 01:05:43 / cg" |
1297 |
"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
|
1298 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1299 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1300 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1301 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1302 |
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
|
1303 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1304 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1305 |
|e commentPair opening closing sz1 sz2| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1306 |
|
3129 | 1307 |
(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
|
1308 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1309 |
self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1310 |
undoableDo:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1311 |
self uncommentFrom:cursorLine to:cursorLine |
3543 | 1312 |
] |
1313 |
info:'Uncomment'. |
|
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1314 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1315 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1316 |
|
3129 | 1317 |
self |
1318 |
undoableDo: |
|
1319 |
[ |
|
1320 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1321 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
|
1322 |
] ifFalse:[ |
|
1323 |
commentPair := commentStrings at:2. |
|
1324 |
opening := commentPair at:1. |
|
1325 |
closing := commentPair at:2. |
|
1326 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1327 |
||
1328 |
sz1 := opening size. |
|
1329 |
sz2 := closing size. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1330 |
|
3129 | 1331 |
((self |
1332 |
stringAtLine:selectionStartLine |
|
1333 |
from:selectionStartCol |
|
1334 |
to:selectionStartCol+sz1 - 1) = opening |
|
1335 |
and:[(self |
|
1336 |
stringAtLine:selectionEndLine |
|
1337 |
from:selectionEndCol - sz2 + 1 |
|
1338 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1339 |
|
3129 | 1340 |
self deleteCharsAtLine:selectionEndLine fromCol:selectionEndCol-sz2+1 toCol:selectionEndCol. |
1341 |
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
|
1342 |
|
3129 | 1343 |
e := selectionEndCol - sz2. |
1344 |
selectionStartLine == selectionEndLine ifTrue:[e := e - sz1]. |
|
1345 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1346 |
toLine:selectionEndLine col:e. |
|
1347 |
] |
|
1348 |
] |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1349 |
] |
3129 | 1350 |
info:'uncomment' |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1351 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1352 |
"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
|
1353 |
"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
|
1354 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1355 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1356 |
!Workspace methodsFor:'event handling'! |
3712 | 1357 |
|
0 | 1358 |
keyPress:key x:x y:y |
4587 | 1359 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #ReplaceIt |
1360 |
#BrowseIt #ImplementorsOfIt #ExpandAbbreviation |
|
1361 |
#CommentSelection #UncommentSelection)> |
|
60 | 1362 |
|
3800 | 1363 |
(key == #DoIt) ifTrue:[self doIt. ^ self]. |
1364 |
(key == #InspectIt) ifTrue:[self inspectIt. ^ self]. |
|
1365 |
(key == #PrintIt) ifTrue:[self printIt. ^ self]. |
|
1366 |
(key == #ReplaceIt) ifTrue:[self replaceIt. ^ self]. |
|
1367 |
(key == #BrowseIt) ifTrue:[self browseIt. ^ self]. |
|
1368 |
(key == #ImplementorsOfIt) ifTrue:[self browseImplementorsOfIt. ^ self]. |
|
1369 |
(key == #ExpandAbbreviation) ifTrue:[self expandAbbreviation. ^ self]. |
|
4587 | 1370 |
(key == #CommentSelection) ifTrue:[self commentSelection. ^ self]. |
1371 |
(key == #UncommentSelection) ifTrue:[self uncommentSelection. ^ self]. |
|
38 | 1372 |
|
0 | 1373 |
super keyPress:key x:x y:y |
3511 | 1374 |
|
1375 |
"Modified: / 08-11-2007 / 11:29:45 / cg" |
|
0 | 1376 |
! ! |
201 | 1377 |
|
2143 | 1378 |
!Workspace methodsFor:'executing'! |
201 | 1379 |
|
1501 | 1380 |
do:code withValueDo:aBlock |
418 | 1381 |
"helper for doIt, printIt and inspectIt. |
1382 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
1383 |
aBlock with the value. |
|
1384 |
Most work is in preparing for proper cleanup in case of abort |
|
1385 |
or other exception while the evaluation is performed. |
|
1386 |
(restore cursor, selectionColors etc.)" |
|
201 | 1387 |
|
4149 | 1388 |
|selLine selCol endLine endCol cLine cCol cleanUp executeBlock| |
201 | 1389 |
|
1390 |
code notNil ifTrue:[ |
|
2409 | 1391 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
2408 | 1392 |
|
257 | 1393 |
codeStartPosition := self characterPositionOfSelection. |
201 | 1394 |
|
257 | 1395 |
" |
1396 |
remember selection for later - if there is an error, |
|
1397 |
the notification method will highlight it. |
|
1398 |
thus destroying the current selection |
|
1399 |
" |
|
1400 |
selLine := selectionStartLine. |
|
1401 |
selCol := selectionStartCol. |
|
1402 |
endLine := selectionEndLine. |
|
1403 |
endCol := selectionEndCol. |
|
1404 |
cCol := cursorCol. |
|
1405 |
cLine := cursorLine. |
|
201 | 1406 |
|
257 | 1407 |
" |
1408 |
cleanup: restore previous selection and cursor positions |
|
1409 |
" |
|
1410 |
cleanUp := [ |
|
1411 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
1412 |
cLine notNil ifTrue:[ |
|
1413 |
self cursorLine:cLine col:cCol |
|
1414 |
]. |
|
1415 |
]. |
|
201 | 1416 |
|
257 | 1417 |
" |
1418 |
perform the action. |
|
1419 |
Be careful to release the reference to the value; |
|
1420 |
otherwise, we could keep lots of garbage from being freed |
|
1421 |
until the view gets closed |
|
1422 |
" |
|
4149 | 1423 |
executeBlock := [ |
1424 |
[ |
|
1425 |
AbortOperationRequest handle:[:ex | |
|
1426 |
"/ aBlock value:'** Abortsignal cought **'. |
|
1427 |
ex return |
|
1428 |
] do:[ |
|
1429 |
|value| |
|
929 | 1430 |
|
4149 | 1431 |
doItAction notNil ifTrue:[ |
1432 |
value := doItAction value:(code asString). |
|
1433 |
cleanUp value. cleanUp := nil. |
|
1434 |
aBlock notNil ifTrue:[ |
|
1435 |
aBlock value:value. |
|
1436 |
]. |
|
1437 |
value := nil. |
|
1438 |
self class rememberDoIt:code. |
|
1439 |
] |
|
257 | 1440 |
] |
4149 | 1441 |
] ensure:[ |
1442 |
cleanUp notNil ifTrue:[ |
|
1443 |
cleanUp value. cleanUp := nil |
|
1444 |
]. |
|
257 | 1445 |
] |
4149 | 1446 |
]. |
1447 |
aBlock isNil ifTrue:[ |
|
1448 |
"no action is performed with the result - give the user a visible |
|
1449 |
feedback, that something has been done" |
|
1450 |
self topView withVisibleCursor:Cursor execute do:executeBlock. |
|
1451 |
] ifFalse:[ |
|
1452 |
self topView withCursor:Cursor execute do:executeBlock. |
|
257 | 1453 |
]. |
201 | 1454 |
] |
257 | 1455 |
|
1501 | 1456 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
1457 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
2409 | 1458 |
"Modified: / 26.9.2001 / 17:32:59 / cg" |
4677 | 1459 |
! |
201 | 1460 |
|
2733 | 1461 |
executeDoIt:theCode |
4391 | 1462 |
"the core of doIt, printIt, inspectIt, browseIt actions" |
1463 |
||
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1464 |
| result compiler | |
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1465 |
|
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1466 |
"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
|
1467 |
[ |
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1468 |
result := ( compiler := (self compilerClass ? Compiler) new ) |
4438 | 1469 |
currentNameSpace:namespaceForDoits; |
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1470 |
moreSharedPools:poolsConsideredInDoIts; |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1471 |
evaluate:theCode |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1472 |
in:nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1473 |
receiver:simulatedSelf |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1474 |
notifying:self |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1475 |
logged:true |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1476 |
ifFail:nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1477 |
] on: Parser undefinedVariableNotification do:[:ex| |
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1478 |
(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
|
1479 |
ex proceedWith: #declare |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1480 |
] ifFalse:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1481 |
ex proceedWith: nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1482 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1483 |
] on: Parser askForVariableTypeOfUndeclaredQuery do:[:ex| |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1484 |
autoDefineVariables == #workspace ifTrue:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1485 |
ex proceedWith:#WorkspaceVariable |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1486 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1487 |
autoDefineVariables == #doIt ifTrue:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1488 |
ex proceedWith:#DoItTemporary |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1489 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1490 |
ex pass. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1491 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1492 |
^result |
4391 | 1493 |
|
4438 | 1494 |
"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
|
1495 |
"Modified: / 24-06-2013 / 15:31:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4677 | 1496 |
! ! |
1497 |
||
1498 |
!Workspace methodsFor:'initialization & release'! |
|
2733 | 1499 |
|
201 | 1500 |
initStyle |
966 | 1501 |
"setup viewStyle specifics" |
1502 |
||
201 | 1503 |
super initStyle. |
1504 |
||
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1505 |
DefaultViewBackground notNil ifTrue:[ |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1506 |
viewBackground := DefaultViewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1507 |
self backgroundColor:viewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1508 |
]. |
201 | 1509 |
! |
1510 |
||
1511 |
initialize |
|
1512 |
super initialize. |
|
1513 |
||
4593 | 1514 |
autoIndent := UserPreferences current autoIndentInCodeView. |
2775 | 1515 |
scrollWhenUpdating := #beginOfText. |
201 | 1516 |
showMatchingParenthesis := true. |
3428 | 1517 |
allowValueDrop := true. |
1518 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1519 |
commentStrings := #( |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1520 |
'"/' |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1521 |
('"' '"') |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1522 |
). |
201 | 1523 |
|
1524 |
self initializeDoITAction. |
|
3396 | 1525 |
self initializeDragAndDrop. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1526 |
|
3428 | 1527 |
"Modified: / 28-11-2006 / 16:11:55 / cg" |
201 | 1528 |
! |
1529 |
||
1530 |
initializeDoITAction |
|
1531 |
"set up the block to be evaluated for doIts. |
|
1532 |
This is done here in a separate method to allow easier |
|
1533 |
redefinition in subclasses" |
|
1534 |
||
2733 | 1535 |
doItAction := [:theCode | self executeDoIt:theCode]. |
3396 | 1536 |
! |
1537 |
||
1538 |
initializeDragAndDrop |
|
1539 |
|target| |
|
1540 |
||
1541 |
target := DropTarget |
|
1542 |
receiver:self |
|
1543 |
argument:nil |
|
3411 | 1544 |
dropSelector:#drop: |
3396 | 1545 |
canDropSelector:#canDrop:. |
1546 |
self dropTarget:target |
|
1547 |
||
1548 |
"Created: / 16-08-2005 / 22:03:36 / janfrog" |
|
3411 | 1549 |
"Modified: / 13-10-2006 / 12:37:18 / cg" |
201 | 1550 |
! ! |
1551 |
||
418 | 1552 |
!Workspace methodsFor:'menu & menu actions'! |
1553 |
||
2285 | 1554 |
browseClass |
1555 |
"user selected 'browseClass' from menu; evaluate the code |
|
1556 |
and open a browser on the resulting class (if it evaluates to one)" |
|
1557 |
||
1558 |
^ self |
|
3272 | 1559 |
do:(self selectionAsString) |
3910 | 1560 |
withValueDo:[:result | |
1561 |
result isBehavior ifTrue:[ |
|
1562 |
result browserClass openInClass:result selector:nil |
|
1563 |
] ifFalse:[ |
|
1564 |
self warn:'Selection does not evaluate to a class' |
|
1565 |
] |
|
1566 |
]. |
|
2285 | 1567 |
|
2410 | 1568 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 1569 |
! |
1570 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1571 |
browseImplementorsOfIt |
4617 | 1572 |
"open a browser on the implementors of the selected text, |
1573 |
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
|
1574 |
|
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1575 |
|selectedText selector browserClass na| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1576 |
|
4617 | 1577 |
selectedText := self selectedTextOrSyntaxElement. |
1578 |
selectedText notEmptyOrNil ifTrue:[ |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1579 |
self windowGroup withWaitCursorDo:[ |
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1580 |
"/ 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
|
1581 |
(compilerClass notNil and:[compilerClass includesBehavior:JavaScriptParser]) ifTrue:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1582 |
"/ selector is in one piece anyway |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1583 |
(selectedText includes:$_) ifFalse:[ |
3896 | 1584 |
"/ 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
|
1585 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:1. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1586 |
selectedText := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:0. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1587 |
] ifTrue:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1588 |
"/ count _#s plus one arg - sigh |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1589 |
na := (selectedText occurrencesOf:$_) + 1. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1590 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:na |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1591 |
]. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1592 |
] ifFalse:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1593 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1594 |
]. |
4619 | 1595 |
browserClass := UserPreferences systemBrowserClass. |
2714 | 1596 |
|
3287 | 1597 |
(selector notNil and:[selector ~= selectedText]) ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1598 |
(SystemBrowser |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1599 |
findImplementorsOfAny:(Array with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1600 |
in:(Smalltalk allClasses) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1601 |
ignoreCase:false) isEmpty ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1602 |
browserClass browseImplementorsOf:selector |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1603 |
] ifFalse:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1604 |
browserClass browseImplementorsOfAny:(Set with:selector with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1605 |
]. |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1606 |
] ifFalse:[ |
2714 | 1607 |
browserClass browseImplementorsOf:(selector ? selectedText) |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1608 |
] |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1609 |
] |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1610 |
]. |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1611 |
|
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1612 |
"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
|
1613 |
"Modified: / 19.11.2001 / 22:15:17 / cg" |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1614 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1615 |
|
2307 | 1616 |
browseIt |
1617 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
2713 | 1618 |
or the class of the resulting object (if it does not evaluate to a class). |
1619 |
||
1620 |
Added feature: if selection is of the form class >> selector, immediately switch to that selector." |
|
1621 |
||
4617 | 1622 |
|codeToEvaluate el idx selector evaluatedValue classToBrowse gotResult| |
2713 | 1623 |
|
4617 | 1624 |
(self selection isEmptyOrNil |
1625 |
and:[ self supportsSyntaxElements |
|
1626 |
and:[ (el := self syntaxElementForVariableUnderCursor) notNil ]]) |
|
1627 |
ifTrue:[ |
|
1628 |
codeToEvaluate := el name |
|
1629 |
] ifFalse:[ |
|
1630 |
codeToEvaluate := (self selectionOrTextOfCursorLine ? '') withoutSeparators. |
|
1631 |
]. |
|
2713 | 1632 |
idx := codeToEvaluate indexOfSubCollection:'>>'. |
1633 |
idx ~~ 0 ifTrue:[ |
|
2717 | 1634 |
selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string. |
3155 | 1635 |
(selector startsWith:'#') ifTrue:[ |
1636 |
selector := Symbol readFrom:selector. |
|
1637 |
]. |
|
2713 | 1638 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
1639 |
]. |
|
2307 | 1640 |
|
3910 | 1641 |
Parser parseErrorSignal handle:[:ex | |
1642 |
|className| |
|
2410 | 1643 |
|
3910 | 1644 |
"/ fallback, if garbage is selected, look for matching classes. |
1645 |
className := SystemBrowser |
|
1646 |
askForClassNameMatching:codeToEvaluate |
|
1647 |
inEnvironment:nil |
|
1648 |
for:nil. |
|
4386 | 1649 |
|
3910 | 1650 |
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
|
1651 |
classToBrowse := Smalltalk classNamed:className. |
3910 | 1652 |
] do:[ |
4386 | 1653 |
gotResult := false. |
1654 |
||
3910 | 1655 |
self |
1656 |
do:codeToEvaluate |
|
4386 | 1657 |
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
|
1658 |
|
4386 | 1659 |
gotResult ifFalse:[^ self]. |
1660 |
||
1661 |
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
|
1662 |
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
|
1663 |
codeToEvaluate isUppercaseFirst ifTrue:[ |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1664 |
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
|
1665 |
^ self. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1666 |
]. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1667 |
] |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1668 |
]. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1669 |
classToBrowse := evaluatedValue isBehavior |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1670 |
ifTrue:[ evaluatedValue ] |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1671 |
ifFalse:[ evaluatedValue class ]. |
3910 | 1672 |
]. |
1673 |
||
1674 |
classToBrowse browserClass openInClass:classToBrowse selector:selector |
|
4386 | 1675 |
|
1676 |
"Modified: / 28-02-2012 / 11:23:06 / cg" |
|
2307 | 1677 |
! |
1678 |
||
2285 | 1679 |
browseItsClass |
1680 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
1681 |
and open a browser on the results class" |
|
1682 |
||
1683 |
^ self |
|
3272 | 1684 |
do:(self selectionAsString) |
2410 | 1685 |
withValueDo:[:result | |
1686 |
result class browserClass openInClass:result class selector:nil |
|
1687 |
] |
|
2285 | 1688 |
|
2410 | 1689 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 1690 |
! |
1691 |
||
2454 | 1692 |
browseReferencesToIt |
1693 |
"open a browser on all references to the selected global" |
|
1694 |
||
4675 | 1695 |
|nameOfGlobal| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1696 |
|
4675 | 1697 |
nameOfGlobal := self selectedTextOrSyntaxElement. |
1698 |
nameOfGlobal notEmptyOrNil ifTrue:[ |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1699 |
self windowGroup withWaitCursorDo:[ |
4675 | 1700 |
|cls privateClass| |
1701 |
||
1702 |
((cls := self editedClass) notNil |
|
1703 |
and:[ (cls theNonMetaclass allClassVarNames includes:nameOfGlobal) ]) ifTrue:[ |
|
1704 |
(UserPreferences systemBrowserClass) |
|
1705 |
browseRefsTo:nameOfGlobal |
|
1706 |
classVars:true |
|
1707 |
in:(cls whichClassDefinesClassVar:nameOfGlobal) withAllSubclasses |
|
1708 |
modificationsOnly:false. |
|
1709 |
] ifFalse:[ |
|
1710 |
(cls notNil |
|
1711 |
and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfGlobal) notNil ]) ifTrue:[ |
|
1712 |
(UserPreferences systemBrowserClass) |
|
1713 |
browseReferendsOf:(privateClass name) |
|
1714 |
] ifFalse:[ |
|
1715 |
(UserPreferences systemBrowserClass) browseReferendsOf:nameOfGlobal |
|
1716 |
] |
|
1717 |
] |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1718 |
]. |
2454 | 1719 |
]. |
1720 |
||
1721 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
1722 |
"Modified: / 5.11.2001 / 17:32:38 / cg" |
|
1723 |
! |
|
1724 |
||
2462 | 1725 |
browseSendersOfIt |
1726 |
"open a browser on the senders of the selected text" |
|
1727 |
||
2715 | 1728 |
|selectedText selector| |
2462 | 1729 |
|
4617 | 1730 |
selectedText := self selectedTextOrSyntaxElement. |
1731 |
selectedText notEmptyOrNil ifTrue:[ |
|
2462 | 1732 |
self windowGroup withWaitCursorDo:[ |
3287 | 1733 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
4619 | 1734 |
(UserPreferences systemBrowserClass) |
2715 | 1735 |
browseAllCallsOn:(selector ? selectedText) |
2462 | 1736 |
] |
1737 |
]. |
|
1738 |
||
1739 |
"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
|
1740 |
"Modified: / 19.11.2001 / 22:15:27 / cg" |
2462 | 1741 |
! |
1742 |
||
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1743 |
browseSharedPoolOfIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1744 |
"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
|
1745 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1746 |
|sel| |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1747 |
|
4617 | 1748 |
sel := self selectedTextOrSyntaxElement. |
1749 |
sel notEmptyOrNil ifTrue:[ |
|
1750 |
sel := sel asSymbol. |
|
1751 |
self windowGroup withWaitCursorDo:[ |
|
1752 |
SharedPool allSubclassesDo:[:eachPool | |
|
1753 |
(eachPool includesKey:sel) ifTrue:[ |
|
4619 | 1754 |
(UserPreferences systemBrowserClass) |
4617 | 1755 |
openInClass:eachPool class selector:#initialize |
1756 |
]. |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1757 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1758 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1759 |
]. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1760 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1761 |
"Created: / 15-01-2011 / 14:01:39 / cg" |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1762 |
! |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1763 |
|
418 | 1764 |
doIt |
1765 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
1766 |
and finally restore cursor; return result of evaluation" |
|
1767 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1768 |
^ self |
3272 | 1769 |
do:(self selectionOrTextOfCursorLine) |
4149 | 1770 |
withValueDo:nil |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1771 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1772 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 1773 |
! |
1774 |
||
1775 |
editMenu |
|
1107 | 1776 |
"return my popUpMenu; thats the superclasses menu |
1777 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
|
1778 |
||
2459 | 1779 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
1780 |
#CommentSelection #UncommentSelection |
|
2573
52c995a1ea78
accelerators for browseIt and implementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
2571
diff
changeset
|
1781 |
#BrowseIt #ImplementorsOfIt |
2459 | 1782 |
)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
1783 |
<resource: #programMenu> |
489 | 1784 |
|
2867 | 1785 |
|m sub subsub idx sensor s s2| |
418 | 1786 |
|
1787 |
m := super editMenu. |
|
3252 | 1788 |
((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
2459 | 1789 |
sub := m. |
1790 |
m := nil. |
|
1791 |
] ifFalse:[ |
|
1792 |
sub := m subMenuAt:#others. |
|
1793 |
]. |
|
418 | 1794 |
|
2459 | 1795 |
sub notNil ifTrue:[ |
2867 | 1796 |
|
2459 | 1797 |
" |
2867 | 1798 |
workspaces support #browse, implementors etc. add them after paste. |
2459 | 1799 |
" |
2867 | 1800 |
sub |
1801 |
addItemList:#( |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1802 |
('-' ) |
3910 | 1803 |
('Browse' browseIt BrowseIt ) |
4617 | 1804 |
('Browse Pool' browseSharedPoolOfIt ) |
3910 | 1805 |
('Senders of It' browseSendersOfIt ) |
1806 |
('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
|
1807 |
('References to It' browseReferencesToIt ) |
|
1808 |
"/ ('Classes Containing It in Name' browseClassesContainingItInName ) |
|
1809 |
"/ ('Methods Contaníning It in Name' browseMethodsContainingItInName ) |
|
1810 |
"/ ('Methods Contaníning It in Source' browseMethodsContainingItInSource ) |
|
2867 | 1811 |
('-' ) |
1812 |
('TimeIt' timeIt ) |
|
1813 |
('SpyOnIt' spyOnIt )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1814 |
resources:resources |
2459 | 1815 |
after:#gotoLine. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1816 |
|
2867 | 1817 |
subsub := sub subMenuAt:#tools. |
1818 |
subsub notNil ifTrue:[ |
|
1819 |
subsub |
|
1820 |
addItemList:#( |
|
1821 |
('-' ) |
|
1822 |
('Comment' commentSelection CommentSelection ) |
|
1823 |
('Uncomment' uncommentSelection UncommentSelection )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1824 |
resources:resources |
2867 | 1825 |
after:#'indent'. |
1826 |
]. |
|
1827 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1828 |
self hasSelection ifFalse:[ |
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1829 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1830 |
browseReferencesToIt timeIt spyOnIt |
4617 | 1831 |
browseSharedPoolOfIt browseIt). |
1832 |
self supportsSyntaxElements ifTrue:[ |
|
1833 |
self syntaxElementForSelectorUnderCursor notNil ifTrue:[ |
|
1834 |
sub enableAll:#(browseImplementorsOfIt browseSendersOfIt ) |
|
1835 |
] ifFalse:[ |
|
1836 |
|el| |
|
1837 |
||
1838 |
(el := self syntaxElementForVariableUnderCursor) notNil ifTrue:[ |
|
1839 |
el isGlobal ifTrue:[ |
|
1840 |
sub enable: #browseReferencesToIt |
|
1841 |
]. |
|
1842 |
el isClass ifTrue:[ |
|
1843 |
sub enable:#browseIt |
|
1844 |
] |
|
1845 |
] |
|
1846 |
] |
|
1847 |
]. |
|
2454 | 1848 |
] ifTrue:[ |
1849 |
s := self selectionAsString. |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1850 |
s notNil ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1851 |
s asSymbolIfInterned isNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1852 |
s2 := SystemBrowser extractSelectorFrom:s. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1853 |
s2 notNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1854 |
s2 := s2 asSymbolIfInterned. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1855 |
]. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1856 |
]. |
2454 | 1857 |
]. |
2487
47e0a1faf544
disabling of impl/senders menu
Claus Gittinger <cg@exept.de>
parents:
2485
diff
changeset
|
1858 |
(s2 isNil and:[s isNil]) ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1859 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1860 |
]. |
3959 | 1861 |
"/ a global or namespace-var selected ? |
4459 | 1862 |
s isNil ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1863 |
sub disable:#browseReferencesToIt. |
4459 | 1864 |
] ifFalse:[ |
1865 |
(s asSymbolIfInterned notNil |
|
1866 |
and:[ (Smalltalk includesKey:s asSymbol) |
|
4617 | 1867 |
or:[ (NameSpace allNameSpaces contains:[:ns | ns includesKey:s asSymbol]) ]] |
1868 |
) ifTrue:[ |
|
1869 |
"/ a global or namespace var selected |
|
4459 | 1870 |
] ifFalse:[ |
4675 | 1871 |
|cls| |
1872 |
||
1873 |
((cls := self editedClass) notNil |
|
1874 |
and:[ (cls theNonMetaclass allClassVarNames includes:s) |
|
1875 |
or:[ (cls theNonMetaclass privateClassNamed:s) notNil ]]) ifTrue:[ |
|
1876 |
"/ a classvar or private class |
|
1877 |
] ifFalse:[ |
|
1878 |
"/ todo: an instvar selected? |
|
1879 |
sub disable:#browseReferencesToIt. |
|
1880 |
]. |
|
4459 | 1881 |
]. |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1882 |
]. |
4342 | 1883 |
(s notNil |
1884 |
and:[ s asSymbolIfInterned notNil |
|
1885 |
and:[ (SharedPool allSubclasses contains:[:pool | pool includesKey:s asSymbol]) ]]) ifFalse:[ |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1886 |
sub disable:#browseSharedPoolOfIt. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1887 |
]. |
4584 | 1888 |
]. |
1889 |
self isReadOnly ifTrue:[ |
|
1890 |
sub disableAll:#(commentSelection uncommentSelection) |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1891 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1892 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1893 |
|
2459 | 1894 |
m notNil ifTrue:[ |
1895 |
" |
|
1896 |
workspaces support #doIt, #printIt and #inspectIt |
|
1897 |
add them after paste. |
|
1898 |
" |
|
1899 |
idx := m indexOf:#paste. |
|
1900 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
1901 |
idx ~~ 0 ifTrue:[ |
|
2867 | 1902 |
m |
1903 |
addItemList:#( |
|
1904 |
('-' ) |
|
1905 |
('DoIt' doIt DoIt ) |
|
1906 |
('PrintIt' printIt PrintIt ) |
|
1907 |
('InspectIt' inspectIt InspectIt)) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1908 |
resources:resources |
2459 | 1909 |
after:idx. |
1910 |
||
1911 |
]. |
|
1912 |
||
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
1913 |
(self hasSelectionOrTextInCursorLine) ifFalse:[ |
3272 | 1914 |
|lNr line| |
1915 |
||
1916 |
lNr := self cursorLine. |
|
1917 |
line := self listAt:lNr. |
|
1918 |
line isEmptyOrNil ifTrue:[ |
|
1919 |
m disableAll:#(printIt doIt inspectIt browseIt) |
|
1920 |
]. |
|
2459 | 1921 |
]. |
2595 | 1922 |
self isReadOnly ifTrue:[ |
1923 |
m disable:#printIt |
|
1924 |
]. |
|
418 | 1925 |
]. |
1926 |
||
2459 | 1927 |
^ m ? sub. |
430 | 1928 |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1929 |
"Modified: / 22-04-1998 / 21:49:06 / ca" |
4342 | 1930 |
"Modified: / 20-12-2011 / 11:22:20 / cg" |
418 | 1931 |
! |
1932 |
||
1933 |
inspectIt |
|
1934 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
1935 |
and start an inspector on the result" |
|
1936 |
||
2981
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1937 |
|shifted| |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1938 |
|
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1939 |
shifted := self sensor shiftDown. |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1940 |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1941 |
^ self |
3272 | 1942 |
do:(self selectionOrTextOfCursorLine) |
2982
9a831ab53acc
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2981
diff
changeset
|
1943 |
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
|
1944 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1945 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 1946 |
! |
1947 |
||
1948 |
printIt |
|
1949 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
1950 |
and insert result of evaluation into my text. |
|
1951 |
If the text is readOnly, do nothing." |
|
1952 |
||
1734 | 1953 |
self isReadOnly ifTrue:[ |
3511 | 1954 |
self beep. |
1955 |
^ self. |
|
1956 |
]. |
|
1957 |
self |
|
1958 |
undoableDo:[ |
|
1959 |
self |
|
1960 |
do:(self selectionOrTextOfCursorLine) |
|
4367 | 1961 |
withValueDo:[:result | |
1962 |
|s| |
|
1963 |
||
3511 | 1964 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
4367 | 1965 |
(result isInteger |
1966 |
and:[ result > 10 |
|
4401 | 1967 |
and:[ InspectorView defaultIntegerDisplayRadix ~= 10 ]]) ifTrue:[ |
1968 |
s := result displayString , ' "',(result radixPrintStringRadix: InspectorView defaultIntegerDisplayRadix),'"'. |
|
4367 | 1969 |
] ifFalse:[ |
1970 |
s := result displayString "printString" |
|
1971 |
]. |
|
1972 |
self insertSelectedStringAtCursor:s |
|
3511 | 1973 |
] |
1974 |
] |
|
1975 |
info:'PrintIt' |
|
1976 |
||
4401 | 1977 |
"Modified: / 08-03-2012 / 16:14:34 / cg" |
3511 | 1978 |
! |
418 | 1979 |
|
4471 | 1980 |
profileIt |
1981 |
"user selected 'profileIt' from menu; show a wait-cursor, profile the code |
|
4472 | 1982 |
and finally restore the cursor. Open a visual profiler on the sample data." |
4471 | 1983 |
|
4472 | 1984 |
self spyOnItUsing:Tools::Profiler |
4471 | 1985 |
! |
1986 |
||
3511 | 1987 |
replaceIt |
1988 |
"like printIt, but replace the selection with the result, instead of |
|
1989 |
pasting it after the selection." |
|
1990 |
||
1991 |
self isReadOnly ifTrue:[ |
|
1992 |
self beep. |
|
1993 |
^ self |
|
1994 |
]. |
|
1995 |
||
1996 |
self |
|
1997 |
undoableDo:[ |
|
1998 |
self |
|
1999 |
do:(self selectionOrTextOfCursorLine) |
|
2000 |
withValueDo:[:result | |
|
2001 |
self replaceSelectionBy:(result displayString "printString") |
|
2002 |
]. |
|
2003 |
undoSupport actionInfo:'ReplaceIt'. |
|
2004 |
] |
|
2005 |
info:'ReplaceIt' |
|
2006 |
||
2007 |
"Created: / 08-11-2007 / 11:31:54 / cg" |
|
1501 | 2008 |
! |
2009 |
||
2010 |
spyOnIt |
|
2011 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
4472 | 2012 |
and finally restore the cursor. Show profile data on the Transcript" |
2013 |
||
2014 |
self spyOnItUsing:MessageTally |
|
2015 |
! |
|
2016 |
||
2017 |
spyOnItUsing:aProfiler |
|
2018 |
"common code for spyOnIt / profileIt. |
|
2019 |
Show a wait-cursor, evaluate the code with profier on it, |
|
2020 |
and finally restore the cursor. Show profile data as per profiler" |
|
1501 | 2021 |
|
2022 |
|code| |
|
2023 |
||
4427 | 2024 |
compilerClass == Smalltalk::Compiler ifFalse:[ |
2025 |
"sigh - this measurement will include the time to compile - sigh" |
|
4472 | 2026 |
aProfiler spyDetailedOn:[ self doIt ]. |
4427 | 2027 |
^ self. |
2028 |
]. |
|
2029 |
||
4472 | 2030 |
code := aProfiler name,' spyDetailedOn:[' , self selectionAsString, ']'. |
4149 | 2031 |
self do:code withValueDo:[:value| ]. |
1501 | 2032 |
! |
2033 |
||
2034 |
timeIt |
|
2035 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
2036 |
and finally restore cursor; return result of evaluation" |
|
2037 |
||
4427 | 2038 |
|code t| |
2039 |
||
2040 |
compilerClass == Smalltalk::Compiler ifFalse:[ |
|
2041 |
"sigh - this measurement will include the time to compile - sigh" |
|
2042 |
t := Time millisecondsToRun:[ self doIt ]. |
|
2043 |
Transcript showCR:'execution time: ' , t printString , ' ms'. |
|
2044 |
^ self. |
|
2045 |
]. |
|
1501 | 2046 |
|
3272 | 2047 |
code := '|t| t := Time millisecondsToRun:[' , self selectionAsString, ']. |
4149 | 2048 |
Transcript showCR:''execution time: '' , t printString , '' ms''.'. |
2049 |
self do:code withValueDo:[:value | ]. |
|
1501 | 2050 |
|
4427 | 2051 |
"Modified: / 22-04-1998 / 22:03:51 / ca" |
2052 |
"Modified (format): / 02-06-2012 / 00:38:51 / cg" |
|
418 | 2053 |
! ! |
2054 |
||
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2055 |
!Workspace methodsFor:'misc'! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2056 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2057 |
expandAbbreviation |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2058 |
"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
|
2059 |
cursor, find an abbrev for it and expand." |
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 |
|expandedString abortExpandAction oldSelectionStartLine oldSelectionStartCol oldSelectionEndLine oldSelectionEndCol oldCursorLine oldCursorCol |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2062 |
newCursorPos replStartCol| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2063 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2064 |
oldCursorLine := self cursorLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2065 |
oldCursorCol := self cursorCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2066 |
oldSelectionStartLine := self selectionStartLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2067 |
oldSelectionStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2068 |
oldSelectionEndLine := self selectionEndLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2069 |
oldSelectionEndCol := self selectionEndCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2070 |
|
4706 | 2071 |
abortExpandAction := |
2072 |
[ |
|
2073 |
self |
|
2074 |
selectFromLine:oldSelectionStartLine col:oldSelectionStartCol |
|
2075 |
toLine:oldSelectionEndLine col:oldSelectionEndCol. |
|
2076 |
self cursorLine:oldCursorLine col:oldCursorCol. |
|
2077 |
]. |
|
2078 |
||
2079 |
expandedString := self selectAbbreviationKeyBeforeCursor. "/ returns the new string AND selects the key |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2080 |
expandedString isNil ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2081 |
abortExpandAction value. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2082 |
^ self |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2083 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2084 |
newCursorPos := expandedString indexOf:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2085 |
newCursorPos ~~ 0 ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2086 |
expandedString := expandedString copyWithout:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2087 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2088 |
replStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2089 |
self |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2090 |
undoableDo:[ |
4743 | 2091 |
self replaceSelectionBy: expandedString |
4706 | 2092 |
] |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2093 |
info:'Replace'. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2094 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2095 |
newCursorPos == 0 ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2096 |
"/ cursor already fine (at the end) |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2097 |
] ifFalse:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2098 |
self cursorCol:replStartCol+newCursorPos-1 |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2099 |
] |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2100 |
! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2101 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2102 |
findAbbreviationKeyBeforeCursor |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2103 |
"after receiving an Alt-shift key-event, look for the string before the |
4706 | 2104 |
cursor, find an abbrev for it, return the key and the abbreviation for it. |
2105 |
If none is found, return nil" |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2106 |
|
4745 | 2107 |
|snippets keys minMax maxKeyLen minKeyLen stringBeforeCursor| |
2108 |
||
2109 |
snippets := self class sniplets. |
|
2110 |
keys := snippets keys. |
|
4714 | 2111 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2112 |
minMax := (keys collect:[:k | k size]) minMax. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2113 |
minKeyLen := minMax first. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2114 |
maxKeyLen := minMax second. |
4714 | 2115 |
|
2116 |
stringBeforeCursor := self lineStringBeforeCursor. |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2117 |
maxKeyLen := maxKeyLen min:stringBeforeCursor size. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2118 |
|
4706 | 2119 |
maxKeyLen to:minKeyLen by:-1 do:[:keyLen | |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2120 |
|lCharactersBeforeCursor expandedString| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2121 |
|
4706 | 2122 |
lCharactersBeforeCursor := stringBeforeCursor last:keyLen. |
4745 | 2123 |
expandedString := snippets at:lCharactersBeforeCursor ifAbsent:nil. |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2124 |
expandedString notNil ifTrue:[ |
4706 | 2125 |
^ { lCharactersBeforeCursor . expandedString withCRs } |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2126 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2127 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2128 |
^ nil. |
4185 | 2129 |
|
2130 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
4617 | 2131 |
! |
2132 |
||
4706 | 2133 |
selectAbbreviationKeyBeforeCursor |
2134 |
"after receiving an Alt-shift key-event, look for the string before the |
|
2135 |
cursor, find an abbrev for it, select it and return the abbreviation for it. |
|
2136 |
If none is found, do not select and return nil" |
|
2137 |
||
4745 | 2138 |
|keyAndSnippet snippet key| |
2139 |
||
2140 |
(keyAndSnippet := self findAbbreviationKeyBeforeCursor) notNil ifTrue:[ |
|
2141 |
key := keyAndSnippet first. |
|
2142 |
snippet := keyAndSnippet second. |
|
4706 | 2143 |
self selectFromLine:cursorLine col:cursorCol-key size toLine:cursorLine col:cursorCol-1. |
4745 | 2144 |
^ snippet |
4706 | 2145 |
]. |
2146 |
^ nil. |
|
2147 |
||
2148 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
2149 |
! |
|
2150 |
||
4617 | 2151 |
selectedTextOrSyntaxElement |
2152 |
|selectedText el| |
|
2153 |
||
2154 |
selectedText := self selectionAsString. |
|
2155 |
selectedText isEmptyOrNil ifTrue:[ |
|
2156 |
self supportsSyntaxElements ifTrue:[ |
|
2157 |
el := self syntaxElementForSelectorUnderCursor. |
|
2158 |
el notNil ifTrue:[ selectedText := el value ]. |
|
2159 |
] |
|
2160 |
]. |
|
2161 |
^ selectedText |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2162 |
! ! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2163 |
|
2646 | 2164 |
!Workspace methodsFor:'queries'! |
2165 |
||
2166 |
isWorkspace |
|
4395 | 2167 |
"back-query from the compiler to ask if this is an interactive view |
2168 |
(for error feedback)" |
|
2169 |
||
2646 | 2170 |
^ true |
4395 | 2171 |
|
2172 |
"Modified (comment): / 07-03-2012 / 17:52:59 / cg" |
|
2646 | 2173 |
! ! |
2174 |
||
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2175 |
!Workspace::CodeCompletionService class methodsFor:'instance creation'! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2176 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2177 |
for:anEditView |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2178 |
^ self new editView:anEditView |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2179 |
! ! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2180 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2181 |
!Workspace::CodeCompletionService methodsFor:'accessing'! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2182 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2183 |
editView:something |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2184 |
editView := something. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2185 |
! ! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2186 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2187 |
!Workspace::CodeCompletionService methodsFor:'events'! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2188 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2189 |
buttonPress:button x:x y:y |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2190 |
self closeCompletionView. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2191 |
! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2192 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2193 |
editViewLostFocus |
4714 | 2194 |
completionView notNil ifTrue:[ |
2195 |
self closeCompletionView |
|
2196 |
] |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2197 |
! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2198 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2199 |
handleKeyPress:key x:x y:y |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2200 |
"return true, if I have eaten this keypress" |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2201 |
|
4741 | 2202 |
|ch completeImmediate eatCursorLeftOrRight| |
2203 |
||
2204 |
completeImmediate := UserPreferences current immediateCodeCompletion. |
|
2205 |
||
4737 | 2206 |
"/ open on CTRL- or TAB-key? |
4716 | 2207 |
(completionView isNil or:[completionView realized not]) ifTrue:[ |
4737 | 2208 |
editView hasSelection ifFalse:[ |
2209 |
((ch := editView characterBeforeCursor) notNil "/ i.e. not at begin of line |
|
2210 |
and:[ ch isSeparator not ]) ifTrue:[ |
|
4762 | 2211 |
(key == #Control_L or:[ key == #Ctrl or:[ key == #Control_R or:[ key == #Control]]]) ifTrue:[ |
4737 | 2212 |
UserPreferences current codeCompletionOnControlKey ifTrue:[ |
2213 |
autoSelect := true. |
|
2214 |
self updateCompletionList |
|
2215 |
] |
|
2216 |
]. |
|
2217 |
(key == #Tab) ifTrue:[ |
|
2218 |
UserPreferences current codeCompletionOnTabKey ifTrue:[ |
|
2219 |
autoSelect := true. |
|
2220 |
self updateCompletionList. |
|
2221 |
^ true |
|
2222 |
]. |
|
4726 | 2223 |
] |
2224 |
]. |
|
4725 | 2225 |
]. |
4716 | 2226 |
^ false. |
2227 |
]. |
|
2228 |
||
4735 | 2229 |
"/ key for completion view ? (careful: do not forward too many, it would disturb user's typing) |
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2230 |
key isCharacter ifFalse:[ |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2231 |
"/ forward to menu |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2232 |
completionView notNil ifTrue:[ |
4741 | 2233 |
eatCursorLeftOrRight := completeImmediate not |
2234 |
or:[ editView sensor shiftDown |
|
2235 |
or:[ editView sensor ctrlDown ]]. |
|
4726 | 2236 |
(key == #CursorDown |
2237 |
or:[ (key == #CursorUp) |
|
4741 | 2238 |
or:[ ((key == #CursorLeft) and:[eatCursorLeftOrRight]) |
2239 |
or:[ ((key == #CursorRight) and:[eatCursorLeftOrRight]) |
|
4726 | 2240 |
or:[ ((key == #Return) and:[ completionView hasSelection ]) |
4735 | 2241 |
]]]]) ifTrue:[ |
4737 | 2242 |
"/ only with shift - normal user typing should not interfere with completion |
2243 |
true "editView sensor shiftDown" ifTrue:[ |
|
2244 |
"/ forward to completion view |
|
2245 |
completionView sensor pushUserEvent:#value for:[ completionView keyPress:key x:0 y:0 ]. |
|
2246 |
^ true. |
|
2247 |
]. |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2248 |
]. |
4737 | 2249 |
|
4717 | 2250 |
(key == #Control_L or:[ key == #Control_R or:[ key == #Control]]) ifTrue:[ |
4729 | 2251 |
"/ CTRL is a toggle |
4737 | 2252 |
self closeCompletionView. |
4729 | 2253 |
^ true. |
2254 |
"/ ^ false |
|
4717 | 2255 |
]. |
2256 |
(key == #Escape) ifTrue:[ |
|
4714 | 2257 |
self closeCompletionView. |
4717 | 2258 |
^ true "/ EAT |
4714 | 2259 |
]. |
4735 | 2260 |
"/ shift does not close |
2261 |
(key == #Shift_L or:[ key == #Shift_R or:[ key == #Shift]]) ifTrue:[ |
|
2262 |
^ false "/ don' eat |
|
2263 |
]. |
|
2264 |
||
4717 | 2265 |
self closeCompletionView. |
2266 |
^ false "/ don' eat |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2267 |
]. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2268 |
]. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2269 |
^ false. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2270 |
! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2271 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2272 |
postKeyPress:key |
4729 | 2273 |
UserPreferences current immediateCodeCompletion ifFalse:[ |
2274 |
"/ only update, if already open |
|
2275 |
completionView isNil ifTrue:[^ self]. |
|
2276 |
]. |
|
2277 |
||
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2278 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
4737 | 2279 |
autoSelect := false. |
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2280 |
self updateCompletionList. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2281 |
^ self |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2282 |
]. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2283 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2284 |
key isCharacter ifTrue:[ |
4714 | 2285 |
key isSeparator ifTrue:[ |
2286 |
self closeCompletionView |
|
2287 |
] ifFalse:[ |
|
4737 | 2288 |
autoSelect := false. |
4703 | 2289 |
self updateCompletionList. |
4714 | 2290 |
]. |
2291 |
^ self |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2292 |
]. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2293 |
! ! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2294 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2295 |
!Workspace::CodeCompletionService methodsFor:'private'! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2296 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2297 |
closeCompletionView |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2298 |
|v| |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2299 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2300 |
(v := completionView) notNil ifTrue:[ |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2301 |
completionView := nil. |
4703 | 2302 |
"/ let it close itself - avoids synchronization problems |
2303 |
v sensor |
|
2304 |
pushUserEvent:#value |
|
2305 |
for:[ v topView destroy ] |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2306 |
]. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2307 |
! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2308 |
|
4714 | 2309 |
release |
2310 |
self stopCompletionProcess. |
|
2311 |
self closeCompletionView. |
|
2312 |
super release |
|
2313 |
! |
|
2314 |
||
4703 | 2315 |
startCompletionProcess |
4729 | 2316 |
"start the code completion process in the background" |
4703 | 2317 |
|
4733 | 2318 |
|movePos topView initialList cursorX cursorY| |
4703 | 2319 |
|
2320 |
"/ terminate any previous process |
|
2321 |
self stopCompletionProcess. |
|
4698 | 2322 |
|
2323 |
(editView sensor hasKeyPressEventFor:nil) ifTrue:[ |
|
2324 |
self closeCompletionView. |
|
2325 |
^ self |
|
2326 |
]. |
|
4733 | 2327 |
((cursorX := editView xOfCursor) isNil |
2328 |
or:[ (cursorY := editView yOfCursor) isNil ]) ifTrue:[ |
|
2329 |
"/ no cursor - user is selecting, or cursor has been scrolled out of sight. |
|
2330 |
self closeCompletionView. |
|
2331 |
^ self |
|
2332 |
]. |
|
4698 | 2333 |
|
4709 | 2334 |
initialList := #( 'busy...' ). |
4706 | 2335 |
|
4703 | 2336 |
"/ move the window |
4733 | 2337 |
movePos := editView device translatePoint:(cursorX @ cursorY) fromView:editView toView:nil. |
4761 | 2338 |
movePos := movePos - (editView viewOrigin x @ 0). |
4714 | 2339 |
"/ currently, we have to stay away a bit, to avoid getting the focus |
2340 |
movePos := movePos + (60 @ (editView font height)). |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2341 |
|
4698 | 2342 |
completionView isNil ifTrue:[ |
4727 | 2343 |
completionView := CodeCompletionHelpMenuView new. |
2344 |
completionView name:'completion'. |
|
4703 | 2345 |
completionView level:0. |
4706 | 2346 |
completionView list:initialList. |
2347 |
completionView enable:false. |
|
4703 | 2348 |
completionView extent:completionView preferredExtentForContents. |
4698 | 2349 |
topView := CodeCompletionHelpView with:completionView. |
4703 | 2350 |
topView origin:movePos. |
2351 |
topView resizeToFit. |
|
4709 | 2352 |
"/ topView open. |
4703 | 2353 |
] ifFalse:[ |
4706 | 2354 |
completionView list:initialList. |
4703 | 2355 |
topView := completionView topView. |
4714 | 2356 |
topView ~~ completionView ifTrue:[ |
2357 |
topView origin:movePos. |
|
2358 |
topView resizeToFit. |
|
2359 |
] |
|
4698 | 2360 |
]. |
2361 |
||
4703 | 2362 |
completionProcess := |
2363 |
[ |
|
4754 | 2364 |
|suggestions implementations actions anyFound| |
4703 | 2365 |
|
2366 |
UserInformation ignoreIn:[ |
|
2367 |
anyFound := false. |
|
2368 |
DoWhatIMeanSupport |
|
2369 |
codeCompletionForMethod:editView editedMethod |
|
2370 |
orClass:editView editedClass |
|
2371 |
context:nil |
|
2372 |
codeView:editView |
|
4705 | 2373 |
into:[:listOfSuggestions :listOfActions :titleWhenAsking | |
4756 | 2374 |
"/ (listOfSuggestions contains:[:l | l isEmptyOrNil]) ifTrue:[self halt]. |
4754 | 2375 |
suggestions := listOfSuggestions collect:[:entry | entry isArray ifTrue:[entry first] ifFalse:[entry]]. |
2376 |
implementations := listOfSuggestions collect:[:entry | entry isArray ifTrue:[entry second] ifFalse:[nil]]. |
|
4703 | 2377 |
actions := listOfActions. |
2378 |
anyFound := true. |
|
2379 |
nil "/ must return nil to avoid DWIM to do it itself (for now) |
|
2380 |
] |
|
4698 | 2381 |
]. |
4703 | 2382 |
"/ anyFound ifFalse:[self halt]. |
2383 |
"/ Transcript show:'suggestions: '; showCR:suggestions. |
|
2384 |
"/ Transcript show:'actions: '; showCR:actions. |
|
2385 |
editView sensor |
|
4754 | 2386 |
pushUserEvent:#'suggestionsArrived:implementations:actions:autoSelect:' |
4703 | 2387 |
for:self |
4754 | 2388 |
withArguments:{suggestions . implementations . actions . autoSelect } |
4703 | 2389 |
] forkAt:(Processor activePriority - 1). |
2390 |
! |
|
2391 |
||
2392 |
stopCompletionProcess |
|
2393 |
"kill any background completion process" |
|
2394 |
||
2395 |
|p| |
|
2396 |
||
2397 |
(p := completionProcess) notNil ifTrue:[ |
|
2398 |
completionProcess := nil. |
|
2399 |
p terminate. |
|
2400 |
]. |
|
2401 |
! |
|
2402 |
||
4754 | 2403 |
suggestionsArrived:suggestionsArg implementations:implementationsArg actions:actionsArg autoSelect:autoSelectArg |
4735 | 2404 |
"the background process has generated some suggestions" |
2405 |
||
4754 | 2406 |
|v suggestions implementations actions suggestionOffset keyAndSnippet indexOfSnippet| |
4703 | 2407 |
|
2408 |
(editView sensor hasKeyPressEventFor:nil) ifTrue:[ |
|
2409 |
self closeCompletionView. |
|
2410 |
^ self |
|
2411 |
]. |
|
4706 | 2412 |
|
4754 | 2413 |
implementations := implementationsArg. |
2414 |
actions := actionsArg. |
|
2415 |
||
2416 |
suggestions := suggestionsArg ? #(). |
|
2417 |
suggestions size > 20 ifTrue:[ |
|
2418 |
suggestions := suggestions copyTo:20. |
|
2419 |
implementations := implementations copyTo:20. |
|
2420 |
actions isArray ifTrue:[ actions := actions copyTo:20 ]. |
|
2421 |
]. |
|
4706 | 2422 |
|
4744 | 2423 |
"/ append snipplet, if any (can be easily reached via CRSR-up) |
4706 | 2424 |
suggestionOffset := 0. |
4745 | 2425 |
indexOfSnippet := nil. |
2426 |
(keyAndSnippet := editView findAbbreviationKeyBeforeCursor) notNil ifTrue:[ |
|
4714 | 2427 |
|abbrev sniplet i line| |
4706 | 2428 |
|
4745 | 2429 |
abbrev := keyAndSnippet first. |
2430 |
sniplet := keyAndSnippet second. |
|
4714 | 2431 |
|
2432 |
"/ if the abbreviation is simply at the end of a longer word, ignore the abbrev. |
|
2433 |
line := editView lineStringBeforeCursor. |
|
2434 |
i := line findLast:[:ch | ch isLetterOrDigit not]. |
|
2435 |
(i < (line size - abbrev size - 1)) ifFalse:[ |
|
2436 |
sniplet := sniplet copyWithout:$!!. |
|
2437 |
||
2438 |
"/ true, false and self are often found in both lists |
|
4754 | 2439 |
(suggestions includes:sniplet) ifFalse:[ |
2440 |
suggestions isEmpty ifFalse:[ suggestions := suggestions copyWith: '-' ]. |
|
2441 |
suggestions := suggestions copyWith: ( '%1 %2' |
|
4714 | 2442 |
bindWith:(sniplet asStringCollection first "contractTo:25") |
4745 | 2443 |
with: ( ('("',abbrev,'" snippet)') colorizeAllWith:Color grey)). |
4754 | 2444 |
indexOfSnippet := suggestions size. |
4714 | 2445 |
|
2446 |
"/ change below, when reversing the order in above code |
|
2447 |
"/ suggestionOffset := 2. |
|
2448 |
] |
|
4706 | 2449 |
] |
2450 |
]. |
|
4754 | 2451 |
suggestions isEmptyOrNil ifTrue:[ |
4703 | 2452 |
self closeCompletionView. |
2453 |
^ self |
|
2454 |
]. |
|
2455 |
(v := completionView) isNil ifTrue: [ |
|
2456 |
^ self |
|
2457 |
]. |
|
4709 | 2458 |
v topView open. |
2459 |
||
4703 | 2460 |
v sensor |
2461 |
pushUserEvent:#value |
|
2462 |
for:[ |
|
4735 | 2463 |
|top idx preselectIdx| |
4706 | 2464 |
|
4704 | 2465 |
(v == completionView) ifTrue: [ |
4706 | 2466 |
top := v topView. |
2467 |
||
4735 | 2468 |
LastCompletions notNil ifTrue:[ |
2469 |
"/ one of the last completions in list? |
|
4754 | 2470 |
idx := LastCompletions findFirst:[:compl | suggestions includes:compl]. |
4735 | 2471 |
idx ~~ 0 ifTrue:[ |
4754 | 2472 |
preselectIdx := suggestions indexOf:(LastCompletions at:idx). |
4735 | 2473 |
]. |
2474 |
]. |
|
4737 | 2475 |
autoSelectArg ifTrue:[ |
4754 | 2476 |
(preselectIdx isNil and:[suggestions size == 1]) ifTrue:[ |
4737 | 2477 |
preselectIdx := 1. |
2478 |
]. |
|
4735 | 2479 |
]. |
4760 | 2480 |
preselectIdx notNil ifTrue:[ |
2481 |
|pref| |
|
2482 |
||
2483 |
pref := suggestions at:preselectIdx. |
|
2484 |
"/ for now, do not move to fron (action may need the index) |
|
2485 |
suggestions at:preselectIdx put:(pref allBold). |
|
2486 |
"/ suggestions removeAtIndex:preselectIdx. |
|
2487 |
"/ suggestions addFirst:(pref allBold). |
|
2488 |
"/ implementations notNil ifTrue:[ |
|
2489 |
"/ implementations removeAtIndex:preselectIdx. |
|
2490 |
"/ implementations addFirst:implementations. |
|
2491 |
"/ ] |
|
2492 |
]. |
|
2493 |
||
2494 |
v list:suggestions |
|
2495 |
expandTabs:false scanForNonStrings:false |
|
2496 |
includesNonStrings:false redraw:true. |
|
2497 |
||
4754 | 2498 |
implementations notNil ifTrue:[ |
2499 |
implementations keysAndValuesDo:[:idx :impls | |
|
2500 |
|implsMenu| |
|
2501 |
||
2502 |
impls notEmptyOrNil ifTrue:[ |
|
2503 |
implsMenu := Menu new. |
|
2504 |
impls do:[:each | |
|
2505 |
implsMenu addItem:(MenuItem new label:each name). |
|
2506 |
]. |
|
2507 |
v subMenuAt:idx put:implsMenu |
|
2508 |
]. |
|
2509 |
]. |
|
2510 |
]. |
|
2511 |
||
4706 | 2512 |
v enable:true. |
4735 | 2513 |
preselectIdx notNil ifTrue:[ |
4760 | 2514 |
false ifTrue:[ |
2515 |
"/ very disturbing!! |
|
2516 |
v selection:preselectIdx. |
|
2517 |
]. |
|
4735 | 2518 |
]. |
4704 | 2519 |
v extent:completionView preferredExtentForContents. |
2520 |
||
2521 |
v action: |
|
4706 | 2522 |
[:selectedListIndex | |
2523 |
|indexInSuggestions| |
|
2524 |
||
4714 | 2525 |
self closeCompletionView. |
4706 | 2526 |
indexInSuggestions := selectedListIndex - suggestionOffset. |
4745 | 2527 |
(selectedListIndex == indexOfSnippet) ifTrue:[ |
4706 | 2528 |
"/ replace the sniplet |
4714 | 2529 |
editView sensor |
2530 |
pushUserEvent:#value |
|
2531 |
for:[ |
|
2532 |
editView expandAbbreviation |
|
2533 |
] |
|
4706 | 2534 |
] ifFalse:[ |
4735 | 2535 |
LastCompletions isNil ifTrue:[ |
2536 |
LastCompletions := OrderedCollection new. |
|
2537 |
]. |
|
2538 |
LastCompletions add:(suggestions at:indexInSuggestions). |
|
4736 | 2539 |
LastCompletions size > 200 ifTrue:[ |
2540 |
LastCompletions removeLast |
|
2541 |
]. |
|
4735 | 2542 |
|
4706 | 2543 |
actions notNil ifTrue:[ |
2544 |
actions isBlock ifTrue:[ |
|
2545 |
actions value:indexInSuggestions |
|
2546 |
] ifFalse:[ |
|
2547 |
(actions at:indexInSuggestions) value |
|
2548 |
]. |
|
4704 | 2549 |
]. |
2550 |
]. |
|
4735 | 2551 |
"/ no, user has made his choice; so don't show more suggestions |
4717 | 2552 |
"/ editView sensor |
2553 |
"/ pushUserEvent:#value |
|
2554 |
"/ for:[ |
|
2555 |
"/ self updateCompletionList |
|
2556 |
"/ ] |
|
4703 | 2557 |
]. |
4704 | 2558 |
|
4706 | 2559 |
(top ~~ v) ifTrue:[ |
2560 |
top resizeToFit. |
|
2561 |
top bottom > v device usableHeight ifTrue:[ |
|
2562 |
top origin:((top origin x) @ (v device usableHeight - v height)). |
|
2563 |
]. |
|
2564 |
top raise. |
|
4704 | 2565 |
] |
2566 |
] |
|
4703 | 2567 |
] |
2568 |
! |
|
2569 |
||
2570 |
updateCompletionList |
|
2571 |
"called for keypress events" |
|
2572 |
||
2573 |
self startCompletionProcess. |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2574 |
! ! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2575 |
|
206 | 2576 |
!Workspace class methodsFor:'documentation'! |
2577 |
||
4402 | 2578 |
version |
4762 | 2579 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.303 2013-09-10 19:49:18 ab Exp $' |
4402 | 2580 |
! |
2581 |
||
3959 | 2582 |
version_CVS |
4762 | 2583 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.303 2013-09-10 19:49:18 ab Exp $' |
858 | 2584 |
! ! |
4504 | 2585 |