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