nicer directory list.
--- a/FBrowser.st Wed Apr 16 21:07:39 1997 +0200
+++ b/FBrowser.st Thu Apr 17 03:34:20 1997 +0200
@@ -16,9 +16,9 @@
showVeryLongList showDotFiles myName killButton compressTabs
lockUpdate previousDirectory currentFileName timeOfFileRead
tabSpec commandView commandIndex fileEncoding tabRulerView
- scrollView'
+ scrollView icons'
classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon
- CommandHistory CommandHistorySize'
+ CommandHistory CommandHistorySize Icons'
poolDictionaries:''
category:'Interface-Browsers'
!
@@ -154,6 +154,34 @@
^ DefaultIcon
"Modified: 19.3.1997 / 22:23:58 / cg"
+!
+
+directoryIcon
+ ^ Image fromFile:'bitmaps/xpmBitmaps/document_images/tiny_yellow_dir.xpm'.
+
+ "Created: 17.4.1997 / 01:31:11 / cg"
+ "Modified: 17.4.1997 / 02:28:28 / cg"
+!
+
+directoryLinkIcon
+ ^ Image fromFile:'bitmaps/xpmBitmaps/document_images/tiny_yellow_dir_link.xpm'.
+
+ "Modified: 17.4.1997 / 02:28:28 / cg"
+ "Created: 17.4.1997 / 02:29:36 / cg"
+!
+
+fileIcon
+ ^ Image fromFile:'bitmaps/xpmBitmaps/document_images/tiny_file_plain.xpm'.
+
+ "Created: 17.4.1997 / 01:31:20 / cg"
+ "Modified: 17.4.1997 / 02:23:17 / cg"
+!
+
+fileLinkIcon
+ ^ Image fromFile:'bitmaps/xpmBitmaps/document_images/tiny_file_link.xpm'.
+
+ "Modified: 17.4.1997 / 02:23:17 / cg"
+ "Created: 17.4.1997 / 02:32:18 / cg"
! !
!FileBrowser methodsFor:'drag & drop'!
@@ -1492,19 +1520,6 @@
yesButton:yesButtonText
!
-binaryFileAction:aFilename
- "for some binary files, if double clicked, we can do some useful
- action ..."
-
- (currentDirectory pathName , '/' , aFilename) asFilename isExecutable ifTrue:[
- (OperatingSystem executeCommand:'cd ',currentDirectory pathName, '; ',aFilename)
- ifTrue:[^true].
- ].
- ^ self imageAction:aFilename
-
- "Modified: 19.6.1996 / 09:44:07 / cg"
-!
-
changeToPreviousDirectory
"if text was modified show a queryBox,
otherwise change immediately to previous directory."
@@ -1602,22 +1617,6 @@
]
!
-defineTabulatorsForLongList
- "define the tabs for the long list"
-
- tabSpec := TabulatorSpecification new.
- tabSpec unit:#inch.
-"/ tabSpec positions:#(0 2 2.3 4.3 5.3 6.0 6.5).
- tabSpec widths: #(2 0.3 2.0 1 0.5 0.5 1"any").
- " name type mode owner group size type"
- tabSpec align: #(#left #left #left #right #right #decimal #left).
- tabSpec addDependent:self.
-
- tabRulerView tabulatorSpecification:tabSpec.
-
- "Modified: 28.3.1997 / 15:30:25 / cg"
-!
-
doChangeCurrentDirectoryTo:fileName updateHistory:updateHistory
"verify argument is name of a readable & executable directory
and if so, go there"
@@ -2254,8 +2253,252 @@
"Modified: 23.1.1997 / 20:39:25 / cg"
!
+onlyOneSelection
+ "show a warning, that only one file must be selected for
+ this operation"
+
+ self warn:'exactly one file must be selected !!'
+!
+
+selectedFilesDo:aBlock
+ "evaluate aBlock on all selected files;
+ show a wait cursor while doing this"
+
+ |sel|
+
+ sel := fileListView selection.
+ sel notNil ifTrue:[
+ self withWaitCursorDo:[
+ sel do:[:aSelectionIndex |
+ aBlock value:(fileList at:aSelectionIndex )
+ ]
+ ]
+ ]
+
+!
+
+setCurrentDirectory:aPathName
+ "setup for another directory"
+
+ |newDirectory|
+
+ aPathName isEmpty ifTrue:[^ self].
+ (currentDirectory isDirectory:aPathName) ifTrue:[
+ newDirectory := FileDirectory directoryNamed:aPathName in:currentDirectory.
+ newDirectory notNil ifTrue:[
+ self currentDirectory:newDirectory pathName.
+ currentFileName notNil ifTrue:[
+ fileListView contents:nil.
+ currentFileName := nil.
+ ] ifFalse:[
+ fileListView setSelection:nil.
+ fileListView scrollToTop.
+ ].
+ self updateCurrentDirectory.
+ self showInfo.
+ ]
+ ]
+
+ "Modified: 21.9.1995 / 11:22:45 / claus"
+ "Modified: 25.5.1996 / 12:27:01 / cg"
+!
+
+show:something
+ "show something in subview and undef acceptAction"
+
+ subView contents:something.
+ subView acceptAction:nil.
+ subView modified:false.
+ currentFileName := nil
+!
+
+showAlert:aString with:anErrorString
+ "show an alertbox, displaying the last Unix-error"
+
+ |msg|
+
+ anErrorString isNil ifTrue:[
+ msg := aString
+ ] ifFalse:[
+ msg := aString , '\\(' , anErrorString , ')'
+ ].
+ self warn:msg withCRs
+!
+
+showInfo
+ "show directory info when dir has changed"
+
+ |info txt|
+
+ info := self getInfoFile.
+ info notNil ifTrue:[
+ txt := self readFile:info
+ ].
+ self show:txt.
+!
+
+sizePrintString:size
+ "helper for update-directory to return a string with a files size.
+ This one gives the size in byte, Kb or Mb depending on size.
+ If you dont like this, just uncomment the first statement below."
+
+ |unitString n|
+
+"
+ ^ size printString.
+"
+ unitString := ''.
+ size < (500 * 1024) ifTrue:[
+ size < 1024 ifTrue:[
+ n := size
+ ] ifFalse:[
+ n := (size * 10 // 1024 / 10.0).
+ unitString := ' Kb'
+ ]
+ ] ifFalse:[
+ n := (size * 10 // 1024 // 1024 / 10.0).
+ unitString := ' Mb'
+ ].
+ ^ (n printStringLeftPaddedTo:5) , unitString.
+!
+
+validateFontEncodingFor:newEncoding ask:ask
+ "if required, query user if he/she wants to change to another font,
+ which is able to display text encoded as specified by newEncoding"
+
+ |fontsEncoding msg filter f defaultFont|
+
+ fontsEncoding := subView font encoding.
+
+ ((newEncoding == #jis7) or:[newEncoding == #euc]) ifTrue:[
+ (fontsEncoding notNil and:[fontsEncoding startsWith:'jis']) ifFalse:[
+ msg := 'switch to a JIS encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:['jis*' match:coding]].
+ ]
+ ].
+ (newEncoding == #gb) ifTrue:[
+ (fontsEncoding notNil and:[fontsEncoding startsWith:'gb']) ifFalse:[
+ msg := 'switch to a GB encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:['gb*' match:coding]].
+ ]
+ ].
+ (newEncoding == #big5) ifTrue:[
+ (fontsEncoding notNil and:[fontsEncoding startsWith:'big5']) ifFalse:[
+ msg := 'switch to a BIG-5 encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:['big5*' match:coding]].
+ ]
+ ].
+ (newEncoding == #ksc) ifTrue:[
+ (fontsEncoding notNil and:[fontsEncoding startsWith:'ksc']) ifFalse:[
+ msg := 'switch to a KSC encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:['ksc*' match:coding]].
+ ]
+ ] ifFalse:[
+ fontsEncoding notNil ifTrue:[
+ ((fontsEncoding startsWith:'jis')
+ or:[(fontsEncoding startsWith:'gb')
+ or:[(fontsEncoding startsWith:'ksc')
+ or:[(fontsEncoding startsWith:'big5')]]])
+ ifTrue:[
+ msg := 'switch back to an ASCII encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:[('ascii' match:coding)
+ or:['iso*' match:coding]]].
+ defaultFont := TextView defaultFont
+ ] ifFalse:[
+ (fontsEncoding notNil and:[fontsEncoding startsWith:'iso8859']) ifTrue:[
+ msg := 'switch to a ''' , newEncoding , ''' encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:[newEncoding asLowercase = coding asLowercase]].
+ ].
+ ].
+ ]
+ ].
+
+ msg isNil ifTrue:[
+ "/ mhmh - can be represented in current font
+ ].
+
+ msg notNil ifTrue:[
+ defaultFont isNil ifTrue:[
+ defaultFont := device
+ listOfAvailableFonts
+ detect:[:f | filter value:f]
+ ifNone:nil.
+ defaultFont isNil ifTrue:[
+ self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'.
+ ^ self.
+ ]
+ ].
+
+ (ask not or:[self confirm:(resources string:msg) withCRs])
+ ifTrue:[
+ f := FontPanel
+ fontFromUserInitial:defaultFont
+ title:(resources string:'font selection')
+ filter:filter.
+ f notNil ifTrue:[
+ subView font:f
+ ]
+ ]
+ ]
+
+ "Created: 26.10.1996 / 12:06:54 / cg"
+!
+
+withoutHiddenFiles:aCollection
+ "remove hidden files (i.e. those that start with '.') from
+ the list in aCollection"
+
+ |newCollection|
+
+ newCollection := aCollection species new.
+ aCollection do:[:fname |
+ |ignore|
+
+ ignore := false.
+
+ ((fname startsWith:'.') and:[fname ~= '..']) ifTrue:[
+ showDotFiles ifFalse:[
+ ignore := true
+ ]
+ ].
+ ignore ifFalse:[
+ newCollection add:fname
+ ]
+ ].
+ ^ newCollection
+
+ "Modified: 21.2.1996 / 01:33:18 / cg"
+! !
+
+!FileBrowser methodsFor:'private - actions'!
+
+binaryFileAction:aFilename
+ "for some binary files, if double clicked, we can do some useful
+ action ..."
+
+ (currentDirectory pathName , '/' , aFilename) asFilename isExecutable ifTrue:[
+ (OperatingSystem executeCommand:'cd ',currentDirectory pathName, '; ',aFilename)
+ ifTrue:[^true].
+ ].
+ ^ self imageAction:aFilename
+
+ "Modified: 19.6.1996 / 09:44:07 / cg"
+!
+
imageAction:aFilename
- "for some binary files, if double clicked, we can do some useful
+ "for some image files, if double clicked, we can do some useful
action ..."
|img|
@@ -2271,7 +2514,7 @@
^ false
"Created: 19.6.1996 / 09:43:50 / cg"
- "Modified: 1.2.1997 / 15:06:38 / cg"
+ "Modified: 16.4.1997 / 13:56:21 / cg"
!
initialCommandFor:fileName into:aBox
@@ -2401,115 +2644,134 @@
"Created: 19.6.1996 / 09:36:38 / cg"
"Modified: 4.4.1997 / 10:49:00 / cg"
-!
-
-onlyOneSelection
- "show a warning, that only one file must be selected for
- this operation"
-
- self warn:'exactly one file must be selected !!'
-!
-
-selectedFilesDo:aBlock
- "evaluate aBlock on all selected files;
- show a wait cursor while doing this"
-
- |sel|
-
- sel := fileListView selection.
- sel notNil ifTrue:[
- self withWaitCursorDo:[
- sel do:[:aSelectionIndex |
- aBlock value:(fileList at:aSelectionIndex )
- ]
- ]
- ]
-
+! !
+
+!FileBrowser methodsFor:'private - presentation'!
+
+defineTabulatorsForLongList
+ "define the tabs for the long list"
+
+ tabSpec := TabulatorSpecification new.
+ tabSpec unit:#inch.
+"/ tabSpec positions:#(0 0.25 2.3 4.3 5.3 6.0 6.5).
+ tabSpec widths: #(0.25 2 2.0 1 0.5 0.5 1"any").
+ " icon name mode owner group size type"
+ tabSpec align: #(#left #left #left #right #right #decimal #left).
+ tabSpec addDependent:self.
+
+ tabRulerView tabulatorSpecification:tabSpec.
+
+ "Modified: 17.4.1997 / 02:56:07 / cg"
!
-setCurrentDirectory:aPathName
- "setup for another directory"
-
- |newDirectory|
-
- aPathName isEmpty ifTrue:[^ self].
- (currentDirectory isDirectory:aPathName) ifTrue:[
- newDirectory := FileDirectory directoryNamed:aPathName in:currentDirectory.
- newDirectory notNil ifTrue:[
- self currentDirectory:newDirectory pathName.
- currentFileName notNil ifTrue:[
- fileListView contents:nil.
- currentFileName := nil.
- ] ifFalse:[
- fileListView setSelection:nil.
- fileListView scrollToTop.
- ].
- self updateCurrentDirectory.
- self showInfo.
- ]
- ]
-
- "Modified: 21.9.1995 / 11:22:45 / claus"
- "Modified: 25.5.1996 / 12:27:01 / cg"
+defineTabulatorsForShortList
+ "define the tabs for the short list"
+
+ tabSpec := TabulatorSpecification new.
+ tabSpec unit:#inch.
+"/ tabSpec positions:#(0 0.25 ).
+ tabSpec widths: #(0.25 2 ).
+ " icon name"
+ tabSpec align: #(#left #left).
+ tabSpec addDependent:self.
+
+ tabRulerView tabulatorSpecification:tabSpec.
+
+ "Created: 17.4.1997 / 02:51:41 / cg"
+ "Modified: 17.4.1997 / 02:55:17 / cg"
+!
+
+directoryIcon
+ "return an icon used to mark directories"
+
+ |i|
+
+ icons isNil ifTrue:[
+ icons := IdentityDictionary new.
+ ].
+ i := icons at:#directory ifAbsent:nil.
+ i isNil ifTrue:[
+ icons at:#directory put:((i := self class directoryIcon) on:device).
+ ].
+ ^ i
+
+ "Created: 16.4.1997 / 14:00:26 / cg"
+ "Modified: 17.4.1997 / 01:32:36 / cg"
!
-show:something
- "show something in subview and undef acceptAction"
-
- subView contents:something.
- subView acceptAction:nil.
- subView modified:false.
- currentFileName := nil
+directoryLinkIcon
+ "return an icon used to mark directory links"
+
+ |i|
+
+ icons isNil ifTrue:[
+ icons := IdentityDictionary new.
+ ].
+ i := icons at:#directoryLink ifAbsent:nil.
+ i isNil ifTrue:[
+ icons at:#directoryLink put:((i := self class directoryLinkIcon) on:device).
+ ].
+ ^ i
+
+ "Modified: 17.4.1997 / 01:32:36 / cg"
+ "Created: 17.4.1997 / 02:29:27 / cg"
!
-showAlert:aString with:anErrorString
- "show an alertbox, displaying the last Unix-error"
-
- |msg|
-
- anErrorString isNil ifTrue:[
- msg := aString
- ] ifFalse:[
- msg := aString , '\\(' , anErrorString , ')'
+fileIcon
+ "return an icon used to mark files"
+
+ |i|
+
+ icons isNil ifTrue:[
+ icons := IdentityDictionary new.
].
- self warn:msg withCRs
+ i := icons at:#file ifAbsent:nil.
+ i isNil ifTrue:[
+ icons at:#file put:((i := self class fileIcon) on:device).
+ ].
+ ^ i
+
+ "Created: 16.4.1997 / 14:00:26 / cg"
+ "Modified: 17.4.1997 / 01:32:47 / cg"
!
-showInfo
- "show directory info when dir has changed"
-
- |info txt|
-
- info := self getInfoFile.
- info notNil ifTrue:[
- txt := self readFile:info
+fileLinkIcon
+ "return an icon used to mark link files"
+
+ |i|
+
+ icons isNil ifTrue:[
+ icons := IdentityDictionary new.
].
- self show:txt.
+ i := icons at:#fileLink ifAbsent:nil.
+ i isNil ifTrue:[
+ icons at:#fileLink put:((i := self class fileLinkIcon) on:device).
+ ].
+ ^ i
+
+ "Modified: 17.4.1997 / 01:32:47 / cg"
+ "Created: 17.4.1997 / 02:32:09 / cg"
!
-sizePrintString:size
- "helper for update-directory to return a string with a files size.
- This one gives the size in byte, Kb or Mb depending on size.
- If you dont like this, just uncomment the first statement below."
-
- |unitString n|
-
-"
- ^ size printString.
-"
- unitString := ''.
- size < (500 * 1024) ifTrue:[
- size < 1024 ifTrue:[
- n := size
- ] ifFalse:[
- n := (size * 10 // 1024 / 10.0).
- unitString := ' Kb'
- ]
- ] ifFalse:[
- n := (size * 10 // 1024 // 1024 / 10.0).
- unitString := ' Mb'
+iconForFile:aFilenameString
+ "update listView with directory contents"
+
+ |f|
+
+ f := currentDirectory asFilename construct:aFilenameString.
+ f isDirectory ifTrue:[
+ f isSymbolicLink ifTrue:[
+ ^ self directoryLinkIcon
+ ].
+ ^ self directoryIcon
].
- ^ (n printStringLeftPaddedTo:5) , unitString.
+ f isSymbolicLink ifTrue:[
+ ^ self fileLinkIcon
+ ].
+ ^ self fileIcon
+
+ "Created: 16.4.1997 / 13:53:49 / cg"
+ "Modified: 17.4.1997 / 02:31:50 / cg"
!
updateCurrentDirectory
@@ -2566,12 +2828,13 @@
the files info ...
"
Processor activeProcess withLowerPriorityDo:[
- |prevUid prevGid nameString groupString modeString info line len text |
+ |prevUid prevGid nameString groupString modeString info line len text firstItem|
"
first show the names only - this is relatively fast
"
fileListView setList:files expandTabs:false.
+ firstItem := true.
"
then walk over the files, adding more info
@@ -2598,6 +2861,10 @@
"
realized ifFalse:[^ self].
+ col := 1.
+ entry colAt:col put:(self iconForFile:aFileName).
+ col := col + 1.
+
len := aFileName size.
(len < 20) ifTrue:[
line := aFileName , (String new:(22 - len))
@@ -2605,44 +2872,54 @@
"can happen on BSD only"
line := (aFileName copyTo:20) , ' '
].
- entry colAt:1 put:line.
+ entry colAt:col put:line.
+ col := col + 1.
info := currentDirectory infoOf:aFileName.
info isNil ifTrue:[
"not accessable - usually a symlink,
to a nonexisting/nonreadable file
"
- entry colAt:2 put:'?'.
- entry colAt:3 put:'(bad symbolic link ?)'.
+"/ entry colAt:col put:'?'.
+"/ col := col + 1.
+ entry colAt:col put:'(bad symbolic link ?)'.
+ col := col + 1.
] ifFalse:[
typ := (info type).
- (typ == #regular) ifFalse:[
- entry colAt:2 put:(typ at:1) asString.
- ] ifTrue:[
- entry colAt:2 put:' '.
- ].
+"/ (typ == #regular) ifFalse:[
+"/ entry colAt:col put:(typ at:1) asString.
+"/ ] ifTrue:[
+"/ entry colAt:col put:' '.
+"/ ].
+"/ col := col + 1.
+
modeString := self getModeString:(info at:#mode)
with:#( '' $r $w $x
' ' $r $w $x
' ' $r $w $x ).
- entry colAt:3 put:modeString.
+ entry colAt:col put:modeString.
+ col := col + 1.
((info uid) ~~ prevUid) ifTrue:[
prevUid := (info uid).
nameString := OperatingSystem getUserNameFromID:prevUid.
nameString := nameString , (String new:(10 - nameString size))
].
- entry colAt:4 put:nameString withoutSpaces.
+ entry colAt:col put:nameString withoutSpaces.
+ col := col + 1.
+
((info gid) ~~ prevGid) ifTrue:[
prevGid := (info gid).
groupString := OperatingSystem getGroupNameFromID:prevGid.
groupString := groupString , (String new:(10 - groupString size))
].
- entry colAt:5 put:groupString withoutSpaces.
+ entry colAt:col put:groupString withoutSpaces.
+ col := col + 1.
(typ == #regular) ifTrue:[
- entry colAt:6 put:(self sizePrintString:(info size)).
+ entry colAt:col put:(self sizePrintString:(info size)).
].
+ col := col + 1.
f := currentDirectory asFilename:aFileName.
f isSymbolicLink ifTrue:[
@@ -2655,14 +2932,16 @@
typeString := f fileType.
].
].
- entry colAt:7 put:typeString.
+ entry colAt:col put:typeString.
text add:entry
].
fileListView at:lineIndex put:entry
].
] ifFalse:[
+ tabSpec isNil ifTrue:[self defineTabulatorsForShortList].
+
files keysAndValuesDo:[:lineIndex :aName |
- |entry|
+ |entry fileName|
"
if multiple FileBrowsers are reading, let others
@@ -2674,11 +2953,25 @@
((currentDirectory isDirectory:aName) and:[
(aName ~= '..') and:[aName ~= '.']]) ifTrue:[
- entry := aName , ' ...'
+ fileName := aName , ' ...'
] ifFalse:[
- entry := aName
+ fileName := aName
].
- fileListView at:lineIndex put:entry
+"/ firstItem ifTrue:[
+"/ firstItem := false.
+"/ fileListView fontHeight:30.
+"/ fileListView computeNumberOfLinesShown.
+"/ fileListView redraw.
+"/ ].
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:(self iconForFile:aName).
+ entry colAt:2 put:fileName.
+
+ fileListView
+ at:lineIndex
+ put:entry
].
].
].
@@ -2690,127 +2983,7 @@
]
"Modified: 21.9.1995 / 11:40:23 / claus"
- "Modified: 15.4.1997 / 15:53:28 / cg"
-!
-
-validateFontEncodingFor:newEncoding ask:ask
- "if required, query user if he/she wants to change to another font,
- which is able to display text encoded as specified by newEncoding"
-
- |fontsEncoding msg filter f defaultFont|
-
- fontsEncoding := subView font encoding.
-
- ((newEncoding == #jis7) or:[newEncoding == #euc]) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'jis']) ifFalse:[
- msg := 'switch to a JIS encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['jis*' match:coding]].
- ]
- ].
- (newEncoding == #gb) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'gb']) ifFalse:[
- msg := 'switch to a GB encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['gb*' match:coding]].
- ]
- ].
- (newEncoding == #big5) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'big5']) ifFalse:[
- msg := 'switch to a BIG-5 encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['big5*' match:coding]].
- ]
- ].
- (newEncoding == #ksc) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'ksc']) ifFalse:[
- msg := 'switch to a KSC encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['ksc*' match:coding]].
- ]
- ] ifFalse:[
- fontsEncoding notNil ifTrue:[
- ((fontsEncoding startsWith:'jis')
- or:[(fontsEncoding startsWith:'gb')
- or:[(fontsEncoding startsWith:'ksc')
- or:[(fontsEncoding startsWith:'big5')]]])
- ifTrue:[
- msg := 'switch back to an ASCII encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:[('ascii' match:coding)
- or:['iso*' match:coding]]].
- defaultFont := TextView defaultFont
- ] ifFalse:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'iso8859']) ifTrue:[
- msg := 'switch to a ''' , newEncoding , ''' encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:[newEncoding asLowercase = coding asLowercase]].
- ].
- ].
- ]
- ].
-
- msg isNil ifTrue:[
- "/ mhmh - can be represented in current font
- ].
-
- msg notNil ifTrue:[
- defaultFont isNil ifTrue:[
- defaultFont := device
- listOfAvailableFonts
- detect:[:f | filter value:f]
- ifNone:nil.
- defaultFont isNil ifTrue:[
- self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'.
- ^ self.
- ]
- ].
-
- (ask not or:[self confirm:(resources string:msg) withCRs])
- ifTrue:[
- f := FontPanel
- fontFromUserInitial:defaultFont
- title:(resources string:'font selection')
- filter:filter.
- f notNil ifTrue:[
- subView font:f
- ]
- ]
- ]
-
- "Created: 26.10.1996 / 12:06:54 / cg"
-!
-
-withoutHiddenFiles:aCollection
- "remove hidden files (i.e. those that start with '.') from
- the list in aCollection"
-
- |newCollection|
-
- newCollection := aCollection species new.
- aCollection do:[:fname |
- |ignore|
-
- ignore := false.
-
- ((fname startsWith:'.') and:[fname ~= '..']) ifTrue:[
- showDotFiles ifFalse:[
- ignore := true
- ]
- ].
- ignore ifFalse:[
- newCollection add:fname
- ]
- ].
- ^ newCollection
-
- "Modified: 21.2.1996 / 01:33:18 / cg"
+ "Modified: 17.4.1997 / 02:59:28 / cg"
! !
!FileBrowser methodsFor:'private-file-I/O'!
@@ -3080,5 +3253,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/Attic/FBrowser.st,v 1.138 1997-04-15 13:54:39 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Attic/FBrowser.st,v 1.139 1997-04-17 01:34:20 cg Exp $'
! !
--- a/FileBrowser.st Wed Apr 16 21:07:39 1997 +0200
+++ b/FileBrowser.st Thu Apr 17 03:34:20 1997 +0200
@@ -16,9 +16,9 @@
showVeryLongList showDotFiles myName killButton compressTabs
lockUpdate previousDirectory currentFileName timeOfFileRead
tabSpec commandView commandIndex fileEncoding tabRulerView
- scrollView'
+ scrollView icons'
classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon
- CommandHistory CommandHistorySize'
+ CommandHistory CommandHistorySize Icons'
poolDictionaries:''
category:'Interface-Browsers'
!
@@ -154,6 +154,34 @@
^ DefaultIcon
"Modified: 19.3.1997 / 22:23:58 / cg"
+!
+
+directoryIcon
+ ^ Image fromFile:'bitmaps/xpmBitmaps/document_images/tiny_yellow_dir.xpm'.
+
+ "Created: 17.4.1997 / 01:31:11 / cg"
+ "Modified: 17.4.1997 / 02:28:28 / cg"
+!
+
+directoryLinkIcon
+ ^ Image fromFile:'bitmaps/xpmBitmaps/document_images/tiny_yellow_dir_link.xpm'.
+
+ "Modified: 17.4.1997 / 02:28:28 / cg"
+ "Created: 17.4.1997 / 02:29:36 / cg"
+!
+
+fileIcon
+ ^ Image fromFile:'bitmaps/xpmBitmaps/document_images/tiny_file_plain.xpm'.
+
+ "Created: 17.4.1997 / 01:31:20 / cg"
+ "Modified: 17.4.1997 / 02:23:17 / cg"
+!
+
+fileLinkIcon
+ ^ Image fromFile:'bitmaps/xpmBitmaps/document_images/tiny_file_link.xpm'.
+
+ "Modified: 17.4.1997 / 02:23:17 / cg"
+ "Created: 17.4.1997 / 02:32:18 / cg"
! !
!FileBrowser methodsFor:'drag & drop'!
@@ -1492,19 +1520,6 @@
yesButton:yesButtonText
!
-binaryFileAction:aFilename
- "for some binary files, if double clicked, we can do some useful
- action ..."
-
- (currentDirectory pathName , '/' , aFilename) asFilename isExecutable ifTrue:[
- (OperatingSystem executeCommand:'cd ',currentDirectory pathName, '; ',aFilename)
- ifTrue:[^true].
- ].
- ^ self imageAction:aFilename
-
- "Modified: 19.6.1996 / 09:44:07 / cg"
-!
-
changeToPreviousDirectory
"if text was modified show a queryBox,
otherwise change immediately to previous directory."
@@ -1602,22 +1617,6 @@
]
!
-defineTabulatorsForLongList
- "define the tabs for the long list"
-
- tabSpec := TabulatorSpecification new.
- tabSpec unit:#inch.
-"/ tabSpec positions:#(0 2 2.3 4.3 5.3 6.0 6.5).
- tabSpec widths: #(2 0.3 2.0 1 0.5 0.5 1"any").
- " name type mode owner group size type"
- tabSpec align: #(#left #left #left #right #right #decimal #left).
- tabSpec addDependent:self.
-
- tabRulerView tabulatorSpecification:tabSpec.
-
- "Modified: 28.3.1997 / 15:30:25 / cg"
-!
-
doChangeCurrentDirectoryTo:fileName updateHistory:updateHistory
"verify argument is name of a readable & executable directory
and if so, go there"
@@ -2254,8 +2253,252 @@
"Modified: 23.1.1997 / 20:39:25 / cg"
!
+onlyOneSelection
+ "show a warning, that only one file must be selected for
+ this operation"
+
+ self warn:'exactly one file must be selected !!'
+!
+
+selectedFilesDo:aBlock
+ "evaluate aBlock on all selected files;
+ show a wait cursor while doing this"
+
+ |sel|
+
+ sel := fileListView selection.
+ sel notNil ifTrue:[
+ self withWaitCursorDo:[
+ sel do:[:aSelectionIndex |
+ aBlock value:(fileList at:aSelectionIndex )
+ ]
+ ]
+ ]
+
+!
+
+setCurrentDirectory:aPathName
+ "setup for another directory"
+
+ |newDirectory|
+
+ aPathName isEmpty ifTrue:[^ self].
+ (currentDirectory isDirectory:aPathName) ifTrue:[
+ newDirectory := FileDirectory directoryNamed:aPathName in:currentDirectory.
+ newDirectory notNil ifTrue:[
+ self currentDirectory:newDirectory pathName.
+ currentFileName notNil ifTrue:[
+ fileListView contents:nil.
+ currentFileName := nil.
+ ] ifFalse:[
+ fileListView setSelection:nil.
+ fileListView scrollToTop.
+ ].
+ self updateCurrentDirectory.
+ self showInfo.
+ ]
+ ]
+
+ "Modified: 21.9.1995 / 11:22:45 / claus"
+ "Modified: 25.5.1996 / 12:27:01 / cg"
+!
+
+show:something
+ "show something in subview and undef acceptAction"
+
+ subView contents:something.
+ subView acceptAction:nil.
+ subView modified:false.
+ currentFileName := nil
+!
+
+showAlert:aString with:anErrorString
+ "show an alertbox, displaying the last Unix-error"
+
+ |msg|
+
+ anErrorString isNil ifTrue:[
+ msg := aString
+ ] ifFalse:[
+ msg := aString , '\\(' , anErrorString , ')'
+ ].
+ self warn:msg withCRs
+!
+
+showInfo
+ "show directory info when dir has changed"
+
+ |info txt|
+
+ info := self getInfoFile.
+ info notNil ifTrue:[
+ txt := self readFile:info
+ ].
+ self show:txt.
+!
+
+sizePrintString:size
+ "helper for update-directory to return a string with a files size.
+ This one gives the size in byte, Kb or Mb depending on size.
+ If you dont like this, just uncomment the first statement below."
+
+ |unitString n|
+
+"
+ ^ size printString.
+"
+ unitString := ''.
+ size < (500 * 1024) ifTrue:[
+ size < 1024 ifTrue:[
+ n := size
+ ] ifFalse:[
+ n := (size * 10 // 1024 / 10.0).
+ unitString := ' Kb'
+ ]
+ ] ifFalse:[
+ n := (size * 10 // 1024 // 1024 / 10.0).
+ unitString := ' Mb'
+ ].
+ ^ (n printStringLeftPaddedTo:5) , unitString.
+!
+
+validateFontEncodingFor:newEncoding ask:ask
+ "if required, query user if he/she wants to change to another font,
+ which is able to display text encoded as specified by newEncoding"
+
+ |fontsEncoding msg filter f defaultFont|
+
+ fontsEncoding := subView font encoding.
+
+ ((newEncoding == #jis7) or:[newEncoding == #euc]) ifTrue:[
+ (fontsEncoding notNil and:[fontsEncoding startsWith:'jis']) ifFalse:[
+ msg := 'switch to a JIS encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:['jis*' match:coding]].
+ ]
+ ].
+ (newEncoding == #gb) ifTrue:[
+ (fontsEncoding notNil and:[fontsEncoding startsWith:'gb']) ifFalse:[
+ msg := 'switch to a GB encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:['gb*' match:coding]].
+ ]
+ ].
+ (newEncoding == #big5) ifTrue:[
+ (fontsEncoding notNil and:[fontsEncoding startsWith:'big5']) ifFalse:[
+ msg := 'switch to a BIG-5 encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:['big5*' match:coding]].
+ ]
+ ].
+ (newEncoding == #ksc) ifTrue:[
+ (fontsEncoding notNil and:[fontsEncoding startsWith:'ksc']) ifFalse:[
+ msg := 'switch to a KSC encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:['ksc*' match:coding]].
+ ]
+ ] ifFalse:[
+ fontsEncoding notNil ifTrue:[
+ ((fontsEncoding startsWith:'jis')
+ or:[(fontsEncoding startsWith:'gb')
+ or:[(fontsEncoding startsWith:'ksc')
+ or:[(fontsEncoding startsWith:'big5')]]])
+ ifTrue:[
+ msg := 'switch back to an ASCII encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:[('ascii' match:coding)
+ or:['iso*' match:coding]]].
+ defaultFont := TextView defaultFont
+ ] ifFalse:[
+ (fontsEncoding notNil and:[fontsEncoding startsWith:'iso8859']) ifTrue:[
+ msg := 'switch to a ''' , newEncoding , ''' encoded font ?'.
+ filter := [:f | |coding|
+ (coding := f encoding) notNil
+ and:[newEncoding asLowercase = coding asLowercase]].
+ ].
+ ].
+ ]
+ ].
+
+ msg isNil ifTrue:[
+ "/ mhmh - can be represented in current font
+ ].
+
+ msg notNil ifTrue:[
+ defaultFont isNil ifTrue:[
+ defaultFont := device
+ listOfAvailableFonts
+ detect:[:f | filter value:f]
+ ifNone:nil.
+ defaultFont isNil ifTrue:[
+ self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'.
+ ^ self.
+ ]
+ ].
+
+ (ask not or:[self confirm:(resources string:msg) withCRs])
+ ifTrue:[
+ f := FontPanel
+ fontFromUserInitial:defaultFont
+ title:(resources string:'font selection')
+ filter:filter.
+ f notNil ifTrue:[
+ subView font:f
+ ]
+ ]
+ ]
+
+ "Created: 26.10.1996 / 12:06:54 / cg"
+!
+
+withoutHiddenFiles:aCollection
+ "remove hidden files (i.e. those that start with '.') from
+ the list in aCollection"
+
+ |newCollection|
+
+ newCollection := aCollection species new.
+ aCollection do:[:fname |
+ |ignore|
+
+ ignore := false.
+
+ ((fname startsWith:'.') and:[fname ~= '..']) ifTrue:[
+ showDotFiles ifFalse:[
+ ignore := true
+ ]
+ ].
+ ignore ifFalse:[
+ newCollection add:fname
+ ]
+ ].
+ ^ newCollection
+
+ "Modified: 21.2.1996 / 01:33:18 / cg"
+! !
+
+!FileBrowser methodsFor:'private - actions'!
+
+binaryFileAction:aFilename
+ "for some binary files, if double clicked, we can do some useful
+ action ..."
+
+ (currentDirectory pathName , '/' , aFilename) asFilename isExecutable ifTrue:[
+ (OperatingSystem executeCommand:'cd ',currentDirectory pathName, '; ',aFilename)
+ ifTrue:[^true].
+ ].
+ ^ self imageAction:aFilename
+
+ "Modified: 19.6.1996 / 09:44:07 / cg"
+!
+
imageAction:aFilename
- "for some binary files, if double clicked, we can do some useful
+ "for some image files, if double clicked, we can do some useful
action ..."
|img|
@@ -2271,7 +2514,7 @@
^ false
"Created: 19.6.1996 / 09:43:50 / cg"
- "Modified: 1.2.1997 / 15:06:38 / cg"
+ "Modified: 16.4.1997 / 13:56:21 / cg"
!
initialCommandFor:fileName into:aBox
@@ -2401,115 +2644,134 @@
"Created: 19.6.1996 / 09:36:38 / cg"
"Modified: 4.4.1997 / 10:49:00 / cg"
-!
-
-onlyOneSelection
- "show a warning, that only one file must be selected for
- this operation"
-
- self warn:'exactly one file must be selected !!'
-!
-
-selectedFilesDo:aBlock
- "evaluate aBlock on all selected files;
- show a wait cursor while doing this"
-
- |sel|
-
- sel := fileListView selection.
- sel notNil ifTrue:[
- self withWaitCursorDo:[
- sel do:[:aSelectionIndex |
- aBlock value:(fileList at:aSelectionIndex )
- ]
- ]
- ]
-
+! !
+
+!FileBrowser methodsFor:'private - presentation'!
+
+defineTabulatorsForLongList
+ "define the tabs for the long list"
+
+ tabSpec := TabulatorSpecification new.
+ tabSpec unit:#inch.
+"/ tabSpec positions:#(0 0.25 2.3 4.3 5.3 6.0 6.5).
+ tabSpec widths: #(0.25 2 2.0 1 0.5 0.5 1"any").
+ " icon name mode owner group size type"
+ tabSpec align: #(#left #left #left #right #right #decimal #left).
+ tabSpec addDependent:self.
+
+ tabRulerView tabulatorSpecification:tabSpec.
+
+ "Modified: 17.4.1997 / 02:56:07 / cg"
!
-setCurrentDirectory:aPathName
- "setup for another directory"
-
- |newDirectory|
-
- aPathName isEmpty ifTrue:[^ self].
- (currentDirectory isDirectory:aPathName) ifTrue:[
- newDirectory := FileDirectory directoryNamed:aPathName in:currentDirectory.
- newDirectory notNil ifTrue:[
- self currentDirectory:newDirectory pathName.
- currentFileName notNil ifTrue:[
- fileListView contents:nil.
- currentFileName := nil.
- ] ifFalse:[
- fileListView setSelection:nil.
- fileListView scrollToTop.
- ].
- self updateCurrentDirectory.
- self showInfo.
- ]
- ]
-
- "Modified: 21.9.1995 / 11:22:45 / claus"
- "Modified: 25.5.1996 / 12:27:01 / cg"
+defineTabulatorsForShortList
+ "define the tabs for the short list"
+
+ tabSpec := TabulatorSpecification new.
+ tabSpec unit:#inch.
+"/ tabSpec positions:#(0 0.25 ).
+ tabSpec widths: #(0.25 2 ).
+ " icon name"
+ tabSpec align: #(#left #left).
+ tabSpec addDependent:self.
+
+ tabRulerView tabulatorSpecification:tabSpec.
+
+ "Created: 17.4.1997 / 02:51:41 / cg"
+ "Modified: 17.4.1997 / 02:55:17 / cg"
+!
+
+directoryIcon
+ "return an icon used to mark directories"
+
+ |i|
+
+ icons isNil ifTrue:[
+ icons := IdentityDictionary new.
+ ].
+ i := icons at:#directory ifAbsent:nil.
+ i isNil ifTrue:[
+ icons at:#directory put:((i := self class directoryIcon) on:device).
+ ].
+ ^ i
+
+ "Created: 16.4.1997 / 14:00:26 / cg"
+ "Modified: 17.4.1997 / 01:32:36 / cg"
!
-show:something
- "show something in subview and undef acceptAction"
-
- subView contents:something.
- subView acceptAction:nil.
- subView modified:false.
- currentFileName := nil
+directoryLinkIcon
+ "return an icon used to mark directory links"
+
+ |i|
+
+ icons isNil ifTrue:[
+ icons := IdentityDictionary new.
+ ].
+ i := icons at:#directoryLink ifAbsent:nil.
+ i isNil ifTrue:[
+ icons at:#directoryLink put:((i := self class directoryLinkIcon) on:device).
+ ].
+ ^ i
+
+ "Modified: 17.4.1997 / 01:32:36 / cg"
+ "Created: 17.4.1997 / 02:29:27 / cg"
!
-showAlert:aString with:anErrorString
- "show an alertbox, displaying the last Unix-error"
-
- |msg|
-
- anErrorString isNil ifTrue:[
- msg := aString
- ] ifFalse:[
- msg := aString , '\\(' , anErrorString , ')'
+fileIcon
+ "return an icon used to mark files"
+
+ |i|
+
+ icons isNil ifTrue:[
+ icons := IdentityDictionary new.
].
- self warn:msg withCRs
+ i := icons at:#file ifAbsent:nil.
+ i isNil ifTrue:[
+ icons at:#file put:((i := self class fileIcon) on:device).
+ ].
+ ^ i
+
+ "Created: 16.4.1997 / 14:00:26 / cg"
+ "Modified: 17.4.1997 / 01:32:47 / cg"
!
-showInfo
- "show directory info when dir has changed"
-
- |info txt|
-
- info := self getInfoFile.
- info notNil ifTrue:[
- txt := self readFile:info
+fileLinkIcon
+ "return an icon used to mark link files"
+
+ |i|
+
+ icons isNil ifTrue:[
+ icons := IdentityDictionary new.
].
- self show:txt.
+ i := icons at:#fileLink ifAbsent:nil.
+ i isNil ifTrue:[
+ icons at:#fileLink put:((i := self class fileLinkIcon) on:device).
+ ].
+ ^ i
+
+ "Modified: 17.4.1997 / 01:32:47 / cg"
+ "Created: 17.4.1997 / 02:32:09 / cg"
!
-sizePrintString:size
- "helper for update-directory to return a string with a files size.
- This one gives the size in byte, Kb or Mb depending on size.
- If you dont like this, just uncomment the first statement below."
-
- |unitString n|
-
-"
- ^ size printString.
-"
- unitString := ''.
- size < (500 * 1024) ifTrue:[
- size < 1024 ifTrue:[
- n := size
- ] ifFalse:[
- n := (size * 10 // 1024 / 10.0).
- unitString := ' Kb'
- ]
- ] ifFalse:[
- n := (size * 10 // 1024 // 1024 / 10.0).
- unitString := ' Mb'
+iconForFile:aFilenameString
+ "update listView with directory contents"
+
+ |f|
+
+ f := currentDirectory asFilename construct:aFilenameString.
+ f isDirectory ifTrue:[
+ f isSymbolicLink ifTrue:[
+ ^ self directoryLinkIcon
+ ].
+ ^ self directoryIcon
].
- ^ (n printStringLeftPaddedTo:5) , unitString.
+ f isSymbolicLink ifTrue:[
+ ^ self fileLinkIcon
+ ].
+ ^ self fileIcon
+
+ "Created: 16.4.1997 / 13:53:49 / cg"
+ "Modified: 17.4.1997 / 02:31:50 / cg"
!
updateCurrentDirectory
@@ -2566,12 +2828,13 @@
the files info ...
"
Processor activeProcess withLowerPriorityDo:[
- |prevUid prevGid nameString groupString modeString info line len text |
+ |prevUid prevGid nameString groupString modeString info line len text firstItem|
"
first show the names only - this is relatively fast
"
fileListView setList:files expandTabs:false.
+ firstItem := true.
"
then walk over the files, adding more info
@@ -2598,6 +2861,10 @@
"
realized ifFalse:[^ self].
+ col := 1.
+ entry colAt:col put:(self iconForFile:aFileName).
+ col := col + 1.
+
len := aFileName size.
(len < 20) ifTrue:[
line := aFileName , (String new:(22 - len))
@@ -2605,44 +2872,54 @@
"can happen on BSD only"
line := (aFileName copyTo:20) , ' '
].
- entry colAt:1 put:line.
+ entry colAt:col put:line.
+ col := col + 1.
info := currentDirectory infoOf:aFileName.
info isNil ifTrue:[
"not accessable - usually a symlink,
to a nonexisting/nonreadable file
"
- entry colAt:2 put:'?'.
- entry colAt:3 put:'(bad symbolic link ?)'.
+"/ entry colAt:col put:'?'.
+"/ col := col + 1.
+ entry colAt:col put:'(bad symbolic link ?)'.
+ col := col + 1.
] ifFalse:[
typ := (info type).
- (typ == #regular) ifFalse:[
- entry colAt:2 put:(typ at:1) asString.
- ] ifTrue:[
- entry colAt:2 put:' '.
- ].
+"/ (typ == #regular) ifFalse:[
+"/ entry colAt:col put:(typ at:1) asString.
+"/ ] ifTrue:[
+"/ entry colAt:col put:' '.
+"/ ].
+"/ col := col + 1.
+
modeString := self getModeString:(info at:#mode)
with:#( '' $r $w $x
' ' $r $w $x
' ' $r $w $x ).
- entry colAt:3 put:modeString.
+ entry colAt:col put:modeString.
+ col := col + 1.
((info uid) ~~ prevUid) ifTrue:[
prevUid := (info uid).
nameString := OperatingSystem getUserNameFromID:prevUid.
nameString := nameString , (String new:(10 - nameString size))
].
- entry colAt:4 put:nameString withoutSpaces.
+ entry colAt:col put:nameString withoutSpaces.
+ col := col + 1.
+
((info gid) ~~ prevGid) ifTrue:[
prevGid := (info gid).
groupString := OperatingSystem getGroupNameFromID:prevGid.
groupString := groupString , (String new:(10 - groupString size))
].
- entry colAt:5 put:groupString withoutSpaces.
+ entry colAt:col put:groupString withoutSpaces.
+ col := col + 1.
(typ == #regular) ifTrue:[
- entry colAt:6 put:(self sizePrintString:(info size)).
+ entry colAt:col put:(self sizePrintString:(info size)).
].
+ col := col + 1.
f := currentDirectory asFilename:aFileName.
f isSymbolicLink ifTrue:[
@@ -2655,14 +2932,16 @@
typeString := f fileType.
].
].
- entry colAt:7 put:typeString.
+ entry colAt:col put:typeString.
text add:entry
].
fileListView at:lineIndex put:entry
].
] ifFalse:[
+ tabSpec isNil ifTrue:[self defineTabulatorsForShortList].
+
files keysAndValuesDo:[:lineIndex :aName |
- |entry|
+ |entry fileName|
"
if multiple FileBrowsers are reading, let others
@@ -2674,11 +2953,25 @@
((currentDirectory isDirectory:aName) and:[
(aName ~= '..') and:[aName ~= '.']]) ifTrue:[
- entry := aName , ' ...'
+ fileName := aName , ' ...'
] ifFalse:[
- entry := aName
+ fileName := aName
].
- fileListView at:lineIndex put:entry
+"/ firstItem ifTrue:[
+"/ firstItem := false.
+"/ fileListView fontHeight:30.
+"/ fileListView computeNumberOfLinesShown.
+"/ fileListView redraw.
+"/ ].
+
+ entry := MultiColListEntry new.
+ entry tabulatorSpecification:tabSpec.
+ entry colAt:1 put:(self iconForFile:aName).
+ entry colAt:2 put:fileName.
+
+ fileListView
+ at:lineIndex
+ put:entry
].
].
].
@@ -2690,127 +2983,7 @@
]
"Modified: 21.9.1995 / 11:40:23 / claus"
- "Modified: 15.4.1997 / 15:53:28 / cg"
-!
-
-validateFontEncodingFor:newEncoding ask:ask
- "if required, query user if he/she wants to change to another font,
- which is able to display text encoded as specified by newEncoding"
-
- |fontsEncoding msg filter f defaultFont|
-
- fontsEncoding := subView font encoding.
-
- ((newEncoding == #jis7) or:[newEncoding == #euc]) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'jis']) ifFalse:[
- msg := 'switch to a JIS encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['jis*' match:coding]].
- ]
- ].
- (newEncoding == #gb) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'gb']) ifFalse:[
- msg := 'switch to a GB encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['gb*' match:coding]].
- ]
- ].
- (newEncoding == #big5) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'big5']) ifFalse:[
- msg := 'switch to a BIG-5 encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['big5*' match:coding]].
- ]
- ].
- (newEncoding == #ksc) ifTrue:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'ksc']) ifFalse:[
- msg := 'switch to a KSC encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:['ksc*' match:coding]].
- ]
- ] ifFalse:[
- fontsEncoding notNil ifTrue:[
- ((fontsEncoding startsWith:'jis')
- or:[(fontsEncoding startsWith:'gb')
- or:[(fontsEncoding startsWith:'ksc')
- or:[(fontsEncoding startsWith:'big5')]]])
- ifTrue:[
- msg := 'switch back to an ASCII encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:[('ascii' match:coding)
- or:['iso*' match:coding]]].
- defaultFont := TextView defaultFont
- ] ifFalse:[
- (fontsEncoding notNil and:[fontsEncoding startsWith:'iso8859']) ifTrue:[
- msg := 'switch to a ''' , newEncoding , ''' encoded font ?'.
- filter := [:f | |coding|
- (coding := f encoding) notNil
- and:[newEncoding asLowercase = coding asLowercase]].
- ].
- ].
- ]
- ].
-
- msg isNil ifTrue:[
- "/ mhmh - can be represented in current font
- ].
-
- msg notNil ifTrue:[
- defaultFont isNil ifTrue:[
- defaultFont := device
- listOfAvailableFonts
- detect:[:f | filter value:f]
- ifNone:nil.
- defaultFont isNil ifTrue:[
- self warn:'your display does not seem to provide any ' , newEncoding , '-encoded font.'.
- ^ self.
- ]
- ].
-
- (ask not or:[self confirm:(resources string:msg) withCRs])
- ifTrue:[
- f := FontPanel
- fontFromUserInitial:defaultFont
- title:(resources string:'font selection')
- filter:filter.
- f notNil ifTrue:[
- subView font:f
- ]
- ]
- ]
-
- "Created: 26.10.1996 / 12:06:54 / cg"
-!
-
-withoutHiddenFiles:aCollection
- "remove hidden files (i.e. those that start with '.') from
- the list in aCollection"
-
- |newCollection|
-
- newCollection := aCollection species new.
- aCollection do:[:fname |
- |ignore|
-
- ignore := false.
-
- ((fname startsWith:'.') and:[fname ~= '..']) ifTrue:[
- showDotFiles ifFalse:[
- ignore := true
- ]
- ].
- ignore ifFalse:[
- newCollection add:fname
- ]
- ].
- ^ newCollection
-
- "Modified: 21.2.1996 / 01:33:18 / cg"
+ "Modified: 17.4.1997 / 02:59:28 / cg"
! !
!FileBrowser methodsFor:'private-file-I/O'!
@@ -3080,5 +3253,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.138 1997-04-15 13:54:39 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.139 1997-04-17 01:34:20 cg Exp $'
! !