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