Indented volume list

Reinier van Loon R.L.J.M.W.van.Loon at inter.nl.net
Sun Apr 5 15:16:45 UTC 1998


Folks,

shame on me. Don't use the changes in the previous message. It will make
sure you can't save anything anymore after a save (because the changes file
gets opened using oldFileNamed:). The new version is included below. If you
did file in the change set and you did a save here is how you can recover
within the image:

1. change false back into true in the method StandardFileStream
class>>oldFileNamed: 
2. after the accept you will get a debugger message (Error attempt to write
to a read-only file)
    (but the byte codes are there!)
3. close the error screen
4. evaluate the following in a workspace: SourceFiles do: [ :each | each
close; open ].
5. this will lead to an error
6. close the error screen
7. everything should be fine now.

Sorry for the inconvenience.

Reinier.

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


	TITLE			FileList.cs
	AUTHOR		Reinier van Loon (reinier at 2share.com)
	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 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).
"!


!FileModel methodsFor: 'accessing' stamp: 'RvL 4/5/98 16:06'!
readContentsBrief: brevityFlag
	"retrieve the contents from the external file unless it is too long.
	  Don't create a file here.  Check if exists."
	| f size newContents first1000 last1000 |

	f _ FileStream "oldFileOrNoneNamed: RvL" readOnlyFileNamed: self fullName.

	f == nil ifTrue:
		[^ 'For some reason, this file cannot be read'].
	(brevityFlag and: [(size _ f size) > 30000]) ifFalse: 
		[^ f contentsOfEntireFile].

	"Don't display long files at first.
	Composing the paragraph may take a long time."
	first1000 _ f next: 1000.
	f position: size - 1000.
	last1000 _ f next: 1000.
	f close.
	^ 'File ''' , fileName , ''' is ', size printString, ' bytes long.
You may use the ''get'' command to read the entire file.

Here are the first 1000 characters:
--------------------------------
' , first1000 , '

.... and here are the last 1000 characters:
--------------------------------------
' , last1000! !


!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).
! !





More information about the Squeak-dev mailing list