--- a/MIMETypes.st Thu Jul 10 14:24:24 2014 +0200
+++ b/MIMETypes.st Thu Jul 10 21:45:59 2014 +0200
@@ -19,12 +19,13 @@
FilenameToTypeMapping FileSuffixToImageReaderClassMapping
CharSetToFontMapping LastSuffix LastType
DefaultCommandPerMIMEPerOS DefaultPrintCommandPerMIMEPerOS
- TypeToParenthesisSpecMapping SuffixToParenthesisSpecMapping'
+ TypeToParenthesisSpecMapping SuffixToParenthesisSpecMapping
+ TypeToInfoMapping'
poolDictionaries:''
category:'Net-Communication-Support'
!
-String variableByteSubclass:#MIMEType
+ImmutableString variableByteSubclass:#MIMEType
instanceVariableNames:''
classVariableNames:'CachedTypes'
poolDictionaries:''
@@ -120,16 +121,18 @@
!
initializeCommentStringMappings
+ "these are used by the editor's comment/uncomment functions"
+
TypeToCommentStringMapping := Dictionary new.
SuffixToCommentStringMapping := Dictionary new.
TypeToCommentStringMapping
at:'application/x-make'
- put:#('#' (nil nil)). "/ '#' for EOL comments only
+ put:#('#' (nil nil)). "/ '#' EOL comments only
TypeToCommentStringMapping
at:'application/x-sh'
- put:#('#' (nil nil)). "/ '#' for EOL comments only
+ put:#('#' (nil nil)). "/ '#' EOL comments only
#('text/html' 'text/xml'
'application/xml'
@@ -155,7 +158,6 @@
at:'application/x-smalltalk-source'
put:#('"/' ('"' '"')). "/ '"/ ' for EOL; ".." for delimited comments
-
"/ this is for standard smalltalk
"/ TypeToCommentStringMapping
"/ at:'application/x-smalltalk-source'
@@ -166,11 +168,6 @@
at:'application/x-pascal-source'
put:#(nil ('{' '}')). "/ '{'..'}' for delimited comments
-
-"/ "/ the following is k&r
-"/ TypeToCommentStringMapping
-"/ at:'application/x-c-source'
-"/ put:#(nil ('/*' '*/')). "/ '/*'..'*/' for delimited comments
"/ this is ANSI-c
TypeToCommentStringMapping
at:'application/x-c-source'
@@ -214,7 +211,9 @@
!
initializeDefaultCommands
- "TODO: move this to OS"
+ "these are used to select an application to be opened when a file of a particular
+ type is double clicked in the browser.
+ TODO: move this to OS"
|unixCommands win32Commands unixPrintCommands win32PrintCommands listToTry|
@@ -264,6 +263,33 @@
"Modified: / 12-05-2004 / 11:43:23 / cg"
!
+initializeFileInfoMappings
+ "these are used by the file browser if a 'file' command is not present in the OS"
+
+ TypeToInfoMapping := Dictionary new.
+
+ TypeToInfoMapping at:'application/x-smalltalk-source' put:'Smalltalk source'.
+ TypeToInfoMapping at:'text/html' put:'HTML document'.
+ TypeToInfoMapping at:'text/xml' put:'XML document'.
+ TypeToInfoMapping at:'application/xml' put:'XML document'.
+ TypeToInfoMapping at:'application/x-c-source' put:'C source'.
+ TypeToInfoMapping at:'application/x-c-header' put:'C header file'.
+ TypeToInfoMapping at:'application/x-cpp-source' put:'C++ source'.
+ TypeToInfoMapping at:'application/x-csharp-source' put:'C# source'.
+ TypeToInfoMapping at:'application/x-java-source' put:'Java source'.
+ TypeToInfoMapping at:'application/x-javascript' put:'Javascript source'.
+ TypeToInfoMapping at:'application/x-lisp-source' put:'Lisp source'.
+
+ TypeToInfoMapping at:'application/x-make' put:'make rules'.
+ TypeToInfoMapping at:'application/binary' put:'binary object file'.
+
+ "
+ self initializeFileInfoMappings
+ 'foo.H' asFilename mimeTypeFromName
+ 'foo.o' asFilename mimeTypeFromName
+ "
+!
+
initializeFileNameToMimeTypeMapping
"initialize wellKnown facts"
@@ -317,6 +343,8 @@
!
initializeImageReaderMappings
+ "these are used so select an image reader, based on a bitmap image's mime type"
+
|rdr|
FileSuffixToImageReaderClassMapping isNil ifTrue:[
@@ -409,7 +437,7 @@
FileSuffixToImageReaderClassMapping at:'ras' put:rdr.
].
- "/ movie formats - experimantal and not yet complete / finished / delivered
+ "/ movie formats - experimental and not yet complete / finished / delivered / published
"/ (rdr := Smalltalk at:#FLIReader) notNil ifTrue:[
"/ TypeToImageReaderClassMapping at:'video/x-fli' put:rdr.
"/ FileSuffixToImageReaderClassMapping at:'fli' put:rdr.
@@ -451,13 +479,14 @@
!
initializeParenthesisSpecMappings
+ "these are used by the editors to mark matching parenthesis"
+
|spec|
TypeToParenthesisSpecMapping := Dictionary new.
SuffixToParenthesisSpecMapping := Dictionary new.
"/ ST/X spec
-
spec := IdentityDictionary new.
spec at:#open put:#( $( $[ ${ ).
spec at:#close put:#( $) $] $} ).
@@ -466,7 +495,6 @@
TypeToParenthesisSpecMapping at:'application/x-smalltalk-source' put:spec.
"/ XML & HTML
-
spec := IdentityDictionary new.
spec at:#open put:#( $< ).
spec at:#close put:#( $> ).
@@ -475,8 +503,7 @@
TypeToParenthesisSpecMapping at:eachXMLType put:spec
].
- "/ ANSI-c, Java, C#
-
+ "/ ANSI-c, Java, C#
spec := IdentityDictionary new.
spec at:#open put:#( $( $[ ${ ).
spec at:#close put:#( $) $] $} ).
@@ -488,8 +515,7 @@
TypeToParenthesisSpecMapping at:'application/x-java-source' put:spec.
TypeToParenthesisSpecMapping at:'application/x-javascript' put:spec.
- "/ Lisp
-
+ "/ Lisp / Scheme
spec := IdentityDictionary new.
spec at:#open put:#( $( $[ ).
spec at:#close put:#( $) $] ).
@@ -769,6 +795,18 @@
].
!
+fileInfoForMimeType:mimeType
+ "given a mimeType, return an info string similar to what the unix 'file' command
+ provides. This info here is returned by systems which have no file (i.e. MSDOS) and
+ for types of which file does not know about (smalltalk files, for example)"
+
+ ^ TypeToInfoMapping at:mimeType ifAbsent:nil
+
+ "
+ self fileInfoForMimeType:(MIMEType fromString:'image/gif')
+ "
+!
+
fileSuffixToImageReaderMapping
"return the suffix-to-imageReader mapping"
@@ -987,6 +1025,9 @@
('---- timestamp ' #'application/x-smalltalk-source')
('from dolphin' #'application/x-smalltalk-source')
('from visualworks' #'application/x-smalltalk-source')
+ ('from squeak' #'application/x-smalltalk-source')
+ ('from smalltalk/x' #'application/x-smalltalk-source')
+ ('"{ Package:' #'application(x-smalltalk-source')
('categoriesforclass' #'application/x-smalltalk-source')
('methodsfor!!' #'application/x-smalltalk-source')
('subclass:' #'application/x-smalltalk-source')
@@ -1355,6 +1396,7 @@
documentation
"
like a string, but knows that it represents a mimeType.
+ mimetypes are singletons, remembered in the class variable CachedTypes.
"
! !
@@ -1384,6 +1426,14 @@
!MIMETypes::MIMEType methodsFor:'queries'!
+fileTypeInfo
+ ^ MIMETypes fileTypeInfoForMimeType:self
+
+ "
+ (MIMETypes mimeTypeFromString:'application/x-smalltalk-source') fileTypeInfo
+ "
+!
+
isArchive
<resource: #obsolete>
"return true, if I represent an archive type (such as zip or tar)"
@@ -1465,7 +1515,7 @@
isSmalltalkSourceType
"return true, if I represent the smalltalk sourcecode type"
- ^ (self = 'application/x-smalltalk-source')
+ ^ (self startsWith: 'application/x-smalltalk-source')
!
isTextType
@@ -1498,11 +1548,11 @@
!MIMETypes class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.134 2014-05-14 18:30:35 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.135 2014-07-10 19:45:59 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.134 2014-05-14 18:30:35 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.135 2014-07-10 19:45:59 cg Exp $'
! !