--- a/FileBrowser.st Tue May 18 14:20:09 1999 +0200
+++ b/FileBrowser.st Tue May 18 21:12:43 1999 +0200
@@ -4467,24 +4467,29 @@
"for some image files, if double clicked, we can do some useful
action ..."
- |img|
+ |img errmsg|
(Image isImageFileSuffix:(aFilename asFilename suffix))
ifTrue:[
- img := Image fromFile:(currentDirectory construct:aFilename).
- img notNil ifTrue:[
- ImageEditor openOnImage:img.
+ Image imageLoadErrorSignal handle:[:ex |
+ errmsg := ex errorString
+ ] do:[
+ img := Image fromFile:(currentDirectory construct:aFilename).
+ ].
+ img notNil ifTrue:[
+ ImageEditor openOnImage:img.
"/ img inspect.
- ^ true
- ]
+ ^ true
+ ].
+ errmsg notNil ifTrue:[
+ self warn:errmsg.
+ ]
].
^ false
- "Created: 19.6.1996 / 09:43:50 / cg"
- "Modified: 18.4.1997 / 14:56:04 / cg"
- "Modified: 18.9.1997 / 16:35:48 / stefan"
-
-
+ "Created: / 19.6.1996 / 09:43:50 / cg"
+ "Modified: / 18.9.1997 / 16:35:48 / stefan"
+ "Modified: / 18.5.1999 / 15:45:06 / cg"
!
initialCommandFor:fileName into:aBox
@@ -5811,20 +5816,20 @@
fontsEncoding pref failWarning|
fileName asFilename isAbsolute ifFalse:[
- path := currentDirectory filenameFor:fileName.
+ path := currentDirectory filenameFor:fileName.
] ifTrue:[
- path := fileName asFilename asAbsoluteFilename
+ path := fileName asFilename asAbsoluteFilename
].
(path type == #regular) ifFalse:[
- "asked for a non-file - ignore it ..."
- path exists ifFalse:[
- msg := '''%1'' does not exist !!'.
- ] ifTrue:[
- msg := '''%1'' is not a regular file !!'.
- ].
- self warn:(resources string:msg with:fileName).
- ^ self
+ "asked for a non-file - ignore it ..."
+ path exists ifFalse:[
+ msg := '''%1'' does not exist !!'.
+ ] ifTrue:[
+ msg := '''%1'' is not a regular file !!'.
+ ].
+ self warn:(resources string:msg with:fileName).
+ ^ self
].
"/
@@ -5832,9 +5837,9 @@
"/
s := path readStream.
s isNil ifTrue:[
- self showAlert:(resources string:'cannot read file ''%1'' !!' with:fileName)
- with:(FileStream lastErrorString).
- ^ nil
+ self showAlert:(resources string:'cannot read file ''%1'' !!' with:fileName)
+ with:(FileStream lastErrorString).
+ ^ nil
].
buffer := String new:4096.
@@ -5846,44 +5851,44 @@
guess := self guessEncodingFrom:buffer.
guess == #binary ifTrue:[
- ok := false.
- viaDoubleClick ifTrue:[
- (self binaryFileAction:fileName) ifTrue:[^ self].
- ].
- (self confirm:(resources string:'''%1'' seems to be a binary file - show anyway ?' with:fileName))
- ifFalse:[^ self]
+ ok := false.
+ viaDoubleClick ifTrue:[
+ (self binaryFileAction:fileName) ifTrue:[^ self].
+ ].
+ (self confirm:(resources string:'''%1'' seems to be a binary file (or unsupported format) - show anyway ?' with:fileName))
+ ifFalse:[^ self]
] ifFalse:[
- viaDoubleClick ifTrue:[
- (self nonBinaryFileAction:fileName) ifTrue:[^ self].
- ].
-
- fontsEncoding := subView font encoding.
- pref := self preferredFontEncodingFor:guess.
-
- ok := pref match:fontsEncoding.
- ok ifFalse:[
- pref = 'iso8859*' ifTrue:[
- ok := 'ascii*' match:fontsEncoding
- ]
- ].
- ok ifTrue:[
- fileEncoding := guess.
- enc := guess.
- ] ifFalse:[
- action := Dialog choose:(resources string:'''%1'' seems to require a %2 font.' with:fileName with:pref)
- labels:(resources array:#('cancel' 'show' 'change font'))
- values:#(nil #show #encoding)
- default:#encoding.
- action isNil ifTrue:[^ self].
- action == #encoding ifTrue:[
- fileEncoding := guess asSymbol.
- subView externalEncoding:fileEncoding.
- self validateFontEncodingFor:fileEncoding ask:false.
- ] ifFalse:[
- self information:(resources string:'Individual characters may be invisible/wrong in this font.')
- ].
- enc := fileEncoding.
- ].
+ viaDoubleClick ifTrue:[
+ (self nonBinaryFileAction:fileName) ifTrue:[^ self].
+ ].
+
+ fontsEncoding := subView font encoding.
+ pref := self preferredFontEncodingFor:guess.
+
+ ok := pref match:fontsEncoding.
+ ok ifFalse:[
+ pref = 'iso8859*' ifTrue:[
+ ok := 'ascii*' match:fontsEncoding
+ ]
+ ].
+ ok ifTrue:[
+ fileEncoding := guess.
+ enc := guess.
+ ] ifFalse:[
+ action := Dialog choose:(resources string:'''%1'' seems to require a %2 font.' with:fileName with:pref)
+ labels:(resources array:#('cancel' 'show' 'change font'))
+ values:#(nil #show #encoding)
+ default:#encoding.
+ action isNil ifTrue:[^ self].
+ action == #encoding ifTrue:[
+ fileEncoding := guess asSymbol.
+ subView externalEncoding:fileEncoding.
+ self validateFontEncodingFor:fileEncoding ask:false.
+ ] ifFalse:[
+ self information:(resources string:'Individual characters may be invisible/wrong in this font.')
+ ].
+ enc := fileEncoding.
+ ].
].
convert := false.
@@ -5904,48 +5909,48 @@
"/ ].
insert ifFalse:[
- "/ release old text first
- "/ - we might need the memory in case of huge files
- "/ (helps if you have a 4Mb file in the view,
- "/ and click on another biggy)
-
- subView contents:nil.
+ "/ release old text first
+ "/ - we might need the memory in case of huge files
+ "/ (helps if you have a 4Mb file in the view,
+ "/ and click on another biggy)
+
+ subView contents:nil.
].
convert ifTrue:[
- eol := Character value:13
+ eol := Character value:13
] ifFalse:[
- eol := Character cr
+ eol := Character cr
].
failWarning := false.
CharacterArray decodingFailedSignal handle:[:ex |
- |errStr|
-
- failWarning ifFalse:[
- errStr := resources string:ex errorString.
- (self confirm:(resources
- string:'An error occurred while decoding:\%1\\The file has either a different encoding or is corrupted.\\Continue ?'
- with:errStr) withCRs)
- ifFalse:[
- ^ self
- ].
- failWarning := true.
- ].
- ex proceed.
+ |errStr|
+
+ failWarning ifFalse:[
+ errStr := resources string:ex errorString.
+ (self confirm:(resources
+ string:'An error occurred while decoding:\%1\\The file has either a different encoding or is corrupted.\\Continue ?'
+ with:errStr) withCRs)
+ ifFalse:[
+ ^ self
+ ].
+ failWarning := true.
+ ].
+ ex proceed.
] do:[
- text := self readFile:fileName lineDelimiter:eol encoding:enc.
+ text := self readFile:fileName lineDelimiter:eol encoding:enc.
].
insert ifFalse:[
- self show:text
+ self show:text
] ifTrue:[
- subView insertSelectedStringAtCursor:text asString
+ subView insertSelectedStringAtCursor:text asString
].
"Created: / 19.6.1996 / 09:39:52 / cg"
"Modified: / 18.9.1997 / 17:10:20 / stefan"
- "Modified: / 4.2.1999 / 17:50:48 / cg"
+ "Modified: / 18.5.1999 / 15:51:18 / cg"
!
writeFile:fileName text:someText encoding:encoding
@@ -6628,5 +6633,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.321 1999-05-08 18:26:17 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.322 1999-05-18 19:12:43 cg Exp $'
! !