author | Claus Gittinger <cg@exept.de> |
Wed, 13 Oct 2010 12:00:40 +0200 | |
changeset 4172 | 432d4d3f5717 |
parent 4171 | 20a315cd98c4 |
child 4175 | e7063a3e7ec5 |
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 |
||
625 |
|action| |
|
626 |
||
627 |
self highlightingErrorPosition:relPos to:relEndPos do:[ |
|
3383 | 628 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
629 |
|box declareButton| |
|
630 |
||
631 |
box := ex parameter. |
|
632 |
declareButton := box buttons at:2. |
|
633 |
declareButton pressAction:declareButton controller releaseAction. |
|
634 |
declareButton controller beTriggerOnDown. |
|
635 |
ex proceed. |
|
636 |
] do:[ |
|
637 |
action := OptionBox |
|
638 |
request:aString |
|
3592
cb6f9f060e62
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3579
diff
changeset
|
639 |
label:(resources string:'Correctable Error') |
3383 | 640 |
image:(WarningBox iconBitmap) |
3592
cb6f9f060e62
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3579
diff
changeset
|
641 |
buttonLabels:(resources array:#('Cancel' 'Declare as...' 'Correct...' 'Continue')) |
3383 | 642 |
values:#(#abort #declare #correct #continue) |
643 |
default:#continue |
|
644 |
onCancel:#abort. |
|
645 |
]. |
|
201 | 646 |
]. |
647 |
||
1930
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
648 |
action == #declare ifTrue:[ |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
649 |
^ action |
5852350f36f4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
1925
diff
changeset
|
650 |
]. |
201 | 651 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
652 |
AbortOperationRequest raise. |
368 | 653 |
^ false |
201 | 654 |
]. |
368 | 655 |
^ action == #correct |
656 |
||
3383 | 657 |
"Modified: / 05-09-2006 / 12:20:42 / cg" |
201 | 658 |
! |
659 |
||
2104 | 660 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
661 |
"compiler notifies us of a correctable selector warning; |
|
662 |
hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort; |
|
663 |
this method should return true to the compiler if user wants the error |
|
664 |
to be corrected; false otherwise" |
|
665 |
||
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
666 |
|action doNotShowAgainHolder| |
2104 | 667 |
|
3261 | 668 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
3744
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
669 |
doNotShowAgainHolder := false asValue. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
670 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
671 |
(aCompiler notNil and:[aCompiler class doNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
672 |
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
|
673 |
]. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
674 |
ex proceed. |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
675 |
] do:[ |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
676 |
action := OptionBox |
2104 | 677 |
request:aString |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
678 |
label:(resources string:'Warning') |
2983
910b4d5f7b1b
dont send obsolete message (OptionBox request:..form:..)
Claus Gittinger <cg@exept.de>
parents:
2982
diff
changeset
|
679 |
image:(WarningBox iconBitmap) |
2471
fc8c179c4228
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2470
diff
changeset
|
680 |
buttonLabels:(resources array:#('Cancel' 'Correct...' 'Generate' 'Continue')) |
2338 | 681 |
values:#(#abort #correct #generate #continue) |
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
682 |
default:#continue |
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
683 |
onCancel:#abort. |
3744
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 |
doNotShowAgainHolder value == true ifTrue:[ |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
686 |
aCompiler class doNotShowCompilerWarningAgainActionQuery actionQuery value |
c206f437042e
turn on/off selector warnings
Claus Gittinger <cg@exept.de>
parents:
3742
diff
changeset
|
687 |
]. |
2104 | 688 |
]. |
689 |
||
2338 | 690 |
action == #generate ifTrue:[ |
691 |
^ action |
|
692 |
]. |
|
693 |
||
2391
f8cd579704db
optionBox: cancel-value corrected
Claus Gittinger <cg@exept.de>
parents:
2388
diff
changeset
|
694 |
(action isNil or:[action == #abort]) ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
695 |
AbortOperationRequest raise. |
2104 | 696 |
^ false |
697 |
]. |
|
698 |
^ action == #correct |
|
699 |
||
700 |
"Created: / 19.1.2000 / 16:27:28 / cg" |
|
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
701 |
"Modified: / 16.11.2001 / 17:39:29 / cg" |
2104 | 702 |
! |
703 |
||
201 | 704 |
error:aString position:relPos to:relEndPos asWarning:asWarning |
2277 | 705 |
"obsolete - no longer invoked" |
706 |
||
707 |
^ self error:aString position:relPos to:relEndPos from:nil asWarning:asWarning |
|
708 |
! |
|
709 |
||
710 |
error:aString position:relPos to:relEndPos from:aCompiler |
|
711 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
|
712 |
and show a Box asking for continue/abort." |
|
713 |
||
714 |
^ self error:aString position:relPos to:relEndPos from:aCompiler asWarning:false |
|
715 |
! |
|
716 |
||
717 |
error:aString position:relPos to:relEndPos from:aCompiler asWarning:asWarning |
|
3397 | 718 |
"compiler notifies us of an error; hilight the error (relPos to relEndPos) |
201 | 719 |
and show a Box asking for continue/abort." |
720 |
||
3007 | 721 |
|answer fg bg| |
201 | 722 |
|
3007 | 723 |
fg := asWarning ifTrue:[ self warningForegroundColor ] ifFalse:[ self errorForegroundColor ]. |
724 |
bg := asWarning ifTrue:[ self warningBackgroundColor ] ifFalse:[ self errorBackgroundColor ]. |
|
201 | 725 |
|
3397 | 726 |
self |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
727 |
highlightingErrorPosition:relPos to:relEndPos |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
728 |
withForeground:fg andBackground:bg |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
729 |
do:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
730 |
|box lbl doNotShowAgainHolder l1 y1 y2 l2| |
201 | 731 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
732 |
"/ Warning isHandled ifTrue:[ |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
733 |
"/ Warning raiseErrorString:aString. |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
734 |
"/ ^ false |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
735 |
"/ ]. |
213
6286d3f36c14
raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents:
208
diff
changeset
|
736 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
737 |
" |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
738 |
ask if we should abort or continue |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
739 |
" |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
740 |
box := YesNoBox |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
741 |
title:aString |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
742 |
yesText:(resources string:'Continue') |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
743 |
noText:(resources string:'Abort'). |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
744 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
745 |
lbl := aCompiler isNil ifTrue:['Compiler'] ifFalse:[aCompiler class name]. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
746 |
asWarning ifTrue:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
747 |
lbl := lbl , ' Warning' |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
748 |
] ifFalse:[ |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
749 |
lbl := lbl , ' Error'. |
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 label:lbl. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
752 |
box image:(WarningBox iconBitmap). |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
753 |
|
4125
eeed55ffc143
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4103
diff
changeset
|
754 |
(aCompiler notNil and:[DoNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
755 |
doNotShowAgainHolder := false asValue. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
756 |
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
|
757 |
]. |
3007 | 758 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
759 |
answer := box confirm. |
3007 | 760 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
761 |
doNotShowAgainHolder value == true ifTrue:[ |
4125
eeed55ffc143
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4103
diff
changeset
|
762 |
DoNotShowCompilerWarningAgainActionQuery actionQuery value |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
763 |
]. |
3007 | 764 |
|
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
765 |
box destroy. |
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
766 |
]. |
2799
4d9967d1052e
support doNotSHowThisWarningDialogAgain
Claus Gittinger <cg@exept.de>
parents:
2794
diff
changeset
|
767 |
|
201 | 768 |
" |
769 |
do the abort if we have to |
|
770 |
" |
|
3397 | 771 |
answer ifFalse:[ |
3480
9defe040ef4a
AbortSignal->AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
3429
diff
changeset
|
772 |
AbortOperationRequest raise. |
201 | 773 |
]. |
774 |
^ 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
|
775 |
|
4170
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
776 |
"Created: / 24-11-1995 / 22:56:34 / cg" |
6bf83a2af71f
changed: #error:position:to:from:asWarning:
Claus Gittinger <cg@exept.de>
parents:
4158
diff
changeset
|
777 |
"Modified: / 22-09-2010 / 11:59:54 / cg" |
201 | 778 |
! |
779 |
||
2663 | 780 |
highlightingErrorLine:lineNr do:aBlock |
781 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
782 |
||
783 |
|linePosition| |
|
784 |
||
785 |
linePosition := self characterPositionOfLine:lineNr col:1. |
|
786 |
self highlightingErrorPosition:linePosition to:nil do:aBlock |
|
787 |
! |
|
788 |
||
59 | 789 |
highlightingErrorPosition:relPos to:relEndPos do:aBlock |
790 |
"evaluate aBlock while some selection is shown highlighted with error colors." |
|
58 | 791 |
|
3007 | 792 |
self |
793 |
highlightingErrorPosition:relPos to:relEndPos |
|
794 |
withForeground:(self errorForegroundColor) andBackground:(self errorBackgroundColor) |
|
795 |
do:aBlock |
|
796 |
! |
|
797 |
||
798 |
highlightingErrorPosition:relPos to:relEndPos withForeground:hilightFg andBackground:hilightBg do:aBlock |
|
799 |
"evaluate aBlock while some selection is shown highlighted with colors passed as args." |
|
800 |
||
801 |
|absPosition oldFg oldBg| |
|
0 | 802 |
|
58 | 803 |
" |
804 |
change color of selection & hide cursor |
|
805 |
" |
|
3007 | 806 |
oldFg := selectionFgColor. |
807 |
oldBg := selectionBgColor. |
|
808 |
selectionBgColor := hilightBg. |
|
809 |
selectionFgColor := hilightFg. |
|
58 | 810 |
self hideCursor. |
0 | 811 |
|
58 | 812 |
" |
813 |
select the text - relEndPos may be nil in which case the whole line is selected |
|
814 |
we have to adjust the positions given by the compiler, since they |
|
815 |
are relative to the texts start (the compiler did stream-read the code). |
|
816 |
" |
|
0 | 817 |
codeStartPosition isNil ifTrue:[codeStartPosition := 1]. |
3427 | 818 |
absPosition := codeStartPosition + (relPos ? 1) - 1. |
0 | 819 |
relEndPos isNil ifTrue:[ |
4141
06c97cc2bf6d
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
820 |
self selectFromCharacterPosition:absPosition. |
06c97cc2bf6d
changed: #highlightingErrorPosition:to:withForeground:andBackground:do:
Claus Gittinger <cg@exept.de>
parents:
4125
diff
changeset
|
821 |
"/ self selectLineWhereCharacterPosition:absPosition. |
0 | 822 |
] ifFalse:[ |
3427 | 823 |
self selectFromCharacterPosition:absPosition to:(codeStartPosition + (relEndPos ? 1) - 1) |
0 | 824 |
]. |
825 |
self makeSelectionVisible. |
|
826 |
||
155 | 827 |
device flush. |
58 | 828 |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
829 |
aBlock ensure:[ |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
830 |
" |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
831 |
undo selection color change and show cursor again |
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
832 |
" |
3007 | 833 |
selectionFgColor := oldFg. |
834 |
selectionBgColor := oldBg. |
|
2519
a088ad3bb1e5
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
2492
diff
changeset
|
835 |
self showCursor. |
0 | 836 |
]. |
3427 | 837 |
|
838 |
"Modified: / 16-11-2006 / 16:37:34 / cg" |
|
0 | 839 |
! |
840 |
||
3007 | 841 |
highlightingWarningPosition:relPos to:relEndPos do:aBlock |
842 |
"evaluate aBlock while some selection is shown highlighted with warning colors." |
|
843 |
||
844 |
self |
|
845 |
highlightingErrorPosition:relPos to:relEndPos |
|
846 |
withForeground:(self warningForegroundColor) andBackground:(self warningBackgroundColor) |
|
847 |
do:aBlock |
|
848 |
! |
|
849 |
||
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
850 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
851 |
"compiler notifies us of a (or some) unused variables; |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
852 |
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
|
853 |
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
|
854 |
to be corrected; false otherwise" |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
855 |
|
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
856 |
|action doNotShowAgainHolder| |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
857 |
|
3007 | 858 |
self highlightingWarningPosition:relPos to:relEndPos do:[ |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
859 |
doNotShowAgainHolder := false asValue. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
860 |
Dialog aboutToOpenBoxNotificationSignal handle:[:ex | |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
861 |
(aCompiler notNil and:[aCompiler class doNotShowCompilerWarningAgainActionQuery isHandled]) ifTrue:[ |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
862 |
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
|
863 |
]. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
864 |
ex proceed. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
865 |
] do:[ |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
866 |
action := OptionBox |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
867 |
request:aString |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
868 |
label:(resources string:'Warning') |
2990
1373f301a694
dont send obsolete message to OptionBox
Claus Gittinger <cg@exept.de>
parents:
2983
diff
changeset
|
869 |
image:(WarningBox iconBitmap) |
3593
0de12c5b752a
changed #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
3592
diff
changeset
|
870 |
buttonLabels:(resources array:#('Cancel' 'Remove Variable(s)' 'Continue')) |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
871 |
values:#(#abort #correct #continue) |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
872 |
default:#continue. |
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
873 |
]. |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
874 |
doNotShowAgainHolder value == true ifTrue:[ |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
875 |
aCompiler class doNotShowCompilerWarningAgainActionQuery actionQuery value |
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
876 |
]. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
877 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
878 |
|
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
879 |
action == #abort ifTrue:[ |
2477
8a324269ee7a
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
2471
diff
changeset
|
880 |
AbortOperationRequest raise. |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
881 |
^ false |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
882 |
]. |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
883 |
^ action == #correct |
2470
240b6d2d5511
finished remove unused vars;
Claus Gittinger <cg@exept.de>
parents:
2462
diff
changeset
|
884 |
|
4154
05d107aebe74
changed: #unusedVariableWarning:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
4150
diff
changeset
|
885 |
"Modified: / 07-07-2010 / 15:51:21 / cg" |
2386
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
886 |
! |
ace953bac401
unusedVariables - correct by deleting
Claus Gittinger <cg@exept.de>
parents:
2338
diff
changeset
|
887 |
|
116 | 888 |
warning:aString position:relPos to:relEndPos from:aCompiler |
32 | 889 |
"compiler notifies us of a warning - same behavior as error" |
0 | 890 |
|
2277 | 891 |
self error:aString position:relPos to:relEndPos from:aCompiler asWarning:true |
0 | 892 |
! ! |
893 |
||
3396 | 894 |
!Workspace methodsFor:'drag & drop'! |
895 |
||
896 |
canDrop:aDropContext |
|
4090 | 897 |
"if allowValueDrop is true, any text- or file-object can be dropped into workspace |
898 |
(printString); otherwise, only ..." |
|
899 |
||
900 |
self isReadOnly ifTrue:[^ false]. |
|
3396 | 901 |
|
4090 | 902 |
allowValueDrop ifTrue:[^ true]. |
903 |
^ super canDrop:aDropContext |
|
3428 | 904 |
|
4090 | 905 |
"/ ^ aDropContext dropObjects |
906 |
"/ contains:[:someObject| (someObject isTextObject or:[ someObject isFileObject ])]. |
|
3396 | 907 |
|
908 |
"Created: / 16-08-2005 / 22:01:13 / janfrog" |
|
3428 | 909 |
"Modified: / 28-11-2006 / 16:18:51 / cg" |
3396 | 910 |
! |
911 |
||
3414 | 912 |
doDrop:aDropContext |
3739 | 913 |
self halt:'should no longer be reached'. |
3428 | 914 |
self drop:aDropContext |
3414 | 915 |
|
3428 | 916 |
"Modified: / 28-11-2006 / 16:14:51 / cg" |
3414 | 917 |
! |
918 |
||
919 |
drop:aDropContext |
|
920 |
"Any object can be dropped into workspace..." |
|
921 |
||
3870 | 922 |
|textObjects nonTextObjects answer text| |
923 |
||
924 |
textObjects := aDropContext dropObjects |
|
3887 | 925 |
select:[:dropObject | dropObject isTextObject |
926 |
or:[ dropObject isFileObject ]]. |
|
3870 | 927 |
nonTextObjects := aDropContext dropObjects |
3887 | 928 |
reject:[:dropObject | dropObject isTextObject |
929 |
or:[ dropObject isFileObject ]]. |
|
3870 | 930 |
|
931 |
self dropObjects:textObjects. |
|
3414 | 932 |
|
3870 | 933 |
nonTextObjects notEmpty ifTrue:[ |
934 |
answer := Dialog |
|
935 |
confirmWithCancel:(resources |
|
936 |
string:'Drop as textual representation or as object reference ?') |
|
937 |
labels:(resources array:#('Cancel' 'Reference' 'Name' 'Text')) |
|
938 |
values:#(nil #ref #name #text) |
|
939 |
default:4. |
|
940 |
answer isNil ifTrue:[^ self]. |
|
941 |
(answer == #text or:[answer == #name]) ifTrue:[ |
|
942 |
text := String streamContents:[:s | |
|
943 |
nonTextObjects do:[:dropObject | |
|
944 |
|obj| |
|
945 |
||
946 |
obj := dropObject theObject. |
|
947 |
obj isMethod ifTrue:[ |
|
948 |
s nextPutAll:(answer == #name ifTrue:[obj selector] ifFalse:[obj source]). |
|
949 |
] ifFalse:[ |
|
950 |
obj isClass ifTrue:[ |
|
951 |
s nextPutAll:(answer == #name ifTrue:[obj name] ifFalse:[obj source asString]) |
|
952 |
] ifFalse:[ |
|
953 |
s nextPutAll:(answer == #name ifTrue:[obj className] ifFalse:[obj printString]) . |
|
954 |
]. |
|
955 |
]. |
|
956 |
]. |
|
957 |
]. |
|
958 |
self paste:text. |
|
3414 | 959 |
] ifFalse:[ |
3870 | 960 |
nonTextObjects do:[:dropObject | |
961 |
name := Dialog |
|
962 |
request:(resources |
|
963 |
string:'Name of the new Workspace Variable (refers to the dropped %1):' |
|
964 |
with:dropObject theObject class name allBold |
|
965 |
) |
|
966 |
initialAnswer:'droppedObject' |
|
967 |
okLabel:'Add' |
|
968 |
title:'Enter Variable Name'. |
|
3414 | 969 |
|
3870 | 970 |
name notEmptyOrNil ifTrue:[ |
971 |
Workspace addWorkspaceVariable:name. |
|
972 |
(Workspace workspaceVariableAt:name) value:dropObject theObject. |
|
973 |
self paste:name. |
|
974 |
]. |
|
3414 | 975 |
]. |
3870 | 976 |
] |
3414 | 977 |
]. |
978 |
||
979 |
"Created: / 13-10-2006 / 17:34:07 / cg" |
|
3396 | 980 |
! ! |
981 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
982 |
!Workspace methodsFor:'editing'! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
983 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
984 |
commentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
985 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
986 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 987 |
in the first col |
988 |
(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
|
989 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
990 |
|eolComment opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
991 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
992 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
993 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
994 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
995 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
996 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
997 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
998 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
999 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1000 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1001 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1002 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1003 |
l isNil ifTrue:[l := '']. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1004 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1005 |
l := eolComment , l |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1006 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1007 |
l := opening , l , closing |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1008 |
]. |
3403 | 1009 |
self replaceLine:lineNr with:l. |
1010 |
widthOfWidestLine notNil ifTrue:[ |
|
1011 |
widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l). |
|
1012 |
]. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1013 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1014 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1015 |
|
3403 | 1016 |
"Created: / 09-11-1997 / 01:05:35 / cg" |
1017 |
"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
|
1018 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1019 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1020 |
commentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1021 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1022 |
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
|
1023 |
in the first col." |
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 |
|e commentPair opening closing| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1026 |
|
1481 | 1027 |
(self checkModificationsAllowed) ifFalse:[ ^ self]. |
3210 | 1028 |
commentStrings isNil ifTrue:[ self beep. ^ self]. |
1029 |
||
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1030 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1031 |
self |
3785 | 1032 |
undoableDo:[ self commentFrom:cursorLine to:cursorLine ] |
3543 | 1033 |
info:'Comment'. |
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1034 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1035 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1036 |
|
3129 | 1037 |
self |
1038 |
undoableDo: |
|
1039 |
[ |
|
1040 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1041 |
self commentFrom:selectionStartLine to:selectionEndLine-1 |
|
1042 |
] ifFalse:[ |
|
3210 | 1043 |
commentPair := commentStrings at:2 ifAbsent:nil. |
1044 |
commentPair isNil ifTrue:[ |
|
1045 |
self beep. |
|
1046 |
] ifFalse:[ |
|
1047 |
opening := commentPair at:1. |
|
1048 |
closing := commentPair at:2. |
|
1049 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
3129 | 1050 |
|
3210 | 1051 |
e := selectionEndCol. |
1052 |
||
1053 |
self insertString:closing atLine:selectionEndLine col:e+1. |
|
1054 |
self insertString:opening atLine:selectionStartLine col:selectionStartCol. |
|
3129 | 1055 |
|
3210 | 1056 |
selectionStartLine == selectionEndLine ifTrue:[e := e + opening size]. |
1057 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1058 |
toLine:selectionEndLine col:e+closing size. |
|
1059 |
] |
|
3129 | 1060 |
] |
1061 |
] |
|
1062 |
info:'comment' |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1063 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1064 |
"Created: / 9.11.1997 / 01:05:40 / cg" |
1481 | 1065 |
"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
|
1066 |
! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1067 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1068 |
uncommentFrom:line1 to:line2 |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1069 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1070 |
All lines from line1 to line2 get an end-of-line comment |
1925 | 1071 |
in the first col. |
1072 |
(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
|
1073 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1074 |
|eolComment opening closing rest| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1075 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1076 |
eolComment := commentStrings at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1077 |
eolComment isNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1078 |
opening := (commentStrings at:2) at:1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1079 |
closing := (commentStrings at:2) at:2. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1080 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1081 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1082 |
rest := eolComment size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1083 |
]. |
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 |
line1 to:line2 do:[:lineNr | |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1086 |
|l| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1087 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1088 |
l := self listAt:lineNr. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1089 |
l notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1090 |
eolComment notNil ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1091 |
(l startsWith:eolComment) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1092 |
l := l copyFrom:rest |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1093 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1094 |
] ifFalse:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1095 |
((l startsWith:opening) |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1096 |
and:[l endsWith:closing]) ifTrue:[ |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1097 |
l := l copyFrom:opening size + 1. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1098 |
l := l copyWithoutLast:closing size. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1099 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1100 |
]. |
3403 | 1101 |
self replaceLine:lineNr with:l. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1102 |
] |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1103 |
]. |
3403 | 1104 |
widthOfWidestLine := nil. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1105 |
self textChanged. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1106 |
|
3403 | 1107 |
"Created: / 09-11-1997 / 01:05:43 / cg" |
1108 |
"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
|
1109 |
! |
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 |
uncommentSelection |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1112 |
"convenient function to comment out a block. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1113 |
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
|
1114 |
in the first col." |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1115 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1116 |
|e commentPair opening closing sz1 sz2| |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1117 |
|
3129 | 1118 |
(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
|
1119 |
selectionStartLine isNil ifTrue:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1120 |
self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1121 |
undoableDo:[ |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1122 |
self uncommentFrom:cursorLine to:cursorLine |
3543 | 1123 |
] |
1124 |
info:'Uncomment'. |
|
3207
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1125 |
^ self |
0088a1d4fb0e
without selection, comment/uncomment operate on the single cursor-line
Claus Gittinger <cg@exept.de>
parents:
3157
diff
changeset
|
1126 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1127 |
|
3129 | 1128 |
self |
1129 |
undoableDo: |
|
1130 |
[ |
|
1131 |
(selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[ |
|
1132 |
self uncommentFrom:selectionStartLine to:selectionEndLine-1 |
|
1133 |
] ifFalse:[ |
|
1134 |
commentPair := commentStrings at:2. |
|
1135 |
opening := commentPair at:1. |
|
1136 |
closing := commentPair at:2. |
|
1137 |
(opening isNil or:[closing isNil]) ifTrue:[^ self]. |
|
1138 |
||
1139 |
sz1 := opening size. |
|
1140 |
sz2 := closing size. |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1141 |
|
3129 | 1142 |
((self |
1143 |
stringAtLine:selectionStartLine |
|
1144 |
from:selectionStartCol |
|
1145 |
to:selectionStartCol+sz1 - 1) = opening |
|
1146 |
and:[(self |
|
1147 |
stringAtLine:selectionEndLine |
|
1148 |
from:selectionEndCol - sz2 + 1 |
|
1149 |
to:selectionEndCol) = closing ]) ifTrue:[ |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1150 |
|
3129 | 1151 |
self deleteCharsAtLine:selectionEndLine fromCol:selectionEndCol-sz2+1 toCol:selectionEndCol. |
1152 |
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
|
1153 |
|
3129 | 1154 |
e := selectionEndCol - sz2. |
1155 |
selectionStartLine == selectionEndLine ifTrue:[e := e - sz1]. |
|
1156 |
self selectFromLine:selectionStartLine col:selectionStartCol |
|
1157 |
toLine:selectionEndLine col:e. |
|
1158 |
] |
|
1159 |
] |
|
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1160 |
] |
3129 | 1161 |
info:'uncomment' |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1162 |
|
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1163 |
"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
|
1164 |
"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
|
1165 |
! ! |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1166 |
|
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1167 |
!Workspace methodsFor:'event handling'! |
3712 | 1168 |
|
0 | 1169 |
keyPress:key x:x y:y |
3712 | 1170 |
<resource: #keyboard (#DoIt #InspectIt #PrintIt #ReplaceIt #BrowseIt #ExpandIt)> |
60 | 1171 |
|
3800 | 1172 |
(key == #DoIt) ifTrue:[self doIt. ^ self]. |
1173 |
(key == #InspectIt) ifTrue:[self inspectIt. ^ self]. |
|
1174 |
(key == #PrintIt) ifTrue:[self printIt. ^ self]. |
|
1175 |
(key == #ReplaceIt) ifTrue:[self replaceIt. ^ self]. |
|
1176 |
(key == #BrowseIt) ifTrue:[self browseIt. ^ self]. |
|
1177 |
(key == #ImplementorsOfIt) ifTrue:[self browseImplementorsOfIt. ^ self]. |
|
1178 |
(key == #ExpandAbbreviation) ifTrue:[self expandAbbreviation. ^ self]. |
|
38 | 1179 |
|
0 | 1180 |
super keyPress:key x:x y:y |
3511 | 1181 |
|
1182 |
"Modified: / 08-11-2007 / 11:29:45 / cg" |
|
0 | 1183 |
! ! |
201 | 1184 |
|
2143 | 1185 |
!Workspace methodsFor:'executing'! |
201 | 1186 |
|
1501 | 1187 |
do:code withValueDo:aBlock |
418 | 1188 |
"helper for doIt, printIt and inspectIt. |
1189 |
Evaluate the selection and, if all went well, evaluate the argument, |
|
1190 |
aBlock with the value. |
|
1191 |
Most work is in preparing for proper cleanup in case of abort |
|
1192 |
or other exception while the evaluation is performed. |
|
1193 |
(restore cursor, selectionColors etc.)" |
|
201 | 1194 |
|
4149 | 1195 |
|selLine selCol endLine endCol cLine cCol cleanUp executeBlock| |
201 | 1196 |
|
1197 |
code notNil ifTrue:[ |
|
2409 | 1198 |
code asString withoutSeparators isEmpty ifTrue:[ ^ self ]. |
2408 | 1199 |
|
257 | 1200 |
codeStartPosition := self characterPositionOfSelection. |
201 | 1201 |
|
257 | 1202 |
" |
1203 |
remember selection for later - if there is an error, |
|
1204 |
the notification method will highlight it. |
|
1205 |
thus destroying the current selection |
|
1206 |
" |
|
1207 |
selLine := selectionStartLine. |
|
1208 |
selCol := selectionStartCol. |
|
1209 |
endLine := selectionEndLine. |
|
1210 |
endCol := selectionEndCol. |
|
1211 |
cCol := cursorCol. |
|
1212 |
cLine := cursorLine. |
|
201 | 1213 |
|
257 | 1214 |
" |
1215 |
cleanup: restore previous selection and cursor positions |
|
1216 |
" |
|
1217 |
cleanUp := [ |
|
1218 |
self selectFromLine:selLine col:selCol toLine:endLine col:endCol. |
|
1219 |
cLine notNil ifTrue:[ |
|
1220 |
self cursorLine:cLine col:cCol |
|
1221 |
]. |
|
1222 |
]. |
|
201 | 1223 |
|
257 | 1224 |
" |
1225 |
perform the action. |
|
1226 |
Be careful to release the reference to the value; |
|
1227 |
otherwise, we could keep lots of garbage from being freed |
|
1228 |
until the view gets closed |
|
1229 |
" |
|
4149 | 1230 |
executeBlock := [ |
1231 |
[ |
|
1232 |
AbortOperationRequest handle:[:ex | |
|
1233 |
"/ aBlock value:'** Abortsignal cought **'. |
|
1234 |
ex return |
|
1235 |
] do:[ |
|
1236 |
|value| |
|
929 | 1237 |
|
4149 | 1238 |
doItAction notNil ifTrue:[ |
1239 |
value := doItAction value:(code asString). |
|
1240 |
cleanUp value. cleanUp := nil. |
|
1241 |
aBlock notNil ifTrue:[ |
|
1242 |
aBlock value:value. |
|
1243 |
]. |
|
1244 |
value := nil. |
|
1245 |
self class rememberDoIt:code. |
|
1246 |
] |
|
257 | 1247 |
] |
4149 | 1248 |
] ensure:[ |
1249 |
cleanUp notNil ifTrue:[ |
|
1250 |
cleanUp value. cleanUp := nil |
|
1251 |
]. |
|
257 | 1252 |
] |
4149 | 1253 |
]. |
1254 |
aBlock isNil ifTrue:[ |
|
1255 |
"no action is performed with the result - give the user a visible |
|
1256 |
feedback, that something has been done" |
|
1257 |
self topView withVisibleCursor:Cursor execute do:executeBlock. |
|
1258 |
] ifFalse:[ |
|
1259 |
self topView withCursor:Cursor execute do:executeBlock. |
|
257 | 1260 |
]. |
201 | 1261 |
] |
257 | 1262 |
|
1501 | 1263 |
"Modified: / 22.4.1998 / 21:56:13 / ca" |
1264 |
"Created: / 22.4.1998 / 21:57:05 / ca" |
|
2409 | 1265 |
"Modified: / 26.9.2001 / 17:32:59 / cg" |
201 | 1266 |
! ! |
1267 |
||
2751 | 1268 |
!Workspace methodsFor:'initialization & release'! |
201 | 1269 |
|
2733 | 1270 |
doItAction:aOneArgBlock |
1271 |
"define the action to be performed when 'doIt' is selected. |
|
1272 |
The block will be evaluated, passing the selection as a String argument. |
|
1273 |
A default doItAction is set for you in the initialize method." |
|
1274 |
||
1275 |
doItAction := aOneArgBlock |
|
1276 |
||
1277 |
"Modified: 27.2.1996 / 15:31:37 / cg" |
|
1278 |
! |
|
1279 |
||
1280 |
executeDoIt:theCode |
|
3537 | 1281 |
^ (self compilerClass new) moreSharedPools:poolsConsideredInDoIts; |
2733 | 1282 |
evaluate:theCode |
1283 |
in:nil |
|
1284 |
receiver:simulatedSelf |
|
1285 |
notifying:self |
|
1286 |
logged:true |
|
1287 |
ifFail:nil |
|
1288 |
! |
|
1289 |
||
201 | 1290 |
initStyle |
966 | 1291 |
"setup viewStyle specifics" |
1292 |
||
201 | 1293 |
super initStyle. |
1294 |
||
2492
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1295 |
DefaultViewBackground notNil ifTrue:[ |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1296 |
viewBackground := DefaultViewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1297 |
self backgroundColor:viewBackground. |
740174c1be0f
allow separate bg-color from styleSheet
Claus Gittinger <cg@exept.de>
parents:
2489
diff
changeset
|
1298 |
]. |
201 | 1299 |
! |
1300 |
||
1301 |
initialize |
|
1302 |
super initialize. |
|
1303 |
||
2775 | 1304 |
scrollWhenUpdating := #beginOfText. |
201 | 1305 |
showMatchingParenthesis := true. |
3428 | 1306 |
allowValueDrop := true. |
1307 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1308 |
commentStrings := #( |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1309 |
'"/' |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1310 |
('"' '"') |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1311 |
). |
201 | 1312 |
|
1313 |
self initializeDoITAction. |
|
3396 | 1314 |
self initializeDragAndDrop. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1315 |
|
3428 | 1316 |
"Modified: / 28-11-2006 / 16:11:55 / cg" |
201 | 1317 |
! |
1318 |
||
1319 |
initializeDoITAction |
|
1320 |
"set up the block to be evaluated for doIts. |
|
1321 |
This is done here in a separate method to allow easier |
|
1322 |
redefinition in subclasses" |
|
1323 |
||
2733 | 1324 |
doItAction := [:theCode | self executeDoIt:theCode]. |
3396 | 1325 |
! |
1326 |
||
1327 |
initializeDragAndDrop |
|
1328 |
|target| |
|
1329 |
||
1330 |
target := DropTarget |
|
1331 |
receiver:self |
|
1332 |
argument:nil |
|
3411 | 1333 |
dropSelector:#drop: |
3396 | 1334 |
canDropSelector:#canDrop:. |
1335 |
self dropTarget:target |
|
1336 |
||
1337 |
"Created: / 16-08-2005 / 22:03:36 / janfrog" |
|
3411 | 1338 |
"Modified: / 13-10-2006 / 12:37:18 / cg" |
201 | 1339 |
! ! |
1340 |
||
418 | 1341 |
!Workspace methodsFor:'menu & menu actions'! |
1342 |
||
2285 | 1343 |
browseClass |
1344 |
"user selected 'browseClass' from menu; evaluate the code |
|
1345 |
and open a browser on the resulting class (if it evaluates to one)" |
|
1346 |
||
1347 |
^ self |
|
3272 | 1348 |
do:(self selectionAsString) |
3910 | 1349 |
withValueDo:[:result | |
1350 |
result isBehavior ifTrue:[ |
|
1351 |
result browserClass openInClass:result selector:nil |
|
1352 |
] ifFalse:[ |
|
1353 |
self warn:'Selection does not evaluate to a class' |
|
1354 |
] |
|
1355 |
]. |
|
2285 | 1356 |
|
2410 | 1357 |
"Modified: / 26.9.2001 / 17:37:35 / cg" |
2285 | 1358 |
! |
1359 |
||
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1360 |
browseImplementorsOfIt |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1361 |
"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
|
1362 |
|
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1363 |
|selectedText selector browserClass na| |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1364 |
|
2714 | 1365 |
selectedText := self selectionAsString. |
1366 |
selectedText size > 0 ifTrue:[ |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1367 |
self windowGroup withWaitCursorDo:[ |
3895
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1368 |
"/ 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
|
1369 |
(compilerClass notNil and:[compilerClass includesBehavior:JavaScriptParser]) ifTrue:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1370 |
"/ selector is in one piece anyway |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1371 |
(selectedText includes:$_) ifFalse:[ |
3896 | 1372 |
"/ 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
|
1373 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:1. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1374 |
selectedText := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:0. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1375 |
] ifTrue:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1376 |
"/ count _#s plus one arg - sigh |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1377 |
na := (selectedText occurrencesOf:$_) + 1. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1378 |
selector := JavaScriptParser basicNew translatedSmalltalkSelectorFor:selectedText numArgs:na |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1379 |
]. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1380 |
] ifFalse:[ |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1381 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
77476b56175b
browse-implementors also for javaScript
Claus Gittinger <cg@exept.de>
parents:
3887
diff
changeset
|
1382 |
]. |
2714 | 1383 |
browserClass := UserPreferences current systemBrowserClass. |
1384 |
||
3287 | 1385 |
(selector notNil and:[selector ~= selectedText]) ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1386 |
(SystemBrowser |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1387 |
findImplementorsOfAny:(Array with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1388 |
in:(Smalltalk allClasses) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1389 |
ignoreCase:false) isEmpty ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1390 |
browserClass browseImplementorsOf:selector |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1391 |
] ifFalse:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1392 |
browserClass browseImplementorsOfAny:(Set with:selector with:selectedText) |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1393 |
]. |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1394 |
] ifFalse:[ |
2714 | 1395 |
browserClass browseImplementorsOf:(selector ? selectedText) |
2534
55df9165ddd7
findImplementorsOfAny if in doubt
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
1396 |
] |
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1397 |
] |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1398 |
]. |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1399 |
|
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1400 |
"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
|
1401 |
"Modified: / 19.11.2001 / 22:15:17 / cg" |
2451
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1402 |
! |
ae246b6c4df7
added browse implementors menu item
Claus Gittinger <cg@exept.de>
parents:
2440
diff
changeset
|
1403 |
|
2307 | 1404 |
browseIt |
1405 |
"evaluate the code and open a browser on the resulting class (if it evaluates to one), |
|
2713 | 1406 |
or the class of the resulting object (if it does not evaluate to a class). |
1407 |
||
1408 |
Added feature: if selection is of the form class >> selector, immediately switch to that selector." |
|
1409 |
||
3910 | 1410 |
|codeToEvaluate idx selector evaluatedValue classToBrowse| |
2713 | 1411 |
|
3596 | 1412 |
codeToEvaluate := (self selectionOrTextOfCursorLine ? '') withoutSeparators. |
2713 | 1413 |
idx := codeToEvaluate indexOfSubCollection:'>>'. |
1414 |
idx ~~ 0 ifTrue:[ |
|
2717 | 1415 |
selector := (codeToEvaluate copyFrom:idx+2) withoutSeparators string. |
3155 | 1416 |
(selector startsWith:'#') ifTrue:[ |
1417 |
selector := Symbol readFrom:selector. |
|
1418 |
]. |
|
2713 | 1419 |
codeToEvaluate := codeToEvaluate copyTo:idx-1. |
1420 |
]. |
|
2307 | 1421 |
|
3910 | 1422 |
Parser parseErrorSignal handle:[:ex | |
1423 |
|className| |
|
2410 | 1424 |
|
3910 | 1425 |
"/ fallback, if garbage is selected, look for matching classes. |
1426 |
className := SystemBrowser |
|
1427 |
askForClassNameMatching:codeToEvaluate |
|
1428 |
inEnvironment:nil |
|
1429 |
for:nil. |
|
1430 |
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
|
1431 |
classToBrowse := Smalltalk classNamed:className. |
3910 | 1432 |
] do:[ |
1433 |
self |
|
1434 |
do:codeToEvaluate |
|
4057
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1435 |
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
|
1436 |
|
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1437 |
evaluatedValue isNil ifTrue:[ |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1438 |
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
|
1439 |
codeToEvaluate isUppercaseFirst ifTrue:[ |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1440 |
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
|
1441 |
^ self. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1442 |
]. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1443 |
] |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1444 |
]. |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1445 |
classToBrowse := evaluatedValue isBehavior |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1446 |
ifTrue:[ evaluatedValue ] |
314415319f37
fixed: #browseIt when selected name was not a valid class name
Claus Gittinger <cg@exept.de>
parents:
3968
diff
changeset
|
1447 |
ifFalse:[ evaluatedValue class ]. |
3910 | 1448 |
]. |
1449 |
||
1450 |
classToBrowse browserClass openInClass:classToBrowse selector:selector |
|
2307 | 1451 |
! |
1452 |
||
2285 | 1453 |
browseItsClass |
1454 |
"user selected 'browseItsClass' from menu; evaluate the code |
|
1455 |
and open a browser on the results class" |
|
1456 |
||
1457 |
^ self |
|
3272 | 1458 |
do:(self selectionAsString) |
2410 | 1459 |
withValueDo:[:result | |
1460 |
result class browserClass openInClass:result class selector:nil |
|
1461 |
] |
|
2285 | 1462 |
|
2410 | 1463 |
"Modified: / 26.9.2001 / 17:38:06 / cg" |
2285 | 1464 |
! |
1465 |
||
2454 | 1466 |
browseReferencesToIt |
1467 |
"open a browser on all references to the selected global" |
|
1468 |
||
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1469 |
|sel| |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1470 |
|
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1471 |
sel := self selectionAsString. |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1472 |
sel size > 0 ifTrue:[ |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1473 |
self windowGroup withWaitCursorDo:[ |
3959 | 1474 |
(Smalltalk includesKey:sel asSymbol) ifFalse:[ |
1475 |
sel := ((NameSpace allNameSpaces detect:[:ns | ns includesKey:sel asSymbol]) at:sel asSymbol) name. |
|
1476 |
]. |
|
2457
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1477 |
(UserPreferences current systemBrowserClass) |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1478 |
browseReferendsOf:sel |
0c1beddda9cb
disable menu items; check for nothing selected
Claus Gittinger <cg@exept.de>
parents:
2454
diff
changeset
|
1479 |
]. |
2454 | 1480 |
]. |
1481 |
||
1482 |
"Created: / 5.11.2001 / 17:32:23 / cg" |
|
1483 |
"Modified: / 5.11.2001 / 17:32:38 / cg" |
|
1484 |
! |
|
1485 |
||
2462 | 1486 |
browseSendersOfIt |
1487 |
"open a browser on the senders of the selected text" |
|
1488 |
||
2715 | 1489 |
|selectedText selector| |
2462 | 1490 |
|
2715 | 1491 |
selectedText := self selectionAsString. |
1492 |
selectedText size > 0 ifTrue:[ |
|
2462 | 1493 |
self windowGroup withWaitCursorDo:[ |
3287 | 1494 |
selector := SystemBrowser extractSelectorFrom:selectedText. |
2462 | 1495 |
(UserPreferences current systemBrowserClass) |
2715 | 1496 |
browseAllCallsOn:(selector ? selectedText) |
2462 | 1497 |
] |
1498 |
]. |
|
1499 |
||
1500 |
"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
|
1501 |
"Modified: / 19.11.2001 / 22:15:27 / cg" |
2462 | 1502 |
! |
1503 |
||
418 | 1504 |
doIt |
1505 |
"user selected 'doIt' from menu; show a wait-cursor, evaluate the code |
|
1506 |
and finally restore cursor; return result of evaluation" |
|
1507 |
||
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1508 |
^ self |
3272 | 1509 |
do:(self selectionOrTextOfCursorLine) |
4149 | 1510 |
withValueDo:nil |
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1511 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1512 |
"Modified: / 16.5.1998 / 16:45:01 / cg" |
418 | 1513 |
! |
1514 |
||
1515 |
editMenu |
|
1107 | 1516 |
"return my popUpMenu; thats the superclasses menu |
1517 |
PLUS st-evaluation items: doIt, printIt and inspectIt." |
|
1518 |
||
2459 | 1519 |
<resource: #keyboard (#DoIt #PrintIt #InspectIt |
1520 |
#CommentSelection #UncommentSelection |
|
2573
52c995a1ea78
accelerators for browseIt and implementorsOfIt
Claus Gittinger <cg@exept.de>
parents:
2571
diff
changeset
|
1521 |
#BrowseIt #ImplementorsOfIt |
2459 | 1522 |
)> |
1262
d69149b5be1f
resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents:
1251
diff
changeset
|
1523 |
<resource: #programMenu> |
489 | 1524 |
|
2867 | 1525 |
|m sub subsub idx sensor s s2| |
418 | 1526 |
|
1527 |
m := super editMenu. |
|
3252 | 1528 |
((sensor := self sensor) notNil and:[sensor ctrlDown and:[sensor shiftDown not]]) ifTrue:[ |
2459 | 1529 |
sub := m. |
1530 |
m := nil. |
|
1531 |
] ifFalse:[ |
|
1532 |
sub := m subMenuAt:#others. |
|
1533 |
]. |
|
418 | 1534 |
|
2459 | 1535 |
sub notNil ifTrue:[ |
2867 | 1536 |
|
2459 | 1537 |
" |
2867 | 1538 |
workspaces support #browse, implementors etc. add them after paste. |
2459 | 1539 |
" |
2867 | 1540 |
sub |
1541 |
addItemList:#( |
|
1542 |
('-' ) |
|
3910 | 1543 |
('Browse' browseIt BrowseIt ) |
1544 |
('Senders of It' browseSendersOfIt ) |
|
1545 |
('Implementors of It' browseImplementorsOfIt ImplementorsOfIt ) |
|
1546 |
('References to It' browseReferencesToIt ) |
|
1547 |
"/ ('Classes Containing It in Name' browseClassesContainingItInName ) |
|
1548 |
"/ ('Methods Contaníning It in Name' browseMethodsContainingItInName ) |
|
1549 |
"/ ('Methods Contaníning It in Source' browseMethodsContainingItInSource ) |
|
2867 | 1550 |
('-' ) |
1551 |
('TimeIt' timeIt ) |
|
1552 |
('SpyOnIt' spyOnIt )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1553 |
resources:resources |
2459 | 1554 |
after:#gotoLine. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1555 |
|
2867 | 1556 |
subsub := sub subMenuAt:#tools. |
1557 |
subsub notNil ifTrue:[ |
|
1558 |
subsub |
|
1559 |
addItemList:#( |
|
1560 |
('-' ) |
|
1561 |
('Comment' commentSelection CommentSelection ) |
|
1562 |
('Uncomment' uncommentSelection UncommentSelection )) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1563 |
resources:resources |
2867 | 1564 |
after:#'indent'. |
1565 |
]. |
|
1566 |
||
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1567 |
self hasSelection ifFalse:[ |
3272 | 1568 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt browseReferencesToIt timeIt spyOnIt |
1569 |
commentSelection uncommentSelection ) |
|
2454 | 1570 |
] ifTrue:[ |
1571 |
s := self selectionAsString. |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1572 |
s notNil ifTrue:[ |
3579
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1573 |
s asSymbolIfInterned isNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1574 |
s2 := SystemBrowser extractSelectorFrom:s. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1575 |
s2 notNil ifTrue:[ |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1576 |
s2 := s2 asSymbolIfInterned. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1577 |
]. |
3923810267b6
better implementorsOf selector extraction
Claus Gittinger <cg@exept.de>
parents:
3543
diff
changeset
|
1578 |
]. |
2454 | 1579 |
]. |
2487
47e0a1faf544
disabling of impl/senders menu
Claus Gittinger <cg@exept.de>
parents:
2485
diff
changeset
|
1580 |
(s2 isNil and:[s isNil]) ifTrue:[ |
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1581 |
sub disableAll:#(browseImplementorsOfIt browseSendersOfIt). |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1582 |
]. |
3959 | 1583 |
"/ a global or namespace-var selected ? |
1584 |
(s notNil |
|
1585 |
and:[s asSymbolIfInterned notNil |
|
1586 |
and:[ (Smalltalk includesKey:s asSymbol) |
|
1587 |
or:[ (NameSpace allNameSpaces contains:[:ns | ns includesKey:s asSymbol]) ]]]) |
|
1588 |
ifFalse:[ |
|
2485
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1589 |
sub disable:#browseReferencesToIt. |
1e4ab722cb11
browse senders/implementors: better selector check
Claus Gittinger <cg@exept.de>
parents:
2477
diff
changeset
|
1590 |
]. |
2595 | 1591 |
self isReadOnly ifTrue:[ |
2641 | 1592 |
sub disableAll:#(commentSelection uncommentSelection) |
2595 | 1593 |
]. |
1395
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1594 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1595 |
]. |
cbadcf93c173
moved comment stuff from CodeView to here.
Claus Gittinger <cg@exept.de>
parents:
1354
diff
changeset
|
1596 |
|
2459 | 1597 |
m notNil ifTrue:[ |
1598 |
" |
|
1599 |
workspaces support #doIt, #printIt and #inspectIt |
|
1600 |
add them after paste. |
|
1601 |
" |
|
1602 |
idx := m indexOf:#paste. |
|
1603 |
idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace]. |
|
1604 |
idx ~~ 0 ifTrue:[ |
|
2867 | 1605 |
m |
1606 |
addItemList:#( |
|
1607 |
('-' ) |
|
1608 |
('DoIt' doIt DoIt ) |
|
1609 |
('PrintIt' printIt PrintIt ) |
|
1610 |
('InspectIt' inspectIt InspectIt)) |
|
2922
70e3f3ec7980
oops - doIt and friends were not translated
Claus Gittinger <cg@exept.de>
parents:
2893
diff
changeset
|
1611 |
resources:resources |
2459 | 1612 |
after:idx. |
1613 |
||
1614 |
]. |
|
1615 |
||
3279
087a9e32c714
oops - autoselect for doIt was done too early
Claus Gittinger <cg@exept.de>
parents:
3272
diff
changeset
|
1616 |
(self hasSelectionOrTextInCursorLine) ifFalse:[ |
3272 | 1617 |
|lNr line| |
1618 |
||
1619 |
lNr := self cursorLine. |
|
1620 |
line := self listAt:lNr. |
|
1621 |
line isEmptyOrNil ifTrue:[ |
|
1622 |
m disableAll:#(printIt doIt inspectIt browseIt) |
|
1623 |
]. |
|
2459 | 1624 |
]. |
2595 | 1625 |
self isReadOnly ifTrue:[ |
1626 |
m disable:#printIt |
|
1627 |
]. |
|
418 | 1628 |
]. |
1629 |
||
2459 | 1630 |
^ m ? sub. |
430 | 1631 |
|
1501 | 1632 |
"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
|
1633 |
"Modified: / 19.11.2001 / 23:12:01 / cg" |
418 | 1634 |
! |
1635 |
||
1636 |
inspectIt |
|
1637 |
"user selected 'inspectIt' from menu; use doIt to evaluate the code |
|
1638 |
and start an inspector on the result" |
|
1639 |
||
2981
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1640 |
|shifted| |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1641 |
|
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1642 |
shifted := self sensor shiftDown. |
75abc5efbf67
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2980
diff
changeset
|
1643 |
|
1521
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1644 |
^ self |
3272 | 1645 |
do:(self selectionOrTextOfCursorLine) |
2982
9a831ab53acc
shift-inspect (= basicInspect)
Claus Gittinger <cg@exept.de>
parents:
2981
diff
changeset
|
1646 |
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
|
1647 |
|
e2bb7811e4db
removed useless intermediate invoke (looks better in debugView)
Claus Gittinger <cg@exept.de>
parents:
1516
diff
changeset
|
1648 |
"Modified: / 16.5.1998 / 16:44:56 / cg" |
418 | 1649 |
! |
1650 |
||
1651 |
printIt |
|
1652 |
"user selected 'printIt' from menu; use doIt to evaluate the code |
|
1653 |
and insert result of evaluation into my text. |
|
1654 |
If the text is readOnly, do nothing." |
|
1655 |
||
1734 | 1656 |
self isReadOnly ifTrue:[ |
3511 | 1657 |
self beep. |
1658 |
^ self. |
|
1659 |
]. |
|
1660 |
self |
|
1661 |
undoableDo:[ |
|
1662 |
self |
|
1663 |
do:(self selectionOrTextOfCursorLine) |
|
1664 |
withValueDo:[:result | |
|
1665 |
self cursorLine:selectionEndLine col:(selectionEndCol + 1). |
|
1666 |
self insertSelectedStringAtCursor:(result displayString "printString") |
|
1667 |
] |
|
1668 |
] |
|
1669 |
info:'PrintIt' |
|
1670 |
||
1671 |
"Modified: / 08-11-2007 / 11:35:31 / cg" |
|
1672 |
! |
|
418 | 1673 |
|
3511 | 1674 |
replaceIt |
1675 |
"like printIt, but replace the selection with the result, instead of |
|
1676 |
pasting it after the selection." |
|
1677 |
||
1678 |
self isReadOnly ifTrue:[ |
|
1679 |
self beep. |
|
1680 |
^ self |
|
1681 |
]. |
|
1682 |
||
1683 |
self |
|
1684 |
undoableDo:[ |
|
1685 |
self |
|
1686 |
do:(self selectionOrTextOfCursorLine) |
|
1687 |
withValueDo:[:result | |
|
1688 |
self replaceSelectionBy:(result displayString "printString") |
|
1689 |
]. |
|
1690 |
undoSupport actionInfo:'ReplaceIt'. |
|
1691 |
] |
|
1692 |
info:'ReplaceIt' |
|
1693 |
||
1694 |
"Created: / 08-11-2007 / 11:31:54 / cg" |
|
1501 | 1695 |
! |
1696 |
||
1697 |
spyOnIt |
|
1698 |
"user selected 'spyOnIt' from menu; show a wait-cursor, evaluate the code |
|
1699 |
and finally restore cursor; return result of evaluation" |
|
1700 |
||
1701 |
|code| |
|
1702 |
||
3511 | 1703 |
code := 'MessageTally spyDetailOn:[' , self selectionAsString, ']'. |
4149 | 1704 |
self do:code withValueDo:[:value| ]. |
1501 | 1705 |
|
3511 | 1706 |
"Modified: / 22-04-1998 / 22:03:53 / ca" |
1707 |
"Modified: / 08-11-2007 / 11:36:38 / cg" |
|
1501 | 1708 |
! |
1709 |
||
1710 |
timeIt |
|
1711 |
"user selected 'timeIt' from menu; show a wait-cursor, evaluate the code |
|
1712 |
and finally restore cursor; return result of evaluation" |
|
1713 |
||
1714 |
|code| |
|
1715 |
||
3272 | 1716 |
code := '|t| t := Time millisecondsToRun:[' , self selectionAsString, ']. |
4149 | 1717 |
Transcript showCR:''execution time: '' , t printString , '' ms''.'. |
1718 |
self do:code withValueDo:[:value | ]. |
|
1501 | 1719 |
|
1720 |
"Modified: / 22.4.1998 / 22:03:51 / ca" |
|
418 | 1721 |
! ! |
1722 |
||
3968
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1723 |
!Workspace methodsFor:'misc'! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1724 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1725 |
expandAbbreviation |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1726 |
"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
|
1727 |
cursor, find an abbrev for it and expand." |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1728 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1729 |
|expandedString abortExpandAction oldSelectionStartLine oldSelectionStartCol oldSelectionEndLine oldSelectionEndCol oldCursorLine oldCursorCol |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1730 |
newCursorPos replStartCol| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1731 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1732 |
oldCursorLine := self cursorLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1733 |
oldCursorCol := self cursorCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1734 |
oldSelectionStartLine := self selectionStartLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1735 |
oldSelectionStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1736 |
oldSelectionEndLine := self selectionEndLine. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1737 |
oldSelectionEndCol := self selectionEndCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1738 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1739 |
abortExpandAction := [ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1740 |
self selectFromLine:oldSelectionStartLine |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1741 |
col:oldSelectionStartCol |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1742 |
toLine:oldSelectionEndLine |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1743 |
col:oldSelectionEndCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1744 |
self cursorLine: oldCursorLine col: oldCursorCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1745 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1746 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1747 |
expandedString := self findAbbreviationKeyBeforeCursor. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1748 |
expandedString isNil ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1749 |
abortExpandAction value. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1750 |
^ self |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1751 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1752 |
newCursorPos := expandedString indexOf:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1753 |
newCursorPos ~~ 0 ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1754 |
expandedString := expandedString copyWithout:$!!. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1755 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1756 |
replStartCol := self selectionStartCol. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1757 |
self |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1758 |
undoableDo:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1759 |
self replaceSelectionWith: expandedString] |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1760 |
info:'Replace'. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1761 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1762 |
newCursorPos == 0 ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1763 |
"/ cursor already fine (at the end) |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1764 |
] ifFalse:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1765 |
self cursorCol:replStartCol+newCursorPos-1 |
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 |
! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1768 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1769 |
findAbbreviationKeyBeforeCursor |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1770 |
"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
|
1771 |
cursor, find an abbrev for it and expand." |
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 |
|sniplets keys minMax maxKeyLen minKeyLen line stringBeforeCursor| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1774 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1775 |
sniplets := self class sniplets. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1776 |
keys := sniplets keys. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1777 |
minMax := (keys collect:[:k | k size]) minMax. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1778 |
minKeyLen := minMax first. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1779 |
maxKeyLen := minMax second. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1780 |
line := (self at:cursorLine) ? ''. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1781 |
stringBeforeCursor := line string copyTo:((cursorCol-1) min:line size). |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1782 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1783 |
maxKeyLen := maxKeyLen min:stringBeforeCursor size. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1784 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1785 |
(maxKeyLen to:minKeyLen by:-1) do:[:l | |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1786 |
|lCharactersBeforeCursor expandedString| |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1787 |
|
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1788 |
lCharactersBeforeCursor := stringBeforeCursor last:l. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1789 |
expandedString := sniplets at:lCharactersBeforeCursor ifAbsent:nil. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1790 |
expandedString notNil ifTrue:[ |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1791 |
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
|
1792 |
^ expandedString |
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 |
]. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1795 |
^ nil. |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1796 |
! ! |
37af1e95c4b4
category and comment changes
Claus Gittinger <cg@exept.de>
parents:
3959
diff
changeset
|
1797 |
|
2646 | 1798 |
!Workspace methodsFor:'queries'! |
1799 |
||
1800 |
isWorkspace |
|
1801 |
^ true |
|
1802 |
! ! |
|
1803 |
||
206 | 1804 |
!Workspace class methodsFor:'documentation'! |
1805 |
||
1806 |
version |
|
4172
432d4d3f5717
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4171
diff
changeset
|
1807 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.222 2010-10-13 10:00:40 cg Exp $' |
3959 | 1808 |
! |
1809 |
||
1810 |
version_CVS |
|
4172
432d4d3f5717
changed: #initializeDefaultAbbreviations
Claus Gittinger <cg@exept.de>
parents:
4171
diff
changeset
|
1811 |
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.222 2010-10-13 10:00:40 cg Exp $' |
858 | 1812 |
! ! |