Indented volume list

Reinier van Loon R.L.J.M.W.van.Loon at inter.nl.net
Sun Apr 5 10:58:00 UTC 1998


Folks,

below you will find an enhancement? for the file browser. It also includes
a fix? for not showing the contents of a read-only file.

Have fun, Reinier.

'From Squeak 1.31 of Feb 4, 1998 on 5 April 1998 at 11:53:08 am'!
"FileList.cs is a change set to implement a indented volume list.


	TITLE			FileList.cs
	AUTHOR		Reinier van Loon (reinier at 2share.com | rvloon at inter.nl.net)
	VERSION		1.0
	IMAGE VERSION	1.31
	PREREQUISITES	none
	DATE			April 5, 1998

This change set changes Squeak in the following way:

1.The volume list shows itself indented.
2. Existing files are by default opened for reading instead of writing
(this fixes the message 'For some reason this file cannot be read' when it
is a read-only file).
"!


!FileList methodsFor: 'initialization' stamp: 'RvL 4/5/98 11:52'!
directory: dir
	"Set the path of the volume to be displayed."
	| depth |
	sortMode == nil ifTrue: [sortMode _ #date].   "2/7/97 sw personal
preference"
	self okToChange ifFalse: [^ self].
	directory _ dir.
"RvL start"
	volList := OrderedCollection with: '[]'.	
	depth := 0.
	directory pathParts do:  [ :each |
		depth := depth + 1.
		volList add: ( String new: depth withAll: $ ), each
	].
	"volList _ (Array with: '[]'), directory pathParts."
"RvL end"
	self changed: #relabel.
	self changed: #list.
	self newListAndPattern: (pattern == nil ifTrue: ['*']
										ifFalse: [pattern]).
! !

!FileList methodsFor: 'list access' stamp: 'RvL 4/5/98 11:52'!
toggleListIndex: index
	"Select the volume name in the receiver's list whose index is the
argument."

	| delim path |
	volListIndex _ index.
	delim _ directory pathNameDelimiter.
	path _ String streamContents: [:strm |
		2 to: index do: [:i |
			strm nextPutAll: ((volList at: i) withBlanksTrimmed). "RvL added
withBlanksTrimmed"
			i < index ifTrue: [strm nextPut: delim]]].
	self directory: (FileDirectory on: path).
! !


!StandardFileStream class methodsFor: 'file creation' stamp: 'RvL 4/5/98
11:51'!
oldFileNamed: aFileName 
 	"Open a file in the default directory (or in the directory contained
	in the input arg); by default, it's available for reading.  2/12/96 sw
	Prior contents will be overwritten, but not truncated on close.  3/18 di"
	| selection |
	(self isAFileNamed: aFileName) ifTrue:
		[^ self new open: aFileName forWrite: false]. "RvL false was true"

	"File does not exist..."
	selection _ (PopUpMenu labels: 'create a new file
choose another name
cancel')
			startUpWithCaption: (FileDirectory localNameFor: aFileName) , '
does not exist.'.
	selection = 1 ifTrue:
		[^ self new open: aFileName forWrite: true].
	selection = 2 ifTrue:
		[^ self oldFileNamed:
			(FillInTheBlank request: 'Enter a new file name'
						initialAnswer: (FileDirectory localNameFor: aFileName))].
	self halt! !





More information about the Squeak-dev mailing list