[squeak-dev] Squeak 4.5: CommandLine-fbs.2.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Jan 24 20:26:07 UTC 2014


Chris Muller uploaded a new version of CommandLine to project Squeak 4.5:
http://source.squeak.org/squeak45/CommandLine-fbs.2.mcz

==================== Summary ====================

Name: CommandLine-fbs.2
Author: fbs
Time: 2 November 2013, 9:47:04.27 pm
UUID: 414e59b8-4f4a-814d-9dac-b7b9886e92a0
Ancestors: CommandLine-fbs.1

SmalltalkImage current -> Smalltalk.

==================== Snapshot ====================

SystemOrganization addCategory: #'CommandLine-Tools'!
SystemOrganization addCategory: #'CommandLine-UIManager'!

UIManager subclass: #DummyUIManager
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'CommandLine-UIManager'!

!DummyUIManager commentStamp: 'fbs 10/31/2013 07:36' prior: 0!
I'm an alternative UIManager used to run an the image without GUI.  I redefine methods which require user input as these requests are irrelevant in a headless environment. !

----- Method: DummyUIManager>>checkForNewDisplaySize (in category 'display') -----
checkForNewDisplaySize
	Display extent = DisplayScreen actualScreenSize ifTrue: [^ self].
	DisplayScreen startUp.
!

----- Method: DummyUIManager>>chooseDirectory:from: (in category 'ui requests') -----
chooseDirectory: label from: dir
	^ nil!

----- Method: DummyUIManager>>chooseFrom:lines:title: (in category 'ui requests') -----
chooseFrom: aList lines: linesArray title: aString
	^ aList first!

----- Method: DummyUIManager>>chooseFrom:values:lines:title: (in category 'ui requests') -----
chooseFrom: labelList values: valueList lines: linesArray title: aString
	^ valueList first!

----- Method: DummyUIManager>>confirm: (in category 'ui requests') -----
confirm: queryString
	(ProvideAnswerNotification signal: queryString)
		ifNotNil: [:answer|^answer].

	self error: 'No user response possible'!

----- Method: DummyUIManager>>confirm:orCancel: (in category 'ui requests') -----
confirm: aString orCancel: cancelBlock
	(ProvideAnswerNotification signal: aString) ifNotNil: [:answer |
	^answer == #cancel ifTrue: [cancelBlock value] ifFalse: [answer]].

	self error: 'No user response possible'!

----- Method: DummyUIManager>>displayProgress:at:from:to:during: (in category 'ui requests') -----
displayProgress: titleString at: aPoint from: minVal to: maxVal during: workBlock
	^ workBlock value: Association new!

----- Method: DummyUIManager>>edit:label:accept: (in category 'ui requests') -----
edit: aText label: labelString accept: anAction
	^ nil!

----- Method: DummyUIManager>>fontFromUser: (in category 'ui requests') -----
fontFromUser: priorFont
	self error: 'No user response possible'!

----- Method: DummyUIManager>>inform: (in category 'ui requests') -----
inform: aString
	"Nothing to be done here"!

----- Method: DummyUIManager>>informUserDuring: (in category 'ui requests') -----
informUserDuring: aBlock
	aBlock value: nil!

----- Method: DummyUIManager>>newDisplayDepthNoRestore: (in category 'display') -----
newDisplayDepthNoRestore: pixelSize
	"Change depths.  Check if there is enough space!!  , di"
	| area need |
	pixelSize = Display depth ifTrue: [^ self  "no change"].
	pixelSize abs < Display depth ifFalse:
		["Make sure there is enough space"
		area := Display boundingBox area. "pixels"

		need := (area * (pixelSize abs - Display depth) // 8)  "new bytes needed"
				+ Smalltalk lowSpaceThreshold.
		(Smalltalk garbageCollectMost <= need
			and: [Smalltalk garbageCollect <= need])
			ifTrue: [self error: 'Insufficient free space']].
	Display setExtent: Display extent depth: pixelSize.

	DisplayScreen startUp!

----- Method: DummyUIManager>>request:initialAnswer: (in category 'ui requests') -----
request: queryString initialAnswer: defaultAnswer
	(ProvideAnswerNotification signal: queryString)
	ifNotNil: [:answer |
	    ^ answer == #default ifTrue: [defaultAnswer] ifFalse: [answer]].

	self error: 'No user response possible'!

----- Method: DummyUIManager>>requestPassword: (in category 'ui requests') -----
requestPassword: queryString
	^ self request: queryString initialAnswer: ''!

----- Method: DummyUIManager>>restoreDisplay (in category 'display') -----
restoreDisplay!

----- Method: DummyUIManager>>restoreDisplayAfter: (in category 'display') -----
restoreDisplayAfter: aBlock
	aBlock value.
	Sensor waitButton.!

StandardToolSet subclass: #CommandLineToolSet
	instanceVariableNames: ''
	classVariableNames: 'SaveSnapshotOnError'
	poolDictionaries: ''
	category: 'CommandLine-Tools'!

----- Method: CommandLineToolSet class>>debugError: (in category 'debugging') -----
debugError: anError
	"Print out a sensible stack trace and bail"
	| problemPlace s |
	self saveSnapshotOnError
		ifTrue: [Smalltalk saveAs: 'Debug-' , (Smalltalk imageName subStrings: '/') last].
	problemPlace := anError signalerContext.
	s := FileStream stderr.
	(anError isKindOf: MessageNotUnderstood) ifTrue: [
		s
			nextPutAll: anError messageText; cr;
			nextPutAll: problemPlace sender methodNode printString; cr].
	(problemPlace stackOfSize: 20) do: [:ctx | s cr. ctx printOn: s].
	s flush.

	Smalltalk snapshot: false andQuit: true!

----- Method: CommandLineToolSet class>>debugSyntaxError: (in category 'debugging') -----
debugSyntaxError: anError
	| s |
	s := FileStream stderr.
	s nextPutAll: '----- Syntax error -----'; cr.
	s nextPutAll: anError errorCode; cr.
	s nextPutAll: '----- Syntax error -----'; cr.

	self debugError: anError!

----- Method: CommandLineToolSet class>>saveSnapshotOnError (in category 'preferences') -----
saveSnapshotOnError
	<preference: 'Save snapshot of image on failure'
	category: 'debug'
	description: 'If true, saves a snapshot of the failing image to the current directory.'
	type: #Boolean>
	^ SaveSnapshotOnError ifNil: [SaveSnapshotOnError := false].!

----- Method: CommandLineToolSet class>>saveSnapshotOnError: (in category 'preferences') -----
saveSnapshotOnError: aBoolean
	SaveSnapshotOnError := aBoolean.!

----- Method: CommandLineToolSet class>>unload (in category 'class initialization') -----
unload
	ToolSet unregister: self.!



More information about the Squeak-dev mailing list