Smalltalk.st
changeset 4957 d2470714f2da
parent 4956 fd2674985283
child 4958 13fa62361760
--- a/Smalltalk.st	Wed Oct 27 10:53:56 1999 +0200
+++ b/Smalltalk.st	Wed Oct 27 13:33:20 1999 +0200
@@ -15,7 +15,7 @@
 	classVariableNames:'StartBlocks ImageStartBlocks ExitBlocks CachedClasses SystemPath
 		StartupClass StartupSelector StartupArguments CommandLine
 		CommandLineArguments CachedAbbreviations SilentLoading
-		Initializing StandAlone LogDoits LoadBinaries RealSystemPath
+		Initializing StandAlone HeadlessOperation LogDoits LoadBinaries RealSystemPath
 		ResourcePath SourcePath BitmapPath BinaryPath FileInPath
 		BinaryDirName ResourceDirName SourceDirName BitmapDirName
 		FileInDirName ChangeFileName ImageStartTime ImageRestartTime
@@ -110,6 +110,11 @@
                                         exits ST/X, when the last non-background
                                         and non-system process exits.
                                         
+	HeadlessOperation		if true, a non-existing Display connection
+			<Boolean>	will NOT lead to an error-exit during startup.
+					Default is false.
+					Can be set in an application-specific startup script. 
+
         LogDoits        <Boolean>       if true, doits are also logged in the changes
                                         file. Default is false, since the changes file
                                         may become huge if every tiny doIt is saved there ...
@@ -1360,6 +1365,14 @@
     ^ prev
 ! !
 
+!Smalltalk class methodsFor:'misc accessing'!
+
+beHeadless:aBoolean
+    "set/clear the headlessOperation flag."
+
+    HeadlessOperation := aBoolean
+! !
+
 !Smalltalk class methodsFor:'misc stuff'!
 
 addExitBlock:aBlock
@@ -1999,7 +2012,9 @@
      if view-classes exist, start dispatching;
      otherwise go into a read-eval-print loop
     "
-    ((Display notNil and:[graphicalMode]) or:[standAloneProcess notNil]) ifTrue:[
+    ((Display notNil and:[graphicalMode]) 
+    or:[standAloneProcess notNil
+    or:[HeadlessOperation]]) ifTrue:[
 	Processor dispatchLoop.
     ] ifFalse:[
 	StandAlone ifFalse:[
@@ -2348,7 +2363,7 @@
 	self initStandardTools.
     ].
 
-    Display isNil ifTrue:[
+    (Display isNil or:[HeadlessOperation]) ifTrue:[
 	graphicalMode := false.
     ].
 
@@ -2389,6 +2404,13 @@
     "Modified: 19.7.1996 / 11:11:16 / cg"
 !
 
+isHeadless
+    "return true, if this is a headless application
+     i.e. no default Display connection is required/used"
+
+    ^ HeadlessOperation ? false
+!
+
 isStandAloneApp
     "return true, if this is a standAlone application
      (in contrast to a full smalltalk system)."
@@ -4058,10 +4080,16 @@
 !
 
 recursiveReadAllAbbreviationsFrom:aDirectory
+    self recursiveReadAllAbbreviationsFrom:aDirectory maxLevels:5
+!
+
+recursiveReadAllAbbreviationsFrom:aDirectory maxLevels:maxLevels
     "read all abbreviations from and under aDirectory."
 
     |abbrevStream dir|
 
+    maxLevels == 0 ifTrue:[^ self].
+
     dir := aDirectory asFilename.
 
     abbrevStream := (dir construct:'abbrev.stc') asFilename readStream.
@@ -4073,9 +4101,13 @@
     dir directoryContents do:[:aFilename |
         |f|
 
-        f := dir construct:aFilename.
-        f isDirectory ifTrue:[
-            self recursiveReadAllAbbreviationsFrom:f
+	(#(
+	    'doc'
+	) includes:aFilename) ifFalse:[
+            f := dir construct:aFilename.
+            f isDirectory ifTrue:[
+                self recursiveReadAllAbbreviationsFrom:f maxLevels:maxLevels-1
+	    ]
         ].
     ].
 !
@@ -4870,5 +4902,5 @@
 !Smalltalk class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.366 1999-10-27 08:53:56 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.367 1999-10-27 11:33:20 stefan Exp $'
 ! !