author | Claus Gittinger <cg@exept.de> |
Tue, 03 Sep 2013 21:27:51 +0200 | |
changeset 4733 | d623925e0257 |
parent 4729 | 450cb0dcedd2 |
child 4735 | 415403266a32 |
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 |
4703 | 29 |
instanceVariableNames:'completionView completionProcess editView state seqNr' |
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
30 |
classVariableNames:'' |
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 |
3807 | 141 |
"default sniplets/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). |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
895 |
]. |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
896 |
"/ box := YesNoBox |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
897 |
"/ title:aString |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
898 |
"/ yesText:(resources string:'Continue') |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
899 |
"/ noText:(resources string:'Abort'). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
900 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
901 |
"/ box label:lbl. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
902 |
"/ box image:(WarningBox iconBitmap). |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
903 |
"/ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
904 |
"/ (aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
905 |
"/ doNotShowAgainHolder := false asValue. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
906 |
"/ 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
|
907 |
"/ ]. |
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 |
"/ "/ answer := box confirm. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
910 |
"/ answer := box confirm. |
3007 | 911 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
912 |
doNotShowAgainHolder value == true ifTrue:[ |
4125
eeed55ffc143
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4103
diff
changeset
|
913 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
914 |
]. |
4386 | 915 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
916 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
917 |
]. |
|
3007 | 918 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
919 |
"/ box destroy. |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
920 |
]. |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
921 |
|
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
922 |
answer == #keepSelected ifTrue:[ |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
923 |
self hideCursor. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
924 |
"redraw selection in normal color" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
925 |
self invalidate. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
926 |
AbortOperationRequest raise. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
927 |
]. |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
928 |
|
201 | 929 |
" |
930 |
do the abort if we have to |
|
931 |
" |
|
3397 | 932 |
answer ifFalse:[ |
4274
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
933 |
"redraw selection in normal color" |
2114434f990d
comment/format in: #error:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4273
diff
changeset
|
934 |
self invalidate. |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
935 |
AbortOperationRequest raise. |
201 | 936 |
]. |
937 |
^ 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
|
938 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
939 |
"Created: / 24-11-1995 / 22:56:34 / cg" |
4398 | 940 |
"Modified: / 08-03-2012 / 10:24:21 / cg" |
201 | 941 |
! |
942 |
||
2663 | 943 |
highlightingErrorLine:lineNr do:aBlock |
944 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
945 |
||
946 |
|linePosition| |
|
947 |
||
948 |
linePosition := self characterPositionOfLine:lineNr col:1. |
|
949 |
self highlightingErrorPosition:linePosition to:nil do:aBlock |
|
950 |
! |
|
951 |
||
59 | 952 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
953 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 954 |
|
3007 | 955 |
self |
956 |
highlightingErrorPosition:relPos to:relEndPos |
|
957 |
withForeground:(self errorForegroundColor) andBackground:(self errorBackgroundColor) |
|
958 |
do:aBlock |
|
959 |
! |
|
960 |
||
961 |
highlightingErrorPosition:relPos to:relEndPos withForeground:hilightFg andBackground:hilightBg do:aBlock |
|
962 |
"evaluate aBlock while some selection is shown highlighted with colors passed as args." |
|
963 |
||
964 |
|absPosition oldFg oldBg| |
|
0 | 965 |
|
58 | 966 |
" |
967 |
change color of selection & hide cursor |
|
968 |
" |
|
3007 | 969 |
oldFg := selectionFgColor. |
970 |
oldBg := selectionBgColor. |
|
971 |
selectionBgColor := hilightBg. |
|
972 |
selectionFgColor := hilightFg. |
|
58 | 973 |
self hideCursor. |
0 | 974 |
|
58 | 975 |
" |
976 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
977 |
we have to adjust the positions given by the compiler, since they |
|
978 |
are relative to the texts start (the compiler did stream-read the code). |
|
979 |
" |
|
0 | 980 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
3427 | 981 |
absPosition := codeStartPosition + (relPos ? 1) - 1. |
0 | 982 |
relEndPos isNil ifTrue:[ |
4141
06c97cc2bf6d
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
983 |
self selectFromCharacterPosition:absPosition. |
06c97cc2bf6d
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
984 |
"/ self selectLineWhereCharacterPosition:absPosition. |
0 | 985 |
] ifFalse:[ |
3427 | 986 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + (relEndPos ? 1) - 1) |
0 | 987 |
]. |
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
988 |
expandingTop := true. "/ hack to make the top of the selection visible |
0 | 989 |
self makeSelectionVisible. |
990 |
||
155 | 991 |
device flush. |
58 | 992 |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
993 |
aBlock ensure:[ |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
994 |
" |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
995 |
undo selection color change and show cursor again |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
996 |
" |
3007 | 997 |
selectionFgColor := oldFg. |
998 |
selectionBgColor := oldBg. |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
999 |
self showCursor. |
0 | 1000 |
]. |
3427 | 1001 |
|
4273
4e9e823f9e41
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4252
diff
changeset
|
1002 |
"Modified: / 30-06-2011 / 17:24:04 / cg" |
0 | 1003 |
! |
1004 |
||
3007 | 1005 |
highlightingWarningPosition:relPos to:relEndPos do:aBlock |
1006 |
"evaluate aBlock while some selection is shown highlighted with warning colors." |
|
1007 |
||
1008 |
self |
|
1009 |
highlightingErrorPosition:relPos to:relEndPos |
|
1010 |
withForeground:(self warningForegroundColor) andBackground:(self warningBackgroundColor) |
|
1011 |
do:aBlock |
|
1012 |
! |
|
1013 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1014 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1015 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1016 |
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
|
1017 |
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
|
1018 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1019 |
|
4386 | 1020 |
|action doNotShowAgainHolder doNotShowAgainForThisMethodHolder| |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1021 |
|
3007 | 1022 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1023 |
doNotShowAgainHolder := false asValue. |
4386 | 1024 |
doNotShowAgainForThisMethodHolder := false asValue. |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1025 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
4386 | 1026 |
|box makeSpace| |
1027 |
||
1028 |
box := ex box. |
|
1029 |
aCompiler notNil ifTrue:[ |
|
1030 |
makeSpace := [ box addVerticalSpace:10. makeSpace := nil ]. |
|
1031 |
DoNotShowCompilerWarningAgainActionQuery isHandled ifTrue:[ |
|
1032 |
makeSpace value. |
|
1033 |
box verticalPanel |
|
1034 |
add:(CheckBox |
|
1035 |
label: "addCheckBoxAtBottom:" 'Do not show this dialog again (reenable via Launcher''s settings dialog)' |
|
1036 |
model:doNotShowAgainHolder). |
|
1037 |
]. |
|
1038 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery isHandled ifTrue:[ |
|
1039 |
makeSpace value. |
|
1040 |
box verticalPanel |
|
1041 |
add:(CheckBox |
|
4398 | 1042 |
label:(resources string:'Do not warn in this method (for %1 - reenable earlier via Launcher''s settings dialog)' with:ParserFlags perMethodDisableWarningTimeDuration) |
4386 | 1043 |
model:doNotShowAgainForThisMethodHolder). |
1044 |
]. |
|
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1045 |
]. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1046 |
] do:[ |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1047 |
action := OptionBox |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1048 |
request:aString |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
1049 |
label:(resources string:'Warning') |
2990
1373f301a694
dont send obsolete message to OptionBox
Claus Gittinger <cg@exept.de>
parents:
2983
diff
changeset
|
1050 |
image:(WarningBox iconBitmap) |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
1051 |
buttonLabels:(resources array:#('Cancel' 'Remove Variable(s)' 'Continue')) |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
1052 |
values:#(#abort #correct #continue) |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1053 |
default:#continue. |
4679 | 1054 |
action isNil ifTrue:[ action := #abort]. |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1055 |
]. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1056 |
doNotShowAgainHolder value == true ifTrue:[ |
4386 | 1057 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
1058 |
]. |
|
1059 |
doNotShowAgainForThisMethodHolder value == true ifTrue:[ |
|
1060 |
DoNotShowCompilerWarningAgainForThisMethodActionQuery actionQuery value |
|
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
1061 |
]. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1062 |
]. |
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 |
action == #abort ifTrue:[ |
4703 | 1065 |
"/ self halt. |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
1066 |
AbortOperationRequest raise. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1067 |
^ false |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1068 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1069 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
1070 |
|
4398 | 1071 |
"Modified: / 08-03-2012 / 10:23:58 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1072 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
1073 |
|
116 | 1074 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 1075 |
"compiler notifies us of a warning - same behavior as error" |
0 | 1076 |
|
2277 | 1077 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 1078 |
! ! |
1079 |
||
3396 | 1080 |
!Workspace methodsFor:'drag & drop'! |
1081 |
||
1082 |
canDrop:aDropContext |
|
4090 | 1083 |
"if allowValueDrop is true, any text- or file-object can be dropped into workspace |
1084 |
(printString); otherwise, only ..." |
|
1085 |
||
1086 |
self isReadOnly ifTrue:[^ false]. |
|
3396 | 1087 |
|
4090 | 1088 |
allowValueDrop ifTrue:[^ true]. |
1089 |
^ super canDrop:aDropContext |
|
3428 | 1090 |
|
4090 | 1091 |
"/ ^ aDropContext dropObjects |
1092 |
"/ contains:[:someObject| (someObject isTextObject or:[ someObject isFileObject ])]. |
|
3396 | 1093 |
|
1094 |
"Created: / 16-08-2005 / 22:01:13 / janfrog" |
|
3428 | 1095 |
"Modified: / 28-11-2006 / 16:18:51 / cg" |
3396 | 1096 |
! |
1097 |
||
3414 | 1098 |
doDrop:aDropContext |
4631 | 1099 |
<resource: #obsolete> |
1100 |
self obsoleteMethodWarning:'should no longer be reached'. |
|
3428 | 1101 |
self drop:aDropContext |
3414 | 1102 |
|
3428 | 1103 |
"Modified: / 28-11-2006 / 16:14:51 / cg" |
4386 | 1104 |
"Modified (format): / 28-02-2012 / 11:20:38 / cg" |
3414 | 1105 |
! |
1106 |
||
1107 |
drop:aDropContext |
|
1108 |
"Any object can be dropped into workspace..." |
|
1109 |
||
3870 | 1110 |
|textObjects nonTextObjects answer text| |
1111 |
||
1112 |
textObjects := aDropContext dropObjects |
|
3887 | 1113 |
select:[:dropObject | dropObject isTextObject |
1114 |
or:[ dropObject isFileObject ]]. |
|
3870 | 1115 |
nonTextObjects := aDropContext dropObjects |
3887 | 1116 |
reject:[:dropObject | dropObject isTextObject |
1117 |
or:[ dropObject isFileObject ]]. |
|
3870 | 1118 |
|
1119 |
self dropObjects:textObjects. |
|
3414 | 1120 |
|
3870 | 1121 |
nonTextObjects notEmpty ifTrue:[ |
1122 |
answer := Dialog |
|
1123 |
confirmWithCancel:(resources |
|
1124 |
string:'Drop as textual representation or as object reference ?') |
|
1125 |
labels:(resources array:#('Cancel' 'Reference' 'Name' 'Text')) |
|
1126 |
values:#(nil #ref #name #text) |
|
1127 |
default:4. |
|
1128 |
answer isNil ifTrue:[^ self]. |
|
1129 |
(answer == #text or:[answer == #name]) ifTrue:[ |
|
1130 |
text := String streamContents:[:s | |
|
1131 |
nonTextObjects do:[:dropObject | |
|
1132 |
|obj| |
|
1133 |
||
1134 |
obj := dropObject theObject. |
|
1135 |
obj isMethod ifTrue:[ |
|
1136 |
s nextPutAll:(answer == #name ifTrue:[obj selector] ifFalse:[obj source]). |
|
1137 |
] ifFalse:[ |
|
1138 |
obj isClass ifTrue:[ |
|
1139 |
s nextPutAll:(answer == #name ifTrue:[obj name] ifFalse:[obj source asString]) |
|
1140 |
] ifFalse:[ |
|
1141 |
s nextPutAll:(answer == #name ifTrue:[obj className] ifFalse:[obj printString]) . |
|
1142 |
]. |
|
1143 |
]. |
|
1144 |
]. |
|
1145 |
]. |
|
1146 |
self paste:text. |
|
3414 | 1147 |
] ifFalse:[ |
3870 | 1148 |
nonTextObjects do:[:dropObject | |
1149 |
name := Dialog |
|
1150 |
request:(resources |
|
1151 |
string:'Name of the new Workspace Variable (refers to the dropped %1):' |
|
1152 |
with:dropObject theObject class name allBold |
|
1153 |
) |
|
1154 |
initialAnswer:'droppedObject' |
|
1155 |
okLabel:'Add' |
|
1156 |
title:'Enter Variable Name'. |
|
3414 | 1157 |
|
3870 | 1158 |
name notEmptyOrNil ifTrue:[ |
1159 |
Workspace addWorkspaceVariable:name. |
|
1160 |
(Workspace workspaceVariableAt:name) value:dropObject theObject. |
|
1161 |
self paste:name. |
|
1162 |
]. |
|
3414 | 1163 |
]. |
3870 | 1164 |
] |
3414 | 1165 |
]. |
1166 |
||
1167 |
"Created: / 13-10-2006 / 17:34:07 / cg" |
|
3396 | 1168 |
! ! |
1169 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1170 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1171 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1172 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1173 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1174 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1175 |
in the first col |
1176 |
(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
|
1177 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1178 |
|eolComment opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1179 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1180 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1181 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1182 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1183 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1184 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1185 |
]. |
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 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1188 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1189 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1190 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1191 |
l isNil ifTrue:[l := '']. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1192 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1193 |
l := eolComment , l |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1194 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1195 |
l := opening , l , closing |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1196 |
]. |
3403 | 1197 |
self replaceLine:lineNr with:l. |
1198 |
widthOfWidestLine notNil ifTrue:[ |
|
1199 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1200 |
]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1201 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1202 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1203 |
|
3403 | 1204 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
1205 |
"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
|
1206 |
! |
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 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1209 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1210 |
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
|
1211 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1212 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1213 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1214 |
|
1481 | 1215 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3210 | 1216 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
1217 |
||
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1218 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1219 |
self |
3785 | 1220 |
undoableDo:[ self commentFrom:cursorLine to:cursorLine ] |
3543 | 1221 |
info:'Comment'. |
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1222 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1223 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1224 |
|
3129 | 1225 |
self |
1226 |
undoableDo: |
|
1227 |
[ |
|
1228 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1229 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
|
1230 |
] ifFalse:[ |
|
3210 | 1231 |
commentPair := commentStrings at:2 ifAbsent:nil. |
1232 |
commentPair isNil ifTrue:[ |
|
1233 |
self beep. |
|
1234 |
] ifFalse:[ |
|
1235 |
opening := commentPair at:1. |
|
1236 |
closing := commentPair at:2. |
|
1237 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
3129 | 1238 |
|
3210 | 1239 |
e := selectionEndCol. |
1240 |
||
1241 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
1242 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
3129 | 1243 |
|
3210 | 1244 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
1245 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1246 |
toLine:selectionEndLine col:e+closing size. |
|
1247 |
] |
|
3129 | 1248 |
] |
1249 |
] |
|
1250 |
info:'comment' |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1251 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1252 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 1253 |
"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
|
1254 |
! |
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 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1257 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1258 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1259 |
in the first col. |
1260 |
(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
|
1261 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1262 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1263 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1264 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1265 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1266 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1267 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1268 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1269 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1270 |
rest := eolComment size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1271 |
]. |
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 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1274 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1275 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1276 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1277 |
l notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1278 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1279 |
(l startsWith:eolComment) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1280 |
l := l copyFrom:rest |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1281 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1282 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1283 |
((l startsWith:opening) |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1284 |
and:[l endsWith:closing]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1285 |
l := l copyFrom:opening size + 1. |
4568
cf9f6fd6d174
Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents:
4542
diff
changeset
|
1286 |
l := l copyButLast:closing size. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1287 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1288 |
]. |
3403 | 1289 |
self replaceLine:lineNr with:l. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1290 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1291 |
]. |
3403 | 1292 |
widthOfWidestLine := nil. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1293 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1294 |
|
3403 | 1295 |
"Created: / 09-11-1997 / 01:05:43 / cg" |
1296 |
"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
|
1297 |
! |
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 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1300 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1301 |
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
|
1302 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1303 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1304 |
|e commentPair opening closing sz1 sz2| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1305 |
|
3129 | 1306 |
(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
|
1307 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1308 |
self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1309 |
undoableDo:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1310 |
self uncommentFrom:cursorLine to:cursorLine |
3543 | 1311 |
] |
1312 |
info:'Uncomment'. |
|
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1313 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1314 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1315 |
|
3129 | 1316 |
self |
1317 |
undoableDo: |
|
1318 |
[ |
|
1319 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1320 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
|
1321 |
] ifFalse:[ |
|
1322 |
commentPair := commentStrings at:2. |
|
1323 |
opening := commentPair at:1. |
|
1324 |
closing := commentPair at:2. |
|
1325 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1326 |
||
1327 |
sz1 := opening size. |
|
1328 |
sz2 := closing size. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1329 |
|
3129 | 1330 |
((self |
1331 |
stringAtLine:selectionStartLine |
|
1332 |
from:selectionStartCol |
|
1333 |
to:selectionStartCol+sz1 - 1) = opening |
|
1334 |
and:[(self |
|
1335 |
stringAtLine:selectionEndLine |
|
1336 |
from:selectionEndCol - sz2 + 1 |
|
1337 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1338 |
|
3129 | 1339 |
self deleteCharsAtLine:selectionEndLine fromCol:selectionEndCol-sz2+1 toCol:selectionEndCol. |
1340 |
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
|
1341 |
|
3129 | 1342 |
e := selectionEndCol - sz2. |
1343 |
selectionStartLine == selectionEndLine ifTrue:[e := e - sz1]. |
|
1344 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1345 |
toLine:selectionEndLine col:e. |
|
1346 |
] |
|
1347 |
] |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1348 |
] |
3129 | 1349 |
info:'uncomment' |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1350 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1351 |
"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
|
1352 |
"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
|
1353 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1354 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1355 |
!Workspace methodsFor:'event handling'! |
3712 | 1356 |
|
0 | 1357 |
keyPress:key x:x y:y |
4587 | 1358 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #ReplaceIt |
1359 |
#BrowseIt #ImplementorsOfIt #ExpandAbbreviation |
|
1360 |
#CommentSelection #UncommentSelection)> |
|
60 | 1361 |
|
3800 | 1362 |
(key == #DoIt) ifTrue:[self doIt. ^ self]. |
1363 |
(key == #InspectIt) ifTrue:[self inspectIt. ^ self]. |
|
1364 |
(key == #PrintIt) ifTrue:[self printIt. ^ self]. |
|
1365 |
(key == #ReplaceIt) ifTrue:[self replaceIt. ^ self]. |
|
1366 |
(key == #BrowseIt) ifTrue:[self browseIt. ^ self]. |
|
1367 |
(key == #ImplementorsOfIt) ifTrue:[self browseImplementorsOfIt. ^ self]. |
|
1368 |
(key == #ExpandAbbreviation) ifTrue:[self expandAbbreviation. ^ self]. |
|
4587 | 1369 |
(key == #CommentSelection) ifTrue:[self commentSelection. ^ self]. |
1370 |
(key == #UncommentSelection) ifTrue:[self uncommentSelection. ^ self]. |
|
38 | 1371 |
|
0 | 1372 |
super keyPress:key x:x y:y |
3511 | 1373 |
|
1374 |
"Modified: / 08-11-2007 / 11:29:45 / cg" |
|
0 | 1375 |
! ! |
201 | 1376 |
|
2143 | 1377 |
!Workspace methodsFor:'executing'! |
201 | 1378 |
|
1501 | 1379 |
do:code withValueDo:aBlock |
418 | 1380 |
"helper for doIt, printIt and inspectIt. |
1381 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
1382 |
aBlock with the value. |
|
1383 |
Most work is in preparing for proper cleanup in case of abort |
|
1384 |
or other exception while the evaluation is performed. |
|
1385 |
(restore cursor, selectionColors etc.)" |
|
201 | 1386 |
|
4149 | 1387 |
|selLine selCol endLine endCol cLine cCol cleanUp executeBlock| |
201 | 1388 |
|
1389 |
code notNil ifTrue:[ |
|
2409 | 1390 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
2408 | 1391 |
|
257 | 1392 |
codeStartPosition := self characterPositionOfSelection. |
201 | 1393 |
|
257 | 1394 |
" |
1395 |
remember selection for later - if there is an error, |
|
1396 |
the notification method will highlight it. |
|
1397 |
thus destroying the current selection |
|
1398 |
" |
|
1399 |
selLine := selectionStartLine. |
|
1400 |
selCol := selectionStartCol. |
|
1401 |
endLine := selectionEndLine. |
|
1402 |
endCol := selectionEndCol. |
|
1403 |
cCol := cursorCol. |
|
1404 |
cLine := cursorLine. |
|
201 | 1405 |
|
257 | 1406 |
" |
1407 |
cleanup: restore previous selection and cursor positions |
|
1408 |
" |
|
1409 |
cleanUp := [ |
|
1410 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
1411 |
cLine notNil ifTrue:[ |
|
1412 |
self cursorLine:cLine col:cCol |
|
1413 |
]. |
|
1414 |
]. |
|
201 | 1415 |
|
257 | 1416 |
" |
1417 |
perform the action. |
|
1418 |
Be careful to release the reference to the value; |
|
1419 |
otherwise, we could keep lots of garbage from being freed |
|
1420 |
until the view gets closed |
|
1421 |
" |
|
4149 | 1422 |
executeBlock := [ |
1423 |
[ |
|
1424 |
AbortOperationRequest handle:[:ex | |
|
1425 |
"/ aBlock value:'** Abortsignal cought **'. |
|
1426 |
ex return |
|
1427 |
] do:[ |
|
1428 |
|value| |
|
929 | 1429 |
|
4149 | 1430 |
doItAction notNil ifTrue:[ |
1431 |
value := doItAction value:(code asString). |
|
1432 |
cleanUp value. cleanUp := nil. |
|
1433 |
aBlock notNil ifTrue:[ |
|
1434 |
aBlock value:value. |
|
1435 |
]. |
|
1436 |
value := nil. |
|
1437 |
self class rememberDoIt:code. |
|
1438 |
] |
|
257 | 1439 |
] |
4149 | 1440 |
] ensure:[ |
1441 |
cleanUp notNil ifTrue:[ |
|
1442 |
cleanUp value. cleanUp := nil |
|
1443 |
]. |
|
257 | 1444 |
] |
4149 | 1445 |
]. |
1446 |
aBlock isNil ifTrue:[ |
|
1447 |
"no action is performed with the result - give the user a visible |
|
1448 |
feedback, that something has been done" |
|
1449 |
self topView withVisibleCursor:Cursor execute do:executeBlock. |
|
1450 |
] ifFalse:[ |
|
1451 |
self topView withCursor:Cursor execute do:executeBlock. |
|
257 | 1452 |
]. |
201 | 1453 |
] |
257 | 1454 |
|
1501 | 1455 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
1456 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
2409 | 1457 |
"Modified: / 26.9.2001 / 17:32:59 / cg" |
4677 | 1458 |
! |
201 | 1459 |
|
2733 | 1460 |
executeDoIt:theCode |
4391 | 1461 |
"the core of doIt, printIt, inspectIt, browseIt actions" |
1462 |
||
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1463 |
| result compiler | |
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1464 |
|
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1465 |
"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
|
1466 |
[ |
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1467 |
result := ( compiler := (self compilerClass ? Compiler) new ) |
4438 | 1468 |
currentNameSpace:namespaceForDoits; |
4404
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1469 |
moreSharedPools:poolsConsideredInDoIts; |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1470 |
evaluate:theCode |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1471 |
in:nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1472 |
receiver:simulatedSelf |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1473 |
notifying:self |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1474 |
logged:true |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1475 |
ifFail:nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1476 |
] on: Parser undefinedVariableNotification do:[:ex| |
4618
d3554659540b
Fix for RegressionTests::Compiler2Tests>>test_03
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4617
diff
changeset
|
1477 |
(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
|
1478 |
ex proceedWith: #declare |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1479 |
] ifFalse:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1480 |
ex proceedWith: nil |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1481 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1482 |
] on: Parser askForVariableTypeOfUndeclaredQuery do:[:ex| |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1483 |
autoDefineVariables == #workspace ifTrue:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1484 |
ex proceedWith:#WorkspaceVariable |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1485 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1486 |
autoDefineVariables == #doIt ifTrue:[ |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1487 |
ex proceedWith:#DoItTemporary |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1488 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1489 |
ex pass. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1490 |
]. |
56ea0037fd42
#executeDoIt: changed to reflect value of autoDefineVariables
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4402
diff
changeset
|
1491 |
^result |
4391 | 1492 |
|
4438 | 1493 |
"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
|
1494 |
"Modified: / 24-06-2013 / 15:31:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4677 | 1495 |
! ! |
1496 |
||
1497 |
!Workspace methodsFor:'initialization & release'! |
|
2733 | 1498 |
|
201 | 1499 |
initStyle |
966 | 1500 |
"setup viewStyle specifics" |
1501 |
||
201 | 1502 |
super initStyle. |
1503 |
||
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1504 |
DefaultViewBackground notNil ifTrue:[ |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1505 |
viewBackground := DefaultViewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1506 |
self backgroundColor:viewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1507 |
]. |
201 | 1508 |
! |
1509 |
||
1510 |
initialize |
|
1511 |
super initialize. |
|
1512 |
||
4593 | 1513 |
autoIndent := UserPreferences current autoIndentInCodeView. |
2775 | 1514 |
scrollWhenUpdating := #beginOfText. |
201 | 1515 |
showMatchingParenthesis := true. |
3428 | 1516 |
allowValueDrop := true. |
1517 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1518 |
commentStrings := #( |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1519 |
'"/' |
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 |
). |
201 | 1522 |
|
1523 |
self initializeDoITAction. |
|
3396 | 1524 |
self initializeDragAndDrop. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1525 |
|
3428 | 1526 |
"Modified: / 28-11-2006 / 16:11:55 / cg" |
201 | 1527 |
! |
1528 |
||
1529 |
initializeDoITAction |
|
1530 |
"set up the block to be evaluated for doIts. |
|
1531 |
This is done here in a separate method to allow easier |
|
1532 |
redefinition in subclasses" |
|
1533 |
||
2733 | 1534 |
doItAction := [:theCode | self executeDoIt:theCode]. |
3396 | 1535 |
! |
1536 |
||
1537 |
initializeDragAndDrop |
|
1538 |
|target| |
|
1539 |
||
1540 |
target := DropTarget |
|
1541 |
receiver:self |
|
1542 |
argument:nil |
|
3411 | 1543 |
dropSelector:#drop: |
3396 | 1544 |
canDropSelector:#canDrop:. |
1545 |
self dropTarget:target |
|
1546 |
||
1547 |
"Created: / 16-08-2005 / 22:03:36 / janfrog" |
|
3411 | 1548 |
"Modified: / 13-10-2006 / 12:37:18 / cg" |
201 | 1549 |
! ! |
1550 |
||
418 | 1551 |
!Workspace methodsFor:'menu & menu actions'! |
1552 |
||
2285 | 1553 |
browseClass |
1554 |
"user selected 'browseClass' from menu; evaluate the code |
|
1555 |
and open a browser on the resulting class (if it evaluates to one)" |
|
1556 |
||
1557 |
^ self |
|
3272 | 1558 |
do:(self selectionAsString) |
3910 | 1559 |
withValueDo:[:result | |
1560 |
result isBehavior ifTrue:[ |
|
1561 |
result browserClass openInClass:result selector:nil |
|
1562 |
] ifFalse:[ |
|
1563 |
self warn:'Selection does not evaluate to a class' |
|
1564 |
] |
|
1565 |
]. |
|
2285 | 1566 |
|
2410 | 1567 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 1568 |
! |
1569 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1570 |
browseImplementorsOfIt |
4617 | 1571 |
"open a browser on the implementors of the selected text, |
1572 |
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
|
1573 |
|
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1574 |
|selectedText selector browserClass na| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1575 |
|
4617 | 1576 |
selectedText := self selectedTextOrSyntaxElement. |
1577 |
selectedText notEmptyOrNil ifTrue:[ |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1578 |
self windowGroup withWaitCursorDo:[ |
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1579 |
"/ 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
|
1580 |
(compilerClass notNil and:[compilerClass includesBehavior:JavaScriptParser]) ifTrue:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1581 |
"/ selector is in one piece anyway |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1582 |
(selectedText includes:$_) ifFalse:[ |
3896 | 1583 |
"/ 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
|
1584 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:1. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1585 |
selectedText := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:0. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1586 |
] ifTrue:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1587 |
"/ count _#s plus one arg - sigh |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1588 |
na := (selectedText occurrencesOf:$_) + 1. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1589 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:na |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1590 |
]. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1591 |
] ifFalse:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1592 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1593 |
]. |
4619 | 1594 |
browserClass := UserPreferences systemBrowserClass. |
2714 | 1595 |
|
3287 | 1596 |
(selector notNil and:[selector ~= selectedText]) ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1597 |
(SystemBrowser |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1598 |
findImplementorsOfAny:(Array with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1599 |
in:(Smalltalk allClasses) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1600 |
ignoreCase:false) isEmpty ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1601 |
browserClass browseImplementorsOf:selector |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1602 |
] ifFalse:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1603 |
browserClass browseImplementorsOfAny:(Set with:selector with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1604 |
]. |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1605 |
] ifFalse:[ |
2714 | 1606 |
browserClass browseImplementorsOf:(selector ? selectedText) |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1607 |
] |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1608 |
] |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1609 |
]. |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1610 |
|
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1611 |
"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
|
1612 |
"Modified: / 19.11.2001 / 22:15:17 / cg" |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1613 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1614 |
|
2307 | 1615 |
browseIt |
1616 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
2713 | 1617 |
or the class of the resulting object (if it does not evaluate to a class). |
1618 |
||
1619 |
Added feature: if selection is of the form class >> selector, immediately switch to that selector." |
|
1620 |
||
4617 | 1621 |
|codeToEvaluate el idx selector evaluatedValue classToBrowse gotResult| |
2713 | 1622 |
|
4617 | 1623 |
(self selection isEmptyOrNil |
1624 |
and:[ self supportsSyntaxElements |
|
1625 |
and:[ (el := self syntaxElementForVariableUnderCursor) notNil ]]) |
|
1626 |
ifTrue:[ |
|
1627 |
codeToEvaluate := el name |
|
1628 |
] ifFalse:[ |
|
1629 |
codeToEvaluate := (self selectionOrTextOfCursorLine ? '') withoutSeparators. |
|
1630 |
]. |
|
2713 | 1631 |
idx := codeToEvaluate indexOfSubCollection:'>>'. |
1632 |
idx ~~ 0 ifTrue:[ |
|
2717 | 1633 |
selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string. |
3155 | 1634 |
(selector startsWith:'#') ifTrue:[ |
1635 |
selector := Symbol readFrom:selector. |
|
1636 |
]. |
|
2713 | 1637 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
1638 |
]. |
|
2307 | 1639 |
|
3910 | 1640 |
Parser parseErrorSignal handle:[:ex | |
1641 |
|className| |
|
2410 | 1642 |
|
3910 | 1643 |
"/ fallback, if garbage is selected, look for matching classes. |
1644 |
className := SystemBrowser |
|
1645 |
askForClassNameMatching:codeToEvaluate |
|
1646 |
inEnvironment:nil |
|
1647 |
for:nil. |
|
4386 | 1648 |
|
3910 | 1649 |
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
|
1650 |
classToBrowse := Smalltalk classNamed:className. |
3910 | 1651 |
] do:[ |
4386 | 1652 |
gotResult := false. |
1653 |
||
3910 | 1654 |
self |
1655 |
do:codeToEvaluate |
|
4386 | 1656 |
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
|
1657 |
|
4386 | 1658 |
gotResult ifFalse:[^ self]. |
1659 |
||
1660 |
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
|
1661 |
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
|
1662 |
codeToEvaluate isUppercaseFirst ifTrue:[ |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1663 |
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
|
1664 |
^ self. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1665 |
]. |
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 |
classToBrowse := evaluatedValue isBehavior |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1669 |
ifTrue:[ evaluatedValue ] |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1670 |
ifFalse:[ evaluatedValue class ]. |
3910 | 1671 |
]. |
1672 |
||
1673 |
classToBrowse browserClass openInClass:classToBrowse selector:selector |
|
4386 | 1674 |
|
1675 |
"Modified: / 28-02-2012 / 11:23:06 / cg" |
|
2307 | 1676 |
! |
1677 |
||
2285 | 1678 |
browseItsClass |
1679 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
1680 |
and open a browser on the results class" |
|
1681 |
||
1682 |
^ self |
|
3272 | 1683 |
do:(self selectionAsString) |
2410 | 1684 |
withValueDo:[:result | |
1685 |
result class browserClass openInClass:result class selector:nil |
|
1686 |
] |
|
2285 | 1687 |
|
2410 | 1688 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 1689 |
! |
1690 |
||
2454 | 1691 |
browseReferencesToIt |
1692 |
"open a browser on all references to the selected global" |
|
1693 |
||
4675 | 1694 |
|nameOfGlobal| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1695 |
|
4675 | 1696 |
nameOfGlobal := self selectedTextOrSyntaxElement. |
1697 |
nameOfGlobal notEmptyOrNil ifTrue:[ |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1698 |
self windowGroup withWaitCursorDo:[ |
4675 | 1699 |
|cls privateClass| |
1700 |
||
1701 |
((cls := self editedClass) notNil |
|
1702 |
and:[ (cls theNonMetaclass allClassVarNames includes:nameOfGlobal) ]) ifTrue:[ |
|
1703 |
(UserPreferences systemBrowserClass) |
|
1704 |
browseRefsTo:nameOfGlobal |
|
1705 |
classVars:true |
|
1706 |
in:(cls whichClassDefinesClassVar:nameOfGlobal) withAllSubclasses |
|
1707 |
modificationsOnly:false. |
|
1708 |
] ifFalse:[ |
|
1709 |
(cls notNil |
|
1710 |
and:[ (privateClass := cls theNonMetaclass privateClassNamed:nameOfGlobal) notNil ]) ifTrue:[ |
|
1711 |
(UserPreferences systemBrowserClass) |
|
1712 |
browseReferendsOf:(privateClass name) |
|
1713 |
] ifFalse:[ |
|
1714 |
(UserPreferences systemBrowserClass) browseReferendsOf:nameOfGlobal |
|
1715 |
] |
|
1716 |
] |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1717 |
]. |
2454 | 1718 |
]. |
1719 |
||
1720 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
1721 |
"Modified: / 5.11.2001 / 17:32:38 / cg" |
|
1722 |
! |
|
1723 |
||
2462 | 1724 |
browseSendersOfIt |
1725 |
"open a browser on the senders of the selected text" |
|
1726 |
||
2715 | 1727 |
|selectedText selector| |
2462 | 1728 |
|
4617 | 1729 |
selectedText := self selectedTextOrSyntaxElement. |
1730 |
selectedText notEmptyOrNil ifTrue:[ |
|
2462 | 1731 |
self windowGroup withWaitCursorDo:[ |
3287 | 1732 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
4619 | 1733 |
(UserPreferences systemBrowserClass) |
2715 | 1734 |
browseAllCallsOn:(selector ? selectedText) |
2462 | 1735 |
] |
1736 |
]. |
|
1737 |
||
1738 |
"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
|
1739 |
"Modified: / 19.11.2001 / 22:15:27 / cg" |
2462 | 1740 |
! |
1741 |
||
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1742 |
browseSharedPoolOfIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1743 |
"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
|
1744 |
|
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1745 |
|sel| |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1746 |
|
4617 | 1747 |
sel := self selectedTextOrSyntaxElement. |
1748 |
sel notEmptyOrNil ifTrue:[ |
|
1749 |
sel := sel asSymbol. |
|
1750 |
self windowGroup withWaitCursorDo:[ |
|
1751 |
SharedPool allSubclassesDo:[:eachPool | |
|
1752 |
(eachPool includesKey:sel) ifTrue:[ |
|
4619 | 1753 |
(UserPreferences systemBrowserClass) |
4617 | 1754 |
openInClass:eachPool class selector:#initialize |
1755 |
]. |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1756 |
]. |
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 |
"Created: / 15-01-2011 / 14:01:39 / cg" |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1761 |
! |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1762 |
|
418 | 1763 |
doIt |
1764 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
1765 |
and finally restore cursor; return result of evaluation" |
|
1766 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1767 |
^ self |
3272 | 1768 |
do:(self selectionOrTextOfCursorLine) |
4149 | 1769 |
withValueDo:nil |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1770 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1771 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 1772 |
! |
1773 |
||
1774 |
editMenu |
|
1107 | 1775 |
"return my popUpMenu; thats the superclasses menu |
1776 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
|
1777 |
||
2459 | 1778 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
1779 |
#CommentSelection #UncommentSelection |
|
2573
52c995a1ea78
accelerators for browseIt and implementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
2571
diff
changeset
|
1780 |
#BrowseIt #ImplementorsOfIt |
2459 | 1781 |
)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
1782 |
<resource: #programMenu> |
489 | 1783 |
|
2867 | 1784 |
|m sub subsub idx sensor s s2| |
418 | 1785 |
|
1786 |
m := super editMenu. |
|
3252 | 1787 |
((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
2459 | 1788 |
sub := m. |
1789 |
m := nil. |
|
1790 |
] ifFalse:[ |
|
1791 |
sub := m subMenuAt:#others. |
|
1792 |
]. |
|
418 | 1793 |
|
2459 | 1794 |
sub notNil ifTrue:[ |
2867 | 1795 |
|
2459 | 1796 |
" |
2867 | 1797 |
workspaces support #browse, implementors etc. add them after paste. |
2459 | 1798 |
" |
2867 | 1799 |
sub |
1800 |
addItemList:#( |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1801 |
('-' ) |
3910 | 1802 |
('Browse' browseIt BrowseIt ) |
4617 | 1803 |
('Browse Pool' browseSharedPoolOfIt ) |
3910 | 1804 |
('Senders of It' browseSendersOfIt ) |
1805 |
('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
|
1806 |
('References to It' browseReferencesToIt ) |
|
1807 |
"/ ('Classes Containing It in Name' browseClassesContainingItInName ) |
|
1808 |
"/ ('Methods Contaníning It in Name' browseMethodsContainingItInName ) |
|
1809 |
"/ ('Methods Contaníning It in Source' browseMethodsContainingItInSource ) |
|
2867 | 1810 |
('-' ) |
1811 |
('TimeIt' timeIt ) |
|
1812 |
('SpyOnIt' spyOnIt )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1813 |
resources:resources |
2459 | 1814 |
after:#gotoLine. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1815 |
|
2867 | 1816 |
subsub := sub subMenuAt:#tools. |
1817 |
subsub notNil ifTrue:[ |
|
1818 |
subsub |
|
1819 |
addItemList:#( |
|
1820 |
('-' ) |
|
1821 |
('Comment' commentSelection CommentSelection ) |
|
1822 |
('Uncomment' uncommentSelection UncommentSelection )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1823 |
resources:resources |
2867 | 1824 |
after:#'indent'. |
1825 |
]. |
|
1826 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1827 |
self hasSelection ifFalse:[ |
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1828 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1829 |
browseReferencesToIt timeIt spyOnIt |
4617 | 1830 |
browseSharedPoolOfIt browseIt). |
1831 |
self supportsSyntaxElements ifTrue:[ |
|
1832 |
self syntaxElementForSelectorUnderCursor notNil ifTrue:[ |
|
1833 |
sub enableAll:#(browseImplementorsOfIt browseSendersOfIt ) |
|
1834 |
] ifFalse:[ |
|
1835 |
|el| |
|
1836 |
||
1837 |
(el := self syntaxElementForVariableUnderCursor) notNil ifTrue:[ |
|
1838 |
el isGlobal ifTrue:[ |
|
1839 |
sub enable: #browseReferencesToIt |
|
1840 |
]. |
|
1841 |
el isClass ifTrue:[ |
|
1842 |
sub enable:#browseIt |
|
1843 |
] |
|
1844 |
] |
|
1845 |
] |
|
1846 |
]. |
|
2454 | 1847 |
] ifTrue:[ |
1848 |
s := self selectionAsString. |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1849 |
s notNil ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1850 |
s asSymbolIfInterned isNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1851 |
s2 := SystemBrowser extractSelectorFrom:s. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1852 |
s2 notNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1853 |
s2 := s2 asSymbolIfInterned. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1854 |
]. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1855 |
]. |
2454 | 1856 |
]. |
2487
47e0a1faf544
disabling of impl/senders menu
Claus Gittinger <cg@exept.de>
parents:
2485
diff
changeset
|
1857 |
(s2 isNil and:[s isNil]) ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1858 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1859 |
]. |
3959 | 1860 |
"/ a global or namespace-var selected ? |
4459 | 1861 |
s isNil ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1862 |
sub disable:#browseReferencesToIt. |
4459 | 1863 |
] ifFalse:[ |
1864 |
(s asSymbolIfInterned notNil |
|
1865 |
and:[ (Smalltalk includesKey:s asSymbol) |
|
4617 | 1866 |
or:[ (NameSpace allNameSpaces contains:[:ns | ns includesKey:s asSymbol]) ]] |
1867 |
) ifTrue:[ |
|
1868 |
"/ a global or namespace var selected |
|
4459 | 1869 |
] ifFalse:[ |
4675 | 1870 |
|cls| |
1871 |
||
1872 |
((cls := self editedClass) notNil |
|
1873 |
and:[ (cls theNonMetaclass allClassVarNames includes:s) |
|
1874 |
or:[ (cls theNonMetaclass privateClassNamed:s) notNil ]]) ifTrue:[ |
|
1875 |
"/ a classvar or private class |
|
1876 |
] ifFalse:[ |
|
1877 |
"/ todo: an instvar selected? |
|
1878 |
sub disable:#browseReferencesToIt. |
|
1879 |
]. |
|
4459 | 1880 |
]. |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1881 |
]. |
4342 | 1882 |
(s notNil |
1883 |
and:[ s asSymbolIfInterned notNil |
|
1884 |
and:[ (SharedPool allSubclasses contains:[:pool | pool includesKey:s asSymbol]) ]]) ifFalse:[ |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1885 |
sub disable:#browseSharedPoolOfIt. |
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1886 |
]. |
4584 | 1887 |
]. |
1888 |
self isReadOnly ifTrue:[ |
|
1889 |
sub disableAll:#(commentSelection uncommentSelection) |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1890 |
]. |
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 |
|
2459 | 1893 |
m notNil ifTrue:[ |
1894 |
" |
|
1895 |
workspaces support #doIt, #printIt and #inspectIt |
|
1896 |
add them after paste. |
|
1897 |
" |
|
1898 |
idx := m indexOf:#paste. |
|
1899 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
1900 |
idx ~~ 0 ifTrue:[ |
|
2867 | 1901 |
m |
1902 |
addItemList:#( |
|
1903 |
('-' ) |
|
1904 |
('DoIt' doIt DoIt ) |
|
1905 |
('PrintIt' printIt PrintIt ) |
|
1906 |
('InspectIt' inspectIt InspectIt)) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1907 |
resources:resources |
2459 | 1908 |
after:idx. |
1909 |
||
1910 |
]. |
|
1911 |
||
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
1912 |
(self hasSelectionOrTextInCursorLine) ifFalse:[ |
3272 | 1913 |
|lNr line| |
1914 |
||
1915 |
lNr := self cursorLine. |
|
1916 |
line := self listAt:lNr. |
|
1917 |
line isEmptyOrNil ifTrue:[ |
|
1918 |
m disableAll:#(printIt doIt inspectIt browseIt) |
|
1919 |
]. |
|
2459 | 1920 |
]. |
2595 | 1921 |
self isReadOnly ifTrue:[ |
1922 |
m disable:#printIt |
|
1923 |
]. |
|
418 | 1924 |
]. |
1925 |
||
2459 | 1926 |
^ m ? sub. |
430 | 1927 |
|
4209
c8e3967e8623
added: #browseSharedPoolOfIt
Claus Gittinger <cg@exept.de>
parents:
4188
diff
changeset
|
1928 |
"Modified: / 22-04-1998 / 21:49:06 / ca" |
4342 | 1929 |
"Modified: / 20-12-2011 / 11:22:20 / cg" |
418 | 1930 |
! |
1931 |
||
1932 |
inspectIt |
|
1933 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
1934 |
and start an inspector on the result" |
|
1935 |
||
2981
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1936 |
|shifted| |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1937 |
|
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1938 |
shifted := self sensor shiftDown. |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1939 |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1940 |
^ self |
3272 | 1941 |
do:(self selectionOrTextOfCursorLine) |
2982
9a831ab53acc
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2981
diff
changeset
|
1942 |
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
|
1943 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1944 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 1945 |
! |
1946 |
||
1947 |
printIt |
|
1948 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
1949 |
and insert result of evaluation into my text. |
|
1950 |
If the text is readOnly, do nothing." |
|
1951 |
||
1734 | 1952 |
self isReadOnly ifTrue:[ |
3511 | 1953 |
self beep. |
1954 |
^ self. |
|
1955 |
]. |
|
1956 |
self |
|
1957 |
undoableDo:[ |
|
1958 |
self |
|
1959 |
do:(self selectionOrTextOfCursorLine) |
|
4367 | 1960 |
withValueDo:[:result | |
1961 |
|s| |
|
1962 |
||
3511 | 1963 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
4367 | 1964 |
(result isInteger |
1965 |
and:[ result > 10 |
|
4401 | 1966 |
and:[ InspectorView defaultIntegerDisplayRadix ~= 10 ]]) ifTrue:[ |
1967 |
s := result displayString , ' "',(result radixPrintStringRadix: InspectorView defaultIntegerDisplayRadix),'"'. |
|
4367 | 1968 |
] ifFalse:[ |
1969 |
s := result displayString "printString" |
|
1970 |
]. |
|
1971 |
self insertSelectedStringAtCursor:s |
|
3511 | 1972 |
] |
1973 |
] |
|
1974 |
info:'PrintIt' |
|
1975 |
||
4401 | 1976 |
"Modified: / 08-03-2012 / 16:14:34 / cg" |
3511 | 1977 |
! |
418 | 1978 |
|
4471 | 1979 |
profileIt |
1980 |
"user selected 'profileIt' from menu; show a wait-cursor, profile the code |
|
4472 | 1981 |
and finally restore the cursor. Open a visual profiler on the sample data." |
4471 | 1982 |
|
4472 | 1983 |
self spyOnItUsing:Tools::Profiler |
4471 | 1984 |
! |
1985 |
||
3511 | 1986 |
replaceIt |
1987 |
"like printIt, but replace the selection with the result, instead of |
|
1988 |
pasting it after the selection." |
|
1989 |
||
1990 |
self isReadOnly ifTrue:[ |
|
1991 |
self beep. |
|
1992 |
^ self |
|
1993 |
]. |
|
1994 |
||
1995 |
self |
|
1996 |
undoableDo:[ |
|
1997 |
self |
|
1998 |
do:(self selectionOrTextOfCursorLine) |
|
1999 |
withValueDo:[:result | |
|
2000 |
self replaceSelectionBy:(result displayString "printString") |
|
2001 |
]. |
|
2002 |
undoSupport actionInfo:'ReplaceIt'. |
|
2003 |
] |
|
2004 |
info:'ReplaceIt' |
|
2005 |
||
2006 |
"Created: / 08-11-2007 / 11:31:54 / cg" |
|
1501 | 2007 |
! |
2008 |
||
2009 |
spyOnIt |
|
2010 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
4472 | 2011 |
and finally restore the cursor. Show profile data on the Transcript" |
2012 |
||
2013 |
self spyOnItUsing:MessageTally |
|
2014 |
! |
|
2015 |
||
2016 |
spyOnItUsing:aProfiler |
|
2017 |
"common code for spyOnIt / profileIt. |
|
2018 |
Show a wait-cursor, evaluate the code with profier on it, |
|
2019 |
and finally restore the cursor. Show profile data as per profiler" |
|
1501 | 2020 |
|
2021 |
|code| |
|
2022 |
||
4427 | 2023 |
compilerClass == Smalltalk::Compiler ifFalse:[ |
2024 |
"sigh - this measurement will include the time to compile - sigh" |
|
4472 | 2025 |
aProfiler spyDetailedOn:[ self doIt ]. |
4427 | 2026 |
^ self. |
2027 |
]. |
|
2028 |
||
4472 | 2029 |
code := aProfiler name,' spyDetailedOn:[' , self selectionAsString, ']'. |
4149 | 2030 |
self do:code withValueDo:[:value| ]. |
1501 | 2031 |
! |
2032 |
||
2033 |
timeIt |
|
2034 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
2035 |
and finally restore cursor; return result of evaluation" |
|
2036 |
||
4427 | 2037 |
|code t| |
2038 |
||
2039 |
compilerClass == Smalltalk::Compiler ifFalse:[ |
|
2040 |
"sigh - this measurement will include the time to compile - sigh" |
|
2041 |
t := Time millisecondsToRun:[ self doIt ]. |
|
2042 |
Transcript showCR:'execution time: ' , t printString , ' ms'. |
|
2043 |
^ self. |
|
2044 |
]. |
|
1501 | 2045 |
|
3272 | 2046 |
code := '|t| t := Time millisecondsToRun:[' , self selectionAsString, ']. |
4149 | 2047 |
Transcript showCR:''execution time: '' , t printString , '' ms''.'. |
2048 |
self do:code withValueDo:[:value | ]. |
|
1501 | 2049 |
|
4427 | 2050 |
"Modified: / 22-04-1998 / 22:03:51 / ca" |
2051 |
"Modified (format): / 02-06-2012 / 00:38:51 / cg" |
|
418 | 2052 |
! ! |
2053 |
||
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2054 |
!Workspace methodsFor:'misc'! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2055 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2056 |
expandAbbreviation |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2057 |
"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
|
2058 |
cursor, find an abbrev for it and expand." |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2059 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2060 |
|expandedString abortExpandAction oldSelectionStartLine oldSelectionStartCol oldSelectionEndLine oldSelectionEndCol oldCursorLine oldCursorCol |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2061 |
newCursorPos replStartCol| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2062 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2063 |
oldCursorLine := self cursorLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2064 |
oldCursorCol := self cursorCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2065 |
oldSelectionStartLine := self selectionStartLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2066 |
oldSelectionStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2067 |
oldSelectionEndLine := self selectionEndLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2068 |
oldSelectionEndCol := self selectionEndCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2069 |
|
4706 | 2070 |
abortExpandAction := |
2071 |
[ |
|
2072 |
self |
|
2073 |
selectFromLine:oldSelectionStartLine col:oldSelectionStartCol |
|
2074 |
toLine:oldSelectionEndLine col:oldSelectionEndCol. |
|
2075 |
self cursorLine:oldCursorLine col:oldCursorCol. |
|
2076 |
]. |
|
2077 |
||
2078 |
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
|
2079 |
expandedString isNil ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2080 |
abortExpandAction value. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2081 |
^ self |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2082 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2083 |
newCursorPos := expandedString indexOf:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2084 |
newCursorPos ~~ 0 ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2085 |
expandedString := expandedString copyWithout:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2086 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2087 |
replStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2088 |
self |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2089 |
undoableDo:[ |
4706 | 2090 |
self replaceSelectionWith: expandedString |
2091 |
] |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2092 |
info:'Replace'. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2093 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2094 |
newCursorPos == 0 ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2095 |
"/ cursor already fine (at the end) |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2096 |
] ifFalse:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2097 |
self cursorCol:replStartCol+newCursorPos-1 |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2098 |
] |
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 |
findAbbreviationKeyBeforeCursor |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2102 |
"after receiving an Alt-shift key-event, look for the string before the |
4706 | 2103 |
cursor, find an abbrev for it, return the key and the abbreviation for it. |
2104 |
If none is found, return nil" |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2105 |
|
4714 | 2106 |
|sniplets keys minMax maxKeyLen minKeyLen stringBeforeCursor| |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2107 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2108 |
sniplets := self class sniplets. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2109 |
keys := sniplets keys. |
4714 | 2110 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2111 |
minMax := (keys collect:[:k | k size]) minMax. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2112 |
minKeyLen := minMax first. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2113 |
maxKeyLen := minMax second. |
4714 | 2114 |
|
2115 |
stringBeforeCursor := self lineStringBeforeCursor. |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2116 |
maxKeyLen := maxKeyLen min:stringBeforeCursor size. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2117 |
|
4706 | 2118 |
maxKeyLen to:minKeyLen by:-1 do:[:keyLen | |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2119 |
|lCharactersBeforeCursor expandedString| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2120 |
|
4706 | 2121 |
lCharactersBeforeCursor := stringBeforeCursor last:keyLen. |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2122 |
expandedString := sniplets at:lCharactersBeforeCursor ifAbsent:nil. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2123 |
expandedString notNil ifTrue:[ |
4706 | 2124 |
^ { lCharactersBeforeCursor . expandedString withCRs } |
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2125 |
]. |
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 |
^ nil. |
4185 | 2128 |
|
2129 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
4617 | 2130 |
! |
2131 |
||
4706 | 2132 |
selectAbbreviationKeyBeforeCursor |
2133 |
"after receiving an Alt-shift key-event, look for the string before the |
|
2134 |
cursor, find an abbrev for it, select it and return the abbreviation for it. |
|
2135 |
If none is found, do not select and return nil" |
|
2136 |
||
2137 |
|keyAndSniplet sniplet key| |
|
2138 |
||
2139 |
(keyAndSniplet := self findAbbreviationKeyBeforeCursor) notNil ifTrue:[ |
|
2140 |
key := keyAndSniplet first. |
|
2141 |
sniplet := keyAndSniplet second. |
|
2142 |
self selectFromLine:cursorLine col:cursorCol-key size toLine:cursorLine col:cursorCol-1. |
|
2143 |
^ sniplet |
|
2144 |
]. |
|
2145 |
^ nil. |
|
2146 |
||
2147 |
"Modified: / 29-10-2010 / 10:22:38 / cg" |
|
2148 |
! |
|
2149 |
||
4617 | 2150 |
selectedTextOrSyntaxElement |
2151 |
|selectedText el| |
|
2152 |
||
2153 |
selectedText := self selectionAsString. |
|
2154 |
selectedText isEmptyOrNil ifTrue:[ |
|
2155 |
self supportsSyntaxElements ifTrue:[ |
|
2156 |
el := self syntaxElementForSelectorUnderCursor. |
|
2157 |
el notNil ifTrue:[ selectedText := el value ]. |
|
2158 |
] |
|
2159 |
]. |
|
2160 |
^ selectedText |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2161 |
! ! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
2162 |
|
2646 | 2163 |
!Workspace methodsFor:'queries'! |
2164 |
||
2165 |
isWorkspace |
|
4395 | 2166 |
"back-query from the compiler to ask if this is an interactive view |
2167 |
(for error feedback)" |
|
2168 |
||
2646 | 2169 |
^ true |
4395 | 2170 |
|
2171 |
"Modified (comment): / 07-03-2012 / 17:52:59 / cg" |
|
2646 | 2172 |
! ! |
2173 |
||
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2174 |
!Workspace::CodeCompletionService class methodsFor:'instance creation'! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2175 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2176 |
for:anEditView |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2177 |
^ self new editView:anEditView |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2178 |
! ! |
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 |
!Workspace::CodeCompletionService methodsFor:'accessing'! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2181 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2182 |
editView:something |
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 |
! ! |
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 |
!Workspace::CodeCompletionService methodsFor:'events'! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2187 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2188 |
buttonPress:button x:x y:y |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2189 |
self closeCompletionView. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2190 |
! |
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 |
editViewLostFocus |
4714 | 2193 |
completionView notNil ifTrue:[ |
2194 |
self closeCompletionView |
|
2195 |
] |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2196 |
! |
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 |
handleKeyPress:key x:x y:y |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2199 |
"return true, if I have eaten this keypress" |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2200 |
|
4716 | 2201 |
(completionView isNil or:[completionView realized not]) ifTrue:[ |
4725 | 2202 |
(key == #Control_L or:[ key == #Control_R or:[ key == #Control]]) ifTrue:[ |
4726 | 2203 |
editView hasSelection ifFalse:[ |
2204 |
UserPreferences current codeCompletionOnControlKey ifTrue:[ |
|
2205 |
self updateCompletionList |
|
2206 |
] |
|
2207 |
]. |
|
4725 | 2208 |
]. |
4716 | 2209 |
^ false. |
2210 |
]. |
|
2211 |
||
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2212 |
key isCharacter ifFalse:[ |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2213 |
"/ forward to menu |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2214 |
completionView notNil ifTrue:[ |
4726 | 2215 |
(key == #CursorDown |
2216 |
or:[ (key == #CursorUp) |
|
2217 |
or:[ ((key == #Return) and:[ completionView hasSelection ]) |
|
2218 |
]]) ifTrue:[ |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2219 |
"/ forward to completion view |
4703 | 2220 |
completionView sensor pushUserEvent:#value for:[ completionView keyPress:key x:0 y:0 ]. |
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2221 |
^ true. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2222 |
]. |
4717 | 2223 |
(key == #Control_L or:[ key == #Control_R or:[ key == #Control]]) ifTrue:[ |
4729 | 2224 |
"/ CTRL is a toggle |
2225 |
self closeCompletionView. |
|
2226 |
^ true. |
|
2227 |
"/ ^ false |
|
4717 | 2228 |
]. |
2229 |
(key == #Escape) ifTrue:[ |
|
4714 | 2230 |
self closeCompletionView. |
4717 | 2231 |
^ true "/ EAT |
4714 | 2232 |
]. |
4717 | 2233 |
self closeCompletionView. |
2234 |
^ false "/ don' eat |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2235 |
]. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2236 |
]. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2237 |
|
4703 | 2238 |
(key == #Escape) ifTrue:[ |
2239 |
completionView notNil ifTrue:[ |
|
2240 |
self closeCompletionView. |
|
2241 |
^ true |
|
4714 | 2242 |
]. |
4729 | 2243 |
"/ self halt. |
4703 | 2244 |
]. |
2245 |
||
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2246 |
(key == #CursorRight |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2247 |
or:[key == #CursorDown |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2248 |
or:[key == #CursorLeft |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2249 |
or:[key == #CursorUp]]]) ifTrue:[ |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2250 |
completionView notNil ifTrue:[ |
4703 | 2251 |
completionView sensor pushUserEvent:#value for:[ completionView keyPress:key x:x y:y ]. |
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2252 |
^ true |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2253 |
]. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2254 |
]. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2255 |
^ false. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2256 |
! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2257 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2258 |
postKeyPress:key |
4729 | 2259 |
UserPreferences current immediateCodeCompletion ifFalse:[ |
2260 |
"/ only update, if already open |
|
2261 |
completionView isNil ifTrue:[^ self]. |
|
2262 |
]. |
|
2263 |
||
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2264 |
(key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[ |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2265 |
self updateCompletionList. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2266 |
^ self |
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 |
key isCharacter ifTrue:[ |
4714 | 2270 |
key isSeparator ifTrue:[ |
2271 |
self closeCompletionView |
|
2272 |
] ifFalse:[ |
|
4703 | 2273 |
self updateCompletionList. |
4714 | 2274 |
]. |
2275 |
^ self |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2276 |
]. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2277 |
! ! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2278 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2279 |
!Workspace::CodeCompletionService methodsFor:'private'! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2280 |
|
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2281 |
closeCompletionView |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2282 |
|v| |
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 |
(v := completionView) notNil ifTrue:[ |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2285 |
completionView := nil. |
4703 | 2286 |
"/ let it close itself - avoids synchronization problems |
2287 |
v sensor |
|
2288 |
pushUserEvent:#value |
|
2289 |
for:[ v topView destroy ] |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2290 |
]. |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2291 |
! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2292 |
|
4714 | 2293 |
release |
2294 |
self stopCompletionProcess. |
|
2295 |
self closeCompletionView. |
|
2296 |
super release |
|
2297 |
! |
|
2298 |
||
4703 | 2299 |
startCompletionProcess |
4729 | 2300 |
"start the code completion process in the background" |
4703 | 2301 |
|
4733 | 2302 |
|movePos topView initialList cursorX cursorY| |
4703 | 2303 |
|
2304 |
"/ terminate any previous process |
|
2305 |
self stopCompletionProcess. |
|
4698 | 2306 |
|
2307 |
(editView sensor hasKeyPressEventFor:nil) ifTrue:[ |
|
2308 |
self closeCompletionView. |
|
2309 |
^ self |
|
2310 |
]. |
|
4733 | 2311 |
((cursorX := editView xOfCursor) isNil |
2312 |
or:[ (cursorY := editView yOfCursor) isNil ]) ifTrue:[ |
|
2313 |
"/ no cursor - user is selecting, or cursor has been scrolled out of sight. |
|
2314 |
self closeCompletionView. |
|
2315 |
^ self |
|
2316 |
]. |
|
4698 | 2317 |
|
4709 | 2318 |
initialList := #( 'busy...' ). |
4706 | 2319 |
|
4703 | 2320 |
"/ move the window |
4733 | 2321 |
movePos := editView device translatePoint:(cursorX @ cursorY) fromView:editView toView:nil. |
4714 | 2322 |
"/ currently, we have to stay away a bit, to avoid getting the focus |
2323 |
movePos := movePos + (60 @ (editView font height)). |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2324 |
|
4698 | 2325 |
completionView isNil ifTrue:[ |
4727 | 2326 |
completionView := CodeCompletionHelpMenuView new. |
2327 |
completionView name:'completion'. |
|
4703 | 2328 |
completionView level:0. |
4706 | 2329 |
completionView list:initialList. |
2330 |
completionView enable:false. |
|
4703 | 2331 |
completionView extent:completionView preferredExtentForContents. |
4698 | 2332 |
topView := CodeCompletionHelpView with:completionView. |
4703 | 2333 |
topView origin:movePos. |
2334 |
topView resizeToFit. |
|
4709 | 2335 |
"/ topView open. |
4703 | 2336 |
] ifFalse:[ |
4706 | 2337 |
completionView list:initialList. |
4703 | 2338 |
topView := completionView topView. |
4714 | 2339 |
topView ~~ completionView ifTrue:[ |
2340 |
topView origin:movePos. |
|
2341 |
topView resizeToFit. |
|
2342 |
] |
|
4698 | 2343 |
]. |
2344 |
||
4703 | 2345 |
completionProcess := |
2346 |
[ |
|
2347 |
|suggestions actions anyFound| |
|
2348 |
||
2349 |
UserInformation ignoreIn:[ |
|
2350 |
anyFound := false. |
|
2351 |
DoWhatIMeanSupport |
|
2352 |
codeCompletionForMethod:editView editedMethod |
|
2353 |
orClass:editView editedClass |
|
2354 |
context:nil |
|
2355 |
codeView:editView |
|
4705 | 2356 |
into:[:listOfSuggestions :listOfActions :titleWhenAsking | |
4703 | 2357 |
suggestions := listOfSuggestions. |
2358 |
actions := listOfActions. |
|
2359 |
anyFound := true. |
|
2360 |
nil "/ must return nil to avoid DWIM to do it itself (for now) |
|
2361 |
] |
|
4698 | 2362 |
]. |
4703 | 2363 |
"/ anyFound ifFalse:[self halt]. |
2364 |
"/ Transcript show:'suggestions: '; showCR:suggestions. |
|
2365 |
"/ Transcript show:'actions: '; showCR:actions. |
|
2366 |
editView sensor |
|
2367 |
pushUserEvent:#'suggestionsArrived:actions:' |
|
2368 |
for:self |
|
2369 |
withArguments:{suggestions . actions } |
|
2370 |
] forkAt:(Processor activePriority - 1). |
|
2371 |
! |
|
2372 |
||
2373 |
stopCompletionProcess |
|
2374 |
"kill any background completion process" |
|
2375 |
||
2376 |
|p| |
|
2377 |
||
2378 |
(p := completionProcess) notNil ifTrue:[ |
|
2379 |
completionProcess := nil. |
|
2380 |
p terminate. |
|
2381 |
]. |
|
2382 |
! |
|
2383 |
||
2384 |
suggestionsArrived:suggestions actions:actions |
|
4722 | 2385 |
|v list suggestionOffset keyAndSniplet lastEntryIsSniplet| |
4703 | 2386 |
|
2387 |
(editView sensor hasKeyPressEventFor:nil) ifTrue:[ |
|
2388 |
self closeCompletionView. |
|
2389 |
^ self |
|
2390 |
]. |
|
4706 | 2391 |
|
2392 |
list := suggestions ? #(). |
|
2393 |
list size > 20 ifTrue:[ list := list copyTo:20 ]. |
|
2394 |
||
4714 | 2395 |
"/ append snipplets, if any (can be easily reached via CRSR-up) |
4706 | 2396 |
suggestionOffset := 0. |
4722 | 2397 |
lastEntryIsSniplet := false. |
4706 | 2398 |
(keyAndSniplet := editView findAbbreviationKeyBeforeCursor) notNil ifTrue:[ |
4714 | 2399 |
|abbrev sniplet i line| |
4706 | 2400 |
|
2401 |
abbrev := keyAndSniplet first. |
|
2402 |
sniplet := keyAndSniplet second. |
|
4714 | 2403 |
|
2404 |
"/ if the abbreviation is simply at the end of a longer word, ignore the abbrev. |
|
2405 |
line := editView lineStringBeforeCursor. |
|
2406 |
i := line findLast:[:ch | ch isLetterOrDigit not]. |
|
2407 |
(i < (line size - abbrev size - 1)) ifFalse:[ |
|
2408 |
sniplet := sniplet copyWithout:$!!. |
|
2409 |
||
2410 |
"/ true, false and self are often found in both lists |
|
2411 |
(list includes:sniplet) ifFalse:[ |
|
2412 |
list isEmpty ifFalse:[ list := list copyWith: '-' ]. |
|
2413 |
list := list copyWith: ( '%1 %2' |
|
2414 |
bindWith:(sniplet asStringCollection first "contractTo:25") |
|
2415 |
with: ( ('("',abbrev,'" sniplet)') colorizeAllWith:Color grey)). |
|
4722 | 2416 |
lastEntryIsSniplet := true. |
4714 | 2417 |
|
2418 |
"/ change below, when reversing the order in above code |
|
2419 |
"/ suggestionOffset := 2. |
|
2420 |
] |
|
4706 | 2421 |
] |
2422 |
]. |
|
2423 |
list isEmptyOrNil ifTrue:[ |
|
4703 | 2424 |
self closeCompletionView. |
2425 |
^ self |
|
2426 |
]. |
|
4706 | 2427 |
|
4703 | 2428 |
(v := completionView) isNil ifTrue: [ |
2429 |
^ self |
|
2430 |
]. |
|
4709 | 2431 |
v topView open. |
2432 |
||
4703 | 2433 |
"/ v waitUntilVisible. |
2434 |
||
2435 |
v sensor |
|
2436 |
pushUserEvent:#value |
|
2437 |
for:[ |
|
4706 | 2438 |
|top| |
2439 |
||
4704 | 2440 |
(v == completionView) ifTrue: [ |
4706 | 2441 |
top := v topView. |
2442 |
||
2443 |
v list:list. |
|
2444 |
v enable:true. |
|
4704 | 2445 |
v extent:completionView preferredExtentForContents. |
2446 |
||
2447 |
v action: |
|
4706 | 2448 |
[:selectedListIndex | |
2449 |
|indexInSuggestions| |
|
2450 |
||
4714 | 2451 |
self closeCompletionView. |
4706 | 2452 |
indexInSuggestions := selectedListIndex - suggestionOffset. |
4722 | 2453 |
(lastEntryIsSniplet and:[ selectedListIndex == list size]) ifTrue:[ |
4706 | 2454 |
"/ replace the sniplet |
4714 | 2455 |
editView sensor |
2456 |
pushUserEvent:#value |
|
2457 |
for:[ |
|
2458 |
editView expandAbbreviation |
|
2459 |
] |
|
4706 | 2460 |
] ifFalse:[ |
2461 |
actions notNil ifTrue:[ |
|
2462 |
actions isBlock ifTrue:[ |
|
2463 |
actions value:indexInSuggestions |
|
2464 |
] ifFalse:[ |
|
2465 |
(actions at:indexInSuggestions) value |
|
2466 |
]. |
|
4704 | 2467 |
]. |
2468 |
]. |
|
4717 | 2469 |
"/ no, user has chosen; so don't show more suggestions |
2470 |
"/ editView sensor |
|
2471 |
"/ pushUserEvent:#value |
|
2472 |
"/ for:[ |
|
2473 |
"/ self updateCompletionList |
|
2474 |
"/ ] |
|
4703 | 2475 |
]. |
4704 | 2476 |
|
4706 | 2477 |
(top ~~ v) ifTrue:[ |
2478 |
top resizeToFit. |
|
2479 |
top bottom > v device usableHeight ifTrue:[ |
|
2480 |
top origin:((top origin x) @ (v device usableHeight - v height)). |
|
2481 |
]. |
|
2482 |
top raise. |
|
4704 | 2483 |
] |
2484 |
] |
|
4703 | 2485 |
] |
2486 |
! |
|
2487 |
||
2488 |
updateCompletionList |
|
2489 |
"called for keypress events" |
|
2490 |
||
2491 |
self startCompletionProcess. |
|
4695
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2492 |
! ! |
f133e5bd6e22
refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents:
4691
diff
changeset
|
2493 |
|
206 | 2494 |
!Workspace class methodsFor:'documentation'! |
2495 |
||
4402 | 2496 |
version |
4733 | 2497 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.290 2013-09-03 19:27:51 cg Exp $' |
4402 | 2498 |
! |
2499 |
||
3959 | 2500 |
version_CVS |
4733 | 2501 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.290 2013-09-03 19:27:51 cg Exp $' |
858 | 2502 |
! ! |
4504 | 2503 |