[Bug][Fix] Patterns in StandardFileMenu

Tobias Isenberg Tobias.Isenberg at gmx.de
Tue May 16 08:50:07 UTC 2000


I noticed that there is support for patterns in StandardFileMenu.
However, first of all it is not used when first opening a menu. Only
after the first directory change it has an effect. Furthermore, the
pattern is not only applied to the file name but also to the directory
string at the same time. This has the effect that if one is looking for
instance for '*.cs' files that once one changes the directory, all
subdirectories disappear (since they don't have '*.cs' in their name).

Attached is a changeset that not only fixes this last problem but also
adds a method to open a StandardFileMenu with a pattern.

Regards,

Tobias
-- 
 --[ Tobias Isenberg ]------------[ isenberg at cs.uni-magdeburg.de ]--
| Otto-von-Guericke-Universitaet Magdeburg   TEL:  +49-391-67-11430 |
| FIN, ISG, Uniplatz 2,  D-39106 Magdeburg   FAX:  +49-391-67-11164 |
 -----------[ http://www.cs.uni-magdeburg.de/~isenberg/ ]-----------
-------------- next part --------------
'From Squeak2.8alpha of 19 January 2000 [latest update: #2098] on 10 May 2000 at 11:19:19 am'!

!StandardFileMenu methodsFor: 'menu building' stamp: 'ti 5/10/2000 11:17'!
directoryNamesString: aDirectory
"Answer a string concatenating the directory name strings in aDirectory, each string followed by a '[...]' indicator, and followed by a cr."

	^String streamContents:
		[:s | 
			aDirectory directoryNames do: 
				[:dn |
					s nextPutAll: dn withBlanksTrimmed.
					s nextPutAll: ' [...]'; cr]]

! !

!StandardFileMenu methodsFor: 'menu building' stamp: 'ti 5/10/2000 11:18'!
menuLinesArray: aDirectory
"Answer a menu lines object corresponding to aDirectory"

	| typeCount nameCnt |
	typeCount _ canTypeFileName 
		ifTrue: [1] 
		ifFalse: [0].
	nameCnt _ aDirectory directoryNames size.
	^Array streamContents: [:s |
		canTypeFileName ifTrue: [s nextPut: 1].
		s nextPut: aDirectory pathParts size + typeCount + 1.
		s nextPut: aDirectory pathParts size + 
					nameCnt + typeCount + 1]! !

!StandardFileMenu methodsFor: 'menu building' stamp: 'ti 5/10/2000 11:18'!
menuSelectionsArray: aDirectory
"Answer a menu selections object corresponding to aDirectory.  The object is an array corresponding to each item, each element itself constituting a two-element array, the first element of which contains a selector to operate on and the second element of which contains the parameters for that selector."

	|dirSize|
	dirSize _ aDirectory pathParts size.
	^Array streamContents: [:s |
		canTypeFileName ifTrue:
			[s nextPut: (StandardFileMenuResult
				directory: aDirectory
				name: nil)].
		s nextPut: (StandardFileMenuResult
			directory: (FileDirectory root)
			name: '').
		aDirectory pathParts doWithIndex: 
			[:d :i |
				s nextPut: (StandardFileMenuResult
					directory: (self 
						advance: dirSize - i
						containingDirectoriesFrom: aDirectory)
					name: '')].
		aDirectory directoryNames do: 
			[:dn | 
				s nextPut: (StandardFileMenuResult
					directory: (FileDirectory on: (aDirectory fullNameFor: dn))
					name: '')].
		aDirectory fileNames do: 
			[:fn | 
				(pattern match: fn) ifTrue: [
					s nextPut: (StandardFileMenuResult
						directory: aDirectory
						name: fn)]]]! !

!StandardFileMenu methodsFor: 'private'!
oldFileFrom: aDirectory withPattern: aPattern

	canTypeFileName _ false.
	pattern _ aPattern.
	^self makeFileMenuFor: aDirectory! !


!StandardFileMenu class methodsFor: 'instance creation'!
oldFileMenu: aDirectory withPattern: aPattern

	World ifNil: [^PluggableFileList oldFileMenu: aDirectory].
	^super new oldFileFrom: aDirectory withPattern: aPattern! !



More information about the Squeak-dev mailing list