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