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