--- a/MIMETypes.st Thu May 17 13:11:53 2001 +0200
+++ b/MIMETypes.st Fri May 18 18:50:04 2001 +0200
@@ -241,6 +241,92 @@
!MIMETypes class methodsFor:'accessing'!
+commentStringsForFilename:aFilename
+ "return a useful comment definition; heuristics for now.
+ The returned value is an array of 2 elements;
+ the first is the end-of-line comment string (or nil);
+ the second an array of opening/closing delimiters (or an array of nils)"
+
+ |mime|
+
+ mime := MIMETypes mimeTypeForFilename:aFilename.
+ ^ self commentStringsForMimeType:mime suffix:(aFilename asFilename suffix)
+
+ "
+ MIMETypes commentStringsForFilename:'Makefile'.
+ MIMETypes commentStringsForFilename:'Object.st'.
+ MIMETypes commentStringsForFilename:'Foo.java'.
+ "
+!
+
+commentStringsForMimeType:mime suffix:suff
+ "return a useful comment definition; heuristics for now.
+ The returned value is an array of 2 elements;
+ the first is the end-of-line comment string (or nil);
+ the second an array of opening/closing delimiters (or an array of nils)"
+
+ (mime = 'application/x-make') ifTrue:[
+ "/ makefile
+ ^ #('#' (nil nil)).
+ ].
+ (mime = 'application/x-sh') ifTrue:[
+ "/ shell script
+ ^ #('#' (nil nil)).
+ ].
+ ((mime = 'text/html')
+ or:[(mime = 'text/xml')
+ or:[(mime = 'application/xml')]]) ifTrue:[
+ ^ #(nil ('<!!-- ' ' -->')).
+ ].
+ (mime = 'application/x-batch-script') ifTrue:[
+ ^ #('rem ' (nil nil)).
+ ].
+ (mime = 'application/x-smalltalk-source') ifTrue:[
+ ^ #('"/' ('"' '"')).
+ ].
+ (mime = 'application/x-pascal-source') ifTrue:[
+ ^ #(nil ('{' '}')).
+ ].
+ (mime = 'application/x-c-source') ifTrue:[
+ ^ #(nil ('/*' '*/')).
+ ].
+ (mime = 'application/x-cpp-source') ifTrue:[
+ ^ #('//' ('/*' '*/')).
+ ].
+ (mime = 'application/x-java-source') ifTrue:[
+ ^ #('//' ('/*' '*/')).
+ ].
+ (mime = 'application/x-asn1-source') ifTrue:[
+ ^ #('--' ('--' '--')).
+ ].
+
+ "/ st/x support files
+ (suff = 'style') ifTrue:[
+ ^ #(';' (nil nil)).
+ ].
+ (suff = 'rs') ifTrue:[
+ ^ #(';' (nil nil)).
+ ].
+
+ "/ default: shell comments
+
+ ^ #(';' (nil nil)).
+
+ "
+ |mime|
+
+ mime := MIMETypes mimeTypeForFilename:'Makefile'.
+ MIMETypes commentStringsForMimeType:mime suffix:nil.
+ "
+
+ "
+ |mime|
+
+ mime := MIMETypes mimeTypeForFilename:'Object.st'.
+ MIMETypes commentStringsForMimeType:mime suffix:nil.
+ "
+!
+
defineImageType:mimeType suffix:aSuffix reader:aReaderClass
"register an image reader."
@@ -443,6 +529,6 @@
!MIMETypes class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.28 2000-09-25 13:11:00 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/MIMETypes.st,v 1.29 2001-05-18 16:50:04 cg Exp $'
! !
MIMETypes initialize!