author | Claus Gittinger <cg@exept.de> |
Thu, 20 Nov 2008 23:15:14 +0100 | |
changeset 11354 | 618eaa4e2a32 |
parent 11353 | 6167f1e604c9 |
child 11355 | 2aa83c61ebd4 |
permissions | -rw-r--r-- |
9944 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
" |
|
12 |
"{ Package: 'stx:libbasic' }" |
|
13 |
||
14 |
Object subclass:#StandaloneStartup |
|
15 |
instanceVariableNames:'' |
|
10772 | 16 |
classVariableNames:'Verbose CommandLineArguments' |
9944 | 17 |
poolDictionaries:'' |
18 |
category:'System-Support' |
|
19 |
! |
|
20 |
||
11102 | 21 |
StandaloneStartup class instanceVariableNames:'MutexHandle' |
22 |
||
23 |
" |
|
24 |
No other class instance variables are inherited by this class. |
|
25 |
" |
|
26 |
! |
|
27 |
||
9944 | 28 |
!StandaloneStartup class methodsFor:'documentation'! |
29 |
||
30 |
copyright |
|
31 |
" |
|
32 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
33 |
All Rights Reserved |
|
34 |
||
35 |
This software is furnished under a license and may be used |
|
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
43 |
||
44 |
documentation |
|
45 |
" |
|
46 |
a subclassable template class for a standalone GUI-application's startup; |
|
47 |
For your own stand alone programs, define a subclass of this, |
|
48 |
and redefine the #main method there. |
|
49 |
(of course, the other methods can also be redefined.) |
|
50 |
||
51 |
[author:] |
|
52 |
Claus Gittinger |
|
53 |
||
54 |
[start with:] |
|
55 |
<yourNamehere>Startup start |
|
10886 | 56 |
|
57 |
[see also:] |
|
58 |
Smalltalk |
|
59 |
GetOpt |
|
60 |
ReadEvalPrintLoop |
|
9944 | 61 |
" |
11102 | 62 |
! |
63 |
||
64 |
howToDealWithMultipleApplicationInstances |
|
65 |
" |
|
66 |
please read the comment in the corresponding ApplicationModel class-documentation method. |
|
67 |
" |
|
11352 | 68 |
! |
69 |
||
70 |
whichMethodsToRedefine |
|
71 |
" |
|
72 |
main:argv |
|
73 |
thats the actual program. |
|
74 |
||
75 |
suppressRCFileReading |
|
76 |
false here; redefine to return true, to disable the rc-file reading. |
|
77 |
you loose the chance of configuration, but lock the user out from any access to any smalltalk |
|
78 |
(if you have a user-phobia) |
|
79 |
||
80 |
allowDebugOption |
|
81 |
true here; redefine to return false, to disable the --debug startup option. |
|
82 |
you loose the chance of debugging, but lock the user out from any access to any smalltalk |
|
83 |
||
84 |
allowScriptingOption |
|
85 |
true here; redefine to return false, to disable the --scripting startup option. |
|
86 |
you loose the chance of remote control, but lock the user out from any access to any smalltalk |
|
87 |
||
88 |
" |
|
9944 | 89 |
! ! |
90 |
||
91 |
!StandaloneStartup class methodsFor:'initialization'! |
|
92 |
||
93 |
initialize |
|
11354 | 94 |
Verbose := true. |
9944 | 95 |
Verbose := false. |
96 |
! ! |
|
97 |
||
98 |
!StandaloneStartup class methodsFor:'helpers'! |
|
99 |
||
100 |
redirectStandardStreams |
|
101 |
Stdout := Stderr. |
|
102 |
Transcript := Stderr. |
|
103 |
! |
|
104 |
||
105 |
verboseInfo:msg |
|
106 |
Verbose == true ifFalse:[^ self]. |
|
107 |
||
108 |
Transcript |
|
109 |
show:('%1 [info]: ' bindWith:(self applicationName)); |
|
110 |
showCR:msg |
|
111 |
||
112 |
"Modified: / 19-09-2006 / 16:30:27 / cg" |
|
113 |
! ! |
|
114 |
||
11102 | 115 |
!StandaloneStartup class methodsFor:'multiple applications support'! |
116 |
||
117 |
applicationRegistryPath |
|
118 |
"the key under which this application stores its process ID in the registry |
|
119 |
as a collection of path-components. |
|
120 |
i.e. if #('foo' 'bar' 'baz') is returned here, the current applications ID will be stored |
|
121 |
in HKEY_CURRENT_USER\Software\foo\bar\baz\CurrentID. |
|
122 |
(would also be used as a relative path for a temporary lock file under unix). |
|
123 |
Used to detect if another instance of this application is already running." |
|
124 |
||
125 |
self subclassResponsibility |
|
126 |
! |
|
127 |
||
128 |
applicationUUID |
|
129 |
"answer an application-specific unique uuid. |
|
130 |
This is used as the name of some exclusive OS-resource, which is used to find out, |
|
131 |
if another instance of this application is already running. |
|
132 |
Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used." |
|
133 |
||
134 |
self subclassResponsibility |
|
135 |
! |
|
136 |
||
137 |
checkForAndExitIfAnotherApplicationInstanceIsRunning |
|
138 |
"if another instance of this application is running, |
|
139 |
send it an openFile command for my file-argument, and exit. |
|
140 |
(i.e. to let the already running application open up another window)." |
|
141 |
||
142 |
|shouldExit| |
|
143 |
||
144 |
self isAnotherApplicationInstanceRunning ifTrue:[ |
|
145 |
shouldExit := self processStartupOfASecondInstance. |
|
146 |
shouldExit ifTrue:[ |
|
147 |
self releaseApplicationMutex. |
|
148 |
Smalltalk isStandAloneApp ifTrue:[ |
|
149 |
Smalltalk exit. |
|
150 |
] |
|
151 |
]. |
|
152 |
]. |
|
153 |
! ! |
|
154 |
||
155 |
!StandaloneStartup class methodsFor:'multiple applications support-helpers'! |
|
156 |
||
157 |
applicationRegistryEntry |
|
158 |
"retrieve the registry entry in which (if present), any currently running application |
|
159 |
has left its process ID" |
|
160 |
||
161 |
|path relPathName applicationEntry softwareEntry| |
|
162 |
||
163 |
path := self applicationRegistryPath. |
|
164 |
relPathName := path asStringWith:$\. |
|
165 |
applicationEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\',relPathName. |
|
166 |
applicationEntry isNil ifTrue:[ |
|
167 |
softwareEntry := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software'. |
|
168 |
softwareEntry isNil ifTrue:[ |
|
169 |
Transcript showCR: 'Failed to get Software entry in registry'. |
|
170 |
^ nil. |
|
171 |
]. |
|
11103 | 172 |
|
11102 | 173 |
path do:[:subKey | |
174 |
|subEntry| |
|
175 |
||
11103 | 176 |
subEntry := softwareEntry createSubKeyNamed:subKey. |
11102 | 177 |
subEntry isNil ifTrue:[ |
178 |
Transcript showCR: 'Failed to create ',subKey,' entry in registry'. |
|
179 |
^ nil. |
|
180 |
]. |
|
181 |
softwareEntry := subEntry. |
|
182 |
]. |
|
183 |
applicationEntry := softwareEntry. |
|
184 |
]. |
|
185 |
^ applicationEntry |
|
186 |
! |
|
187 |
||
11107 | 188 |
confirmOpenNewApplicationInstance |
189 |
||
190 |
^ Dialog confirm: ('Continue opening a new instance of %1 or exit?' bindWith:self applicationName) |
|
191 |
title: ('%1 is already open!!' bindWith:self applicationName) |
|
192 |
yesLabel: 'Continue' |
|
193 |
noLabel: 'Exit' |
|
194 |
! |
|
195 |
||
11102 | 196 |
currentIDKeyInRegistry |
197 |
^ 'CurrentID' |
|
198 |
! |
|
199 |
||
200 |
getCurrentIDFromRegistry |
|
201 |
||
202 |
|applicationEntry| |
|
203 |
||
204 |
applicationEntry := self applicationRegistryEntry. |
|
205 |
applicationEntry isNil ifTrue:[^ nil.]. |
|
206 |
^ applicationEntry valueNamed: self currentIDKeyInRegistry |
|
207 |
||
208 |
" |
|
209 |
|hWnd externalAddress| |
|
210 |
hWnd := DapasXStartup getCurrentIDFromRegistry. |
|
211 |
hWnd isEmptyOrNil ifTrue:[^ self halt.]. |
|
212 |
hWnd := hWnd asInteger. |
|
213 |
externalAddress := ExternalAddress newAddress: hWnd. |
|
214 |
Display raiseWindow:externalAddress. |
|
215 |
Display setForegroundWindow:externalAddress |
|
216 |
" |
|
217 |
! |
|
218 |
||
219 |
getIDOfRunningApplicationFromRegistryEntry |
|
220 |
|applicationEntry| |
|
221 |
||
222 |
applicationEntry := self applicationRegistryEntry. |
|
223 |
applicationEntry isNil ifTrue:[^ nil.]. |
|
224 |
^ applicationEntry valueNamed: self currentIDKeyInRegistry |
|
225 |
! |
|
226 |
||
227 |
isAnotherApplicationInstanceRunning |
|
228 |
"answer true, if another instance of mzself is currently running. |
|
229 |
For now, it only works under win32, because it uses the underlying mutex mechanism." |
|
230 |
||
11106 | 231 |
| lastErrorCode alreadyExists handleAndLastErrorCode | |
11102 | 232 |
|
233 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
234 |
handleAndLastErrorCode := OperatingSystem createMutexNamed: (self applicationUUID printString). |
|
235 |
MutexHandle := handleAndLastErrorCode first. |
|
236 |
lastErrorCode := handleAndLastErrorCode second. |
|
237 |
"/ self assert: lastErrorCode == 0. |
|
238 |
alreadyExists := |
|
239 |
MutexHandle isNil |
|
240 |
or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS" |
|
241 |
or:[lastErrorCode == 5 "ERROR_ACCESS_DENIED"]]. |
|
242 |
||
243 |
alreadyExists ifFalse:[OperatingSystem waitForSingleObject: MutexHandle]. |
|
244 |
^ alreadyExists |
|
245 |
]. |
|
246 |
||
247 |
^ false. |
|
248 |
! |
|
249 |
||
250 |
processStartupOfASecondInstance |
|
251 |
"This is executed when I have been started as a second instance of an already running application. |
|
252 |
If I can get the currentID (i.e. windowID) of the first one and there is a command line argument with a file, |
|
253 |
send a message to the main window of the already running application, o ask it for another window. |
|
254 |
If the currentID is unknown, ask if the user wants to open a new instance of the application anyway. |
|
255 |
Return true if the first instance has been notified, and this second instance should exit." |
|
256 |
||
11107 | 257 |
|currentIDStringFromRegistry currentIDFromRegistry fileArg commands aWindowId setForegroundWindowSucceeded| |
11102 | 258 |
|
259 |
commands := Smalltalk commandLineArguments. |
|
260 |
||
261 |
currentIDStringFromRegistry := self getCurrentIDFromRegistry. |
|
262 |
||
263 |
"If the currentID is not found and there are arguments from the command line, |
|
264 |
we should wait in case of starting the first instance of the application |
|
265 |
with a multiple selection of files." |
|
266 |
(currentIDStringFromRegistry isEmptyOrNil and:[commands notEmptyOrNil]) ifTrue:[ |
|
267 |
Delay waitForSeconds: 2. |
|
268 |
]. |
|
269 |
||
270 |
currentIDStringFromRegistry := self getCurrentIDFromRegistry. |
|
271 |
currentIDStringFromRegistry isEmptyOrNil ifTrue:[ |
|
11107 | 272 |
^ self confirmOpenNewApplicationInstance not. |
11102 | 273 |
]. |
274 |
||
11107 | 275 |
currentIDFromRegistry := Integer readFrom:currentIDStringFromRegistry onError: 0. |
11102 | 276 |
|
277 |
"/ bring the other application to the foreground |
|
278 |
aWindowId := ExternalAddress newAddress: currentIDFromRegistry. |
|
11107 | 279 |
setForegroundWindowSucceeded := Display primSetForegroundWindow: aWindowId. |
280 |
setForegroundWindowSucceeded ifFalse:[^ self confirmOpenNewApplicationInstance not]. |
|
11102 | 281 |
|
282 |
"Autostart for associated extension" |
|
283 |
commands notEmpty ifTrue:[ |
|
284 |
fileArg := commands last asFilename. |
|
285 |
fileArg exists ifTrue:[ |
|
286 |
self sendOpenPathCommand:(fileArg pathName) toWindowId: aWindowId. |
|
287 |
]. |
|
288 |
]. |
|
289 |
^ true |
|
290 |
! |
|
291 |
||
292 |
releaseApplicationMutex |
|
293 |
||
294 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
295 |
MutexHandle notNil ifTrue:[ |
|
296 |
OperatingSystem releaseMutex: MutexHandle. |
|
297 |
OperatingSystem primCloseHandle: MutexHandle. |
|
298 |
]. |
|
299 |
]. |
|
300 |
! |
|
301 |
||
302 |
sendCommand:message toWindowId:aWindowId |
|
303 |
"use the event send mechanism to forward a command to the already running application" |
|
304 |
||
305 |
Display |
|
306 |
sendCopyDataString: message |
|
307 |
toWindowId: aWindowId. |
|
308 |
! |
|
309 |
||
310 |
sendOpenPathCommand:pathName toWindowId:aWindowId |
|
311 |
"use the event send mechanism to forward an open-Path command to the already running application" |
|
312 |
||
313 |
self sendCommand:('openPath:', pathName) toWindowId:aWindowId. |
|
314 |
! |
|
315 |
||
316 |
writeCurrentIDIntoRegistry: currentID |
|
317 |
||
11104 | 318 |
|applicationEntry currentIDEntry| |
11102 | 319 |
|
11104 | 320 |
applicationEntry := self applicationRegistryEntry. |
321 |
applicationEntry isNil ifTrue:[^ false.]. |
|
11102 | 322 |
|
11104 | 323 |
currentIDEntry := applicationEntry createSubKeyNamed:(self currentIDKeyInRegistry). |
11102 | 324 |
currentIDEntry isNil ifTrue:[ |
325 |
Transcript showCR: 'Failed to create CurrentID entry in registry'. |
|
326 |
^ false. |
|
327 |
]. |
|
328 |
||
11104 | 329 |
^ applicationEntry valueNamed:(self currentIDKeyInRegistry) put:(currentID printString). |
11102 | 330 |
|
331 |
" |
|
332 |
| currentID returnedCurrentID | |
|
333 |
currentID := 999. |
|
334 |
DapasXStartup writeCurrentIDIntoRegistry: currentID. |
|
335 |
returnedCurrentID := DapasXStartup getCurrentIDFromRegistry. |
|
336 |
self assert: currentID = returnedCurrentID asNumber. |
|
337 |
" |
|
338 |
! ! |
|
339 |
||
9944 | 340 |
!StandaloneStartup class methodsFor:'queries'! |
341 |
||
11352 | 342 |
allowDebugOption |
343 |
"enable/disable the --debug startup option. |
|
344 |
Can be redefined in subclasses to disable it" |
|
345 |
||
346 |
^ true |
|
347 |
! |
|
348 |
||
349 |
allowScriptingOption |
|
350 |
"enable/disable the --scripting startup option. |
|
351 |
Can be redefined in subclasses to disable it" |
|
352 |
||
353 |
^ true |
|
354 |
! |
|
355 |
||
9944 | 356 |
applicationName |
11352 | 357 |
"used in verbose messages - can/should be redefined in subclasses" |
9944 | 358 |
|
359 |
|nm| |
|
360 |
||
361 |
nm := self nameWithoutPrefix. |
|
362 |
(nm endsWith:'Startup') ifTrue:[ |
|
363 |
^ nm copyWithoutLast:('Startup' size). |
|
364 |
]. |
|
365 |
(nm endsWith:'Start') ifTrue:[ |
|
366 |
^ nm copyWithoutLast:('Start' size). |
|
367 |
]. |
|
368 |
^ nm |
|
369 |
||
370 |
"Created: / 19-09-2006 / 16:26:44 / cg" |
|
371 |
! |
|
372 |
||
10040
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
373 |
isBrowserStartable |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
374 |
"do not allow clicking on me in the browser" |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
375 |
|
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
376 |
^ false |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
377 |
|
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
378 |
"Created: / 06-10-2006 / 11:33:13 / cg" |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
379 |
! |
59d0c20b139f
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9944
diff
changeset
|
380 |
|
9944 | 381 |
startupFilename |
11352 | 382 |
"used in verbose messages - can/should be redefined in subclasses" |
9944 | 383 |
|
384 |
^ self applicationName asLowercase,'Start.rc' |
|
385 |
||
386 |
" |
|
11352 | 387 |
ExpeccoStartup startupFilename -> 'expecco.rc' |
9944 | 388 |
" |
389 |
||
390 |
"Created: / 19-09-2006 / 16:38:28 / cg" |
|
11352 | 391 |
! |
392 |
||
393 |
suppressRCFileReading |
|
394 |
"enable/disable the rc-file reading (and also the --rcFileName option). |
|
395 |
If suppressed, there is no chance to interfere with the startup. |
|
396 |
Can be redefined in subclasses to disable it" |
|
397 |
||
398 |
^ false |
|
9944 | 399 |
! ! |
400 |
||
401 |
!StandaloneStartup class methodsFor:'startup'! |
|
402 |
||
11055
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
403 |
loadPatch:fileName |
11056
e2c4a6e948b6
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
11055
diff
changeset
|
404 |
self verboseInfo:('loading patch: ',fileName baseName). |
11055
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
405 |
Smalltalk fileIn:fileName pathName. |
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
406 |
! |
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
407 |
|
9944 | 408 |
loadPatches |
10934 | 409 |
|patchesDir| |
9944 | 410 |
|
10934 | 411 |
patchesDir := OperatingSystem pathOfSTXExecutable asFilename directory construct:'patches'. |
412 |
(patchesDir exists and:[patchesDir isDirectory]) ifTrue:[ |
|
413 |
patchesDir directoryContents sort do:[:eachFile | |
|
11055
e600e19e2e7f
loadPatch extracted to be redefinable.
Claus Gittinger <cg@exept.de>
parents:
10956
diff
changeset
|
414 |
self loadPatch:(patchesDir construct:eachFile). |
9944 | 415 |
]. |
416 |
]. |
|
417 |
||
418 |
"Modified: / 19-09-2006 / 16:30:58 / cg" |
|
419 |
! |
|
420 |
||
421 |
setupSmalltalkFromArguments:argv |
|
11352 | 422 |
"handle common command line arguments: |
423 |
--help ............... print usage and exit |
|
424 |
--verbose (-V) ....... be verbose during startup |
|
425 |
--debug .............. enable debugger & inspector |
|
426 |
--rcFileName ......... define a startup rc-file |
|
427 |
--scripting portNr ... define a startup rc-file |
|
428 |
" |
|
429 |
||
430 |
|idx rcFilename nextArg debugging scripting portNr| |
|
9944 | 431 |
|
432 |
"/ Smalltalk beHeadless:true. |
|
433 |
"/ OperatingSystem disableSignal:(OperatingSystem sigHUP). |
|
434 |
"/ Smalltalk infoPrinting:true. |
|
435 |
||
436 |
(argv includes:'--help') ifTrue:[ |
|
437 |
self usage. |
|
438 |
AbortOperationRequest raise. |
|
439 |
]. |
|
440 |
||
441 |
idx := argv indexOfAny:#('--verbose' '-V'). |
|
442 |
idx ~~ 0 ifTrue:[ |
|
443 |
argv removeAtIndex:idx. |
|
444 |
Verbose := true. |
|
445 |
]. |
|
10773 | 446 |
self verboseInfo:('args: ',argv asArray printString). |
9944 | 447 |
|
11352 | 448 |
debugging := false. |
449 |
(self allowDebugOption) ifTrue:[ |
|
450 |
idx := argv indexOfAny:#('--debug'). |
|
451 |
idx ~~ 0 ifTrue:[ |
|
452 |
argv removeAtIndex:idx. |
|
453 |
debugging := true |
|
454 |
]. |
|
455 |
]. |
|
456 |
debugging ifTrue:[ |
|
9944 | 457 |
self setupToolsForDebug. |
458 |
] ifFalse:[ |
|
459 |
self setupToolsForNoDebug. |
|
460 |
]. |
|
461 |
||
11352 | 462 |
self suppressRCFileReading ifFalse:[ |
463 |
idx := argv indexOf:'--rcFileName'. |
|
464 |
idx ~~ 0 ifTrue:[ |
|
465 |
nextArg := argv at:(idx + 1) ifAbsent:nil. |
|
466 |
(nextArg notNil and:[ (nextArg startsWith:'-') not ]) ifTrue:[ |
|
467 |
rcFilename := nextArg. |
|
468 |
argv removeAtIndex:idx+1; removeAtIndex:idx. |
|
469 |
] |
|
470 |
]. |
|
471 |
||
472 |
rcFilename isNil ifTrue:[ |
|
473 |
rcFilename := self startupFilename. |
|
474 |
]. |
|
475 |
rcFilename asFilename exists ifTrue:[ |
|
476 |
self verboseInfo:('reading ',rcFilename,'...'). |
|
477 |
rcFilename isAbsolute ifFalse:[ |
|
478 |
rcFilename := OperatingSystem pathOfSTXExecutable asFilename directory constructString:rcFilename. |
|
479 |
]. |
|
480 |
Smalltalk secureFileIn:rcFilename |
|
481 |
]. |
|
9944 | 482 |
]. |
483 |
||
11352 | 484 |
scripting := false. |
485 |
(self allowScriptingOption) ifTrue:[ |
|
486 |
idx := argv indexOfAny:#('--scripting'). |
|
487 |
idx ~~ 0 ifTrue:[ |
|
488 |
nextArg := argv at:(idx + 1) ifAbsent:nil. |
|
489 |
(nextArg notNil and:[ (nextArg startsWith:'-') not ]) ifTrue:[ |
|
490 |
portNr := nextArg asInteger. |
|
491 |
argv removeAtIndex:idx+1. |
|
492 |
]. |
|
493 |
argv removeAtIndex:idx. |
|
494 |
||
495 |
scripting := true |
|
496 |
]. |
|
9944 | 497 |
]. |
11352 | 498 |
scripting ifTrue:[ |
499 |
STXScriptingServer notNil ifTrue:[ |
|
11353 | 500 |
"/ scripting on port/stdin_out/8008 |
501 |
self verboseInfo:('start scripting'). |
|
502 |
STXScriptingServer startAt:portNr |
|
9944 | 503 |
]. |
504 |
]. |
|
11352 | 505 |
|
9944 | 506 |
^ true |
507 |
||
10773 | 508 |
"Modified: / 31-10-2007 / 16:05:59 / cg" |
9944 | 509 |
! |
510 |
||
11354 | 511 |
you into a debugger.'). |
9944 | 512 |
|
513 |
"Created: / 19-09-2006 / 16:40:32 / cg" |
|
514 |
! |
|
515 |
||
11354 | 516 |
tStandardStreams. |
10773 | 517 |
]. |
9944 | 518 |
|
519 |
"Created: / 19-09-2006 / 16:40:47 / cg" |
|
10773 | 520 |
"Modified: / 31-10-2007 / 16:18:40 / cg" |
9944 | 521 |
! |
522 |
||
11354 | 523 |
StringCollection asString). |
9944 | 524 |
|
525 |
Smalltalk isStandAloneApp ifTrue:[ |
|
526 |
self loadPatches. |
|
527 |
self verboseInfo:('setup Smalltalk'). |
|
528 |
]. |
|
10772 | 529 |
self setupSmalltalkFromArguments:CommandLineArguments. |
9944 | 530 |
self main |
531 |
||
10772 | 532 |
"Modified: / 31-10-2007 / 16:03:44 / cg" |
9944 | 533 |
! |
534 |
||
11354 | 535 |
utLine:' --help .................. output this message'. |
9944 | 536 |
Stderr nextPutLine:' --verbose ............... verbose startup'. |
11352 | 537 |
self allowScriptingOption ifTrue:[ |
538 |
Stderr nextPutLine:' --scripting portNr ...... enable scripting via port (or stdin/stdOut, if 0)'. |
|
539 |
]. |
|
540 |
self allowDebugOption ifTrue:[ |
|
541 |
Stderr nextPutLine:' --debug ................. enable Debugger'. |
|
542 |
]. |
|
543 |
self suppressRCFileReading ifFalse:[ |
|
544 |
Stderr nextPutLine:' --rcFileName file ....... execute code from file on startup (default: ',self startupFilename,')'. |
|
545 |
]. |
|
9944 | 546 |
|
547 |
"Created: / 19-09-2006 / 16:37:55 / cg" |
|
548 |
! ! |
|
549 |
||
550 |
!StandaloneStartup class methodsFor:'startup-to be redefined'! |
|
551 |
||
11354 | 552 |
/ 31-10-2007 / 16:03:22 / cg" |
10636 | 553 |
! |
554 |
||
11354 | 555 |
ion'). |
9944 | 556 |
"/ app := <someGUIApplicationModelClass> open. |
557 |
"/ |
|
558 |
"/ self verboseInfo:('looking for args in ',argv). |
|
559 |
"/ argv notEmptyOrNil ifTrue:[ |
|
560 |
"/ fileArg := argv last asFilename. |
|
561 |
"/ self verboseInfo:('fileArg is ',fileArg name). |
|
562 |
"/ fileArg exists ifTrue:[ |
|
563 |
"/ self verboseInfo:('file exists'). |
|
564 |
"/ |
|
565 |
"/ ( #('foo' 'bar' 'baz' ) includes:fileArg suffix) ifTrue:[ |
|
566 |
"/ self verboseInfo:('loading'). |
|
567 |
"/ |
|
568 |
"/ Error handle:[:ex | |
|
569 |
"/ self verboseInfo:'error while loading'. |
|
570 |
"/ ex suspendedContext fullPrintAll. |
|
571 |
"/ ] do:[ |
|
572 |
"/ app menuLoadFromFile:fileArg |
|
573 |
"/ ]. |
|
574 |
"/ ]. |
|
575 |
"/ ]. |
|
576 |
"/ ]. |
|
577 |
||
578 |
"Created: / 19-09-2006 / 16:48:29 / cg" |
|
579 |
! ! |
|
580 |
||
581 |
!StandaloneStartup class methodsFor:'documentation'! |
|
582 |
||
583 |
version |
|
11354 | 584 |
^ '$Header: /cvs/stx/stx/libbasic/StandaloneStartup.st,v 1.19 2008-11-20 22:15:14 cg Exp $' |
9944 | 585 |
! ! |
586 |
||
587 |
StandaloneStartup initialize! |