--- a/AbstractFileBrowser.st Mon May 26 11:33:51 2003 +0200
+++ b/AbstractFileBrowser.st Wed May 28 10:21:21 2003 +0200
@@ -1498,28 +1498,28 @@
#label: '-'
)
#(#MenuItem
+ #enabled: #hasSelection
#label: 'Copy'
+ #itemValue: #copyFiles
#translateLabel: true
- #value: #copyFiles
- #enabled: #hasSelection
)
#(#MenuItem
+ #enabled: #hasSelection
#label: 'Cut'
+ #itemValue: #cutFiles
#translateLabel: true
- #value: #cutFiles
- #enabled: #hasSelection
)
#(#MenuItem
+ #enabled: #canPaste
#label: 'Paste'
+ #itemValue: #pasteFiles
#translateLabel: true
- #value: #pasteFiles
- #enabled: #canPaste
)
#(#MenuItem
+ #enabled: #hasSelection
#label: 'Delete'
+ #itemValue: #deleteFiles
#translateLabel: true
- #value: #deleteFiles
- #enabled: #hasSelection
)
#(#MenuItem
#label: '-'
@@ -1541,19 +1541,9 @@
#label: '-'
)
#(#MenuItem
- #label: 'Truncate...'
- #itemValue: #truncateSelectedFilesToZeroSize
+ #label: 'Operations'
#translateLabel: true
- )
- #(#MenuItem
- #label: 'Split...'
- #itemValue: #splitSelectedFiles
- #translateLabel: true
- )
- #(#MenuItem
- #label: 'Join...'
- #itemValue: #joinSelectedFiles
- #translateLabel: true
+ #submenuChannel: #fileOpMenu
)
#(#MenuItem
#label: '-'
@@ -1612,6 +1602,56 @@
)
!
+fileOpMenu
+ "This resource specification was automatically generated
+ by the MenuEditor of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the MenuEditor may not be able to read the specification."
+
+ "
+ MenuEditor new openOnClass:AbstractFileBrowser andSelector:#fileOpMenu
+ (Menu new fromLiteralArrayEncoding:(AbstractFileBrowser fileOpMenu)) startUp
+ "
+
+ <resource: #menu>
+
+ ^
+ #(#Menu
+ #(
+ #(#MenuItem
+ #label: 'Split...'
+ #itemValue: #splitSelectedFiles
+ #translateLabel: true
+ )
+ #(#MenuItem
+ #label: 'Join...'
+ #itemValue: #joinSelectedFiles
+ #translateLabel: true
+ )
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
+ #label: 'Rot13...'
+ #itemValue: #filterSelectedFiles:
+ #translateLabel: true
+ #argument: #rot13
+ )
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
+ #label: 'Truncate...'
+ #itemValue: #truncateSelectedFilesToZeroSize
+ #translateLabel: true
+ )
+ )
+ nil
+ nil
+ )
+!
+
newMenu
"This resource specification was automatically generated
by the MenuEditor of ST/X."
@@ -4598,6 +4638,69 @@
].
!
+filterSelectedFiles:whichFilter
+ |selectedFiles numFiles msg filterBlock|
+
+ selectedFiles := self currentFileNameHolder value.
+ (numFiles := selectedFiles size) == 0 ifTrue:[^ self].
+
+ msg := 'Replace contents of file ''%2'' with output of %3-filter ?'.
+ numFiles > 1 ifTrue:[
+ msg := 'Replace contents of %1 files with output of %3-filter ?'.
+ ].
+
+ (Dialog
+ confirm:(msg bindWith:numFiles with:selectedFiles first baseName allBold with:whichFilter) withCRs
+ initialAnswer:false
+ ) ifFalse:[
+ ^ self
+ ].
+
+ whichFilter == #rot13 ifTrue:[
+ filterBlock := [:charIn | charIn rot13 ].
+ ].
+ "/ add more here...
+
+ filterBlock isNil ifTrue:[
+ self information:'No such filter: ' , whichFilter.
+ ^ self.
+ ].
+
+ selectedFiles do:[:fileName |
+ |s|
+
+ self notify:('Processing:', fileName baseName).
+ fileName isDirectory ifFalse:[
+ [
+ |inFile outFile in out|
+
+ inFile := fileName asFilename.
+ outFile := (fileName pathName , '.filter') asFilename.
+
+ [
+ |charIn charOut|
+
+ in := inFile readStream.
+ out := outFile writeStream.
+ [in atEnd] whileFalse:[
+ charIn := in next.
+ charOut := filterBlock value:charIn.
+ out nextPut:charOut.
+ ].
+ outFile renameTo:inFile.
+ ] ensure:[
+ out notNil ifTrue:[ out close ].
+ in notNil ifTrue:[ in close ].
+ outFile delete.
+ ]
+ ] on:FileStream openErrorSignal do:[:ex|
+ self warn:('Cannot process "%1".' bindWith:fileName baseName allBold).
+ ].
+ ]
+ ].
+ self notify:''.
+!
+
installAllAsAutoloaded
"install all classes found here as autoloaded classes"
@@ -5139,13 +5242,13 @@
selectedFiles := self currentFileNameHolder value.
(numFiles := selectedFiles size) == 0 ifTrue:[^ self].
- msg := 'Really truncate %2 ?\\WARNING: contents of file is lost !!\This cannot be undone.'.
+ msg := 'Really truncate file ''%2'' to zero length ?\\WARNING: contents of file is lost !!\This cannot be undone.'.
numFiles > 1 ifTrue:[
- msg := 'Really truncate %1 files ?\\WARNING: contents of files is lost !!\This cannot be undone.'.
+ msg := 'Really truncate %1 files to zero length ?\\WARNING: contents of files is lost !!\This cannot be undone.'.
].
(Dialog
- confirm:(msg bindWith:numFiles with:selectedFiles first baseName) withCRs
+ confirm:(msg bindWith:numFiles with:selectedFiles first baseName allBold) withCRs
initialAnswer:false
) ifFalse:[
^ self
@@ -6178,5 +6281,5 @@
!AbstractFileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.146 2003-05-22 15:51:19 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.147 2003-05-28 08:21:21 cg Exp $'
! !