--- a/FileBrowser.st Fri Jan 19 11:10:10 2001 +0100
+++ b/FileBrowser.st Fri Jan 19 11:17:54 2001 +0100
@@ -24,7 +24,7 @@
imageRenderProcess dosEOLMode doAutoUpdate doNotShowFontDialog'
classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon
CommandHistory CommandHistorySize Icons DefaultCommandPerSuffix
- DefaultCommandPerMIME'
+ DefaultCommandPerMIME VisitedFileHistory'
poolDictionaries:''
category:'Interface-Browsers'
!
@@ -126,6 +126,15 @@
"Modified: / 17.6.1998 / 11:25:29 / cg"
! !
+!FileBrowser class methodsFor:'aspects'!
+
+hasVisitHistory
+ ^ [DirectoryHistory size > 0]
+
+ "Created: / 14.8.1998 / 19:17:02 / cg"
+ "Modified: / 14.8.1998 / 19:17:17 / cg"
+! !
+
!FileBrowser class methodsFor:'class initialization'!
icons
@@ -199,33 +208,6 @@
"Modified: / 1.8.1998 / 17:39:27 / cg"
! !
-!FileBrowser class methodsFor:'command history'!
-
-addToCommandHistory:aCommandString for:aFilename
- |cmd suffix|
-
- (aCommandString notNil and:[aCommandString notEmpty]) ifTrue:[
- CommandHistory notNil ifTrue:[
- CommandHistory addFirst:aCommandString.
- CommandHistory size > CommandHistorySize ifTrue:[
- CommandHistory removeLast
- ]
- ].
- aFilename notNil ifTrue:[
- cmd := aCommandString copyTo:(aCommandString indexOf:Character space ifAbsent:[aCommandString size + 1])-1.
- DefaultCommandPerSuffix isNil ifTrue:[
- DefaultCommandPerSuffix := Dictionary new.
- ].
- suffix := aFilename asFilename suffix.
- suffix notNil ifTrue:[
- DefaultCommandPerSuffix at:suffix put:cmd.
- ]
- ]
- ]
-
- "Created: 14.11.1996 / 14:58:13 / cg"
-! !
-
!FileBrowser class methodsFor:'defaults'!
defaultIcon
@@ -255,6 +237,73 @@
"Modified: 15.8.1997 / 15:27:19 / cg"
! !
+!FileBrowser class methodsFor:'history'!
+
+addToCommandHistory:aCommandString for:aFilename
+ |cmd suffix|
+
+ (aCommandString notNil and:[aCommandString notEmpty]) ifTrue:[
+ CommandHistory notNil ifTrue:[
+ CommandHistory addFirst:aCommandString.
+ CommandHistory size > CommandHistorySize ifTrue:[
+ CommandHistory removeLast
+ ]
+ ].
+ aFilename notNil ifTrue:[
+ cmd := aCommandString copyTo:(aCommandString indexOf:Character space ifAbsent:[aCommandString size + 1])-1.
+ DefaultCommandPerSuffix isNil ifTrue:[
+ DefaultCommandPerSuffix := Dictionary new.
+ ].
+ suffix := aFilename asFilename suffix.
+ suffix notNil ifTrue:[
+ DefaultCommandPerSuffix at:suffix put:cmd.
+ ]
+ ]
+ ]
+
+ "Created: 14.11.1996 / 14:58:13 / cg"
+!
+
+addToHistory:path
+ |pos idx|
+
+ idx := DirectoryHistory indexOf:path.
+ idx == 0 ifTrue:[
+ DirectoryHistory size >= HistorySize ifTrue:[
+ DirectoryHistory removeLast.
+ DirectoryHistoryWhere removeLast
+ ]
+ ] ifFalse:[
+ "already been there before; move the entry to
+ the beginning, so it will fall out later."
+
+ DirectoryHistory removeIndex:idx.
+ pos := DirectoryHistoryWhere at:idx.
+ DirectoryHistoryWhere removeIndex:idx.
+ ].
+ DirectoryHistory addFirst:path.
+ DirectoryHistoryWhere addFirst:pos.
+
+ "Created: / 8.11.1997 / 17:16:29 / cg"
+!
+
+addToVisitedFileHistory:path
+ |idx|
+
+ idx := VisitedFileHistory indexOf:path.
+ idx == 0 ifTrue:[
+ VisitedFileHistory size >= HistorySize ifTrue:[
+ VisitedFileHistory removeLast.
+ ]
+ ] ifFalse:[
+ "already been there before; move the entry to
+ the beginning, so it will fall out later."
+
+ VisitedFileHistory removeIndex:idx.
+ ].
+ VisitedFileHistory addFirst:path.
+! !
+
!FileBrowser class methodsFor:'interface specs'!
fileSearchDialogSpec
@@ -635,6 +684,14 @@
#(#Menu
#(
#(#MenuItem
+ #label: 'Spawn'
+ #translateLabel: true
+ #value: #fileSpawn
+ )
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
#label: 'Open'
#translateLabel: true
#value: #menuOpen
@@ -814,6 +871,14 @@
#translateLabel: true
#value: #copyCommandHistory
)
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
+ #label: 'Visited Files'
+ #translateLabel: true
+ #submenuChannel: #visitedFileMenuSpec
+ )
)
nil
nil
@@ -1118,6 +1183,26 @@
nil
nil
)
+!
+
+visitedFileMenuSpec
+
+ <resource: #programMenu>
+
+ |m|
+
+ VisitedFileHistory size == 0 ifTrue:[^ nil].
+
+ m := Menu new.
+
+ "/ add the history items ...
+
+ VisitedFileHistory do:[:pathName |
+ m addItem:((MenuItem label:pathName asFilename baseName value:#revisitFile:)
+ argument:pathName;
+ yourself).
+ ].
+ ^ m
! !
!FileBrowser class methodsFor:'queries'!
@@ -1342,13 +1427,6 @@
"Modified: / 4.8.1998 / 14:10:57 / cg"
!
-hasVisitHistory
- ^ [DirectoryHistory size > 0]
-
- "Created: / 14.8.1998 / 19:17:02 / cg"
- "Modified: / 14.8.1998 / 19:17:17 / cg"
-!
-
hasZipFileSelected
^ [|sel f fn suff|
@@ -3122,6 +3200,19 @@
"Modified: / 29.1.2000 / 13:10:01 / cg"
!
+revisitFile:aFileName
+ |lineNr|
+
+ (self askIfModified:'contents has not been saved.\\Modifications will be lost when you proceed.'
+ yesButton:'proceed') ifFalse:[ ^self ].
+
+ self doChangeCurrentDirectoryTo:aFileName asFilename directory updateHistory:false.
+ lineNr := fileList indexOf:aFileName asFilename baseName.
+ fileListView selection:lineNr.
+ self fileGet:true.
+
+!
+
showOrHideTabView
"depending on the showLongList setting, show or hde the tabSpec view"
@@ -3312,7 +3403,12 @@
DirectoryHistory isNil ifTrue:[
DirectoryHistory := OrderedCollection new.
DirectoryHistoryWhere := OrderedCollection new.
- HistorySize := 15.
+ ].
+ VisitedFileHistory isNil ifTrue:[
+ VisitedFileHistory := OrderedCollection new.
+ ].
+ HistorySize isNil ifTrue:[
+ HistorySize := 15
].
commandIndex := 0.
@@ -5059,26 +5155,7 @@
!FileBrowser methodsFor:'private - directory stuff'!
addToHistory:path
- |pos idx|
-
- (DirectoryHistory includes:path) ifFalse:[
- DirectoryHistory size >= HistorySize ifTrue:[
- DirectoryHistory removeLast.
- DirectoryHistoryWhere removeLast
- ]
- ] ifTrue:[
- "already been there before; move the entry to
- the beginning, so it will fall out later."
-
- idx := DirectoryHistory indexOf:path.
- DirectoryHistory removeIndex:idx.
- pos := DirectoryHistoryWhere at:idx.
- DirectoryHistoryWhere removeIndex:idx.
- ].
- DirectoryHistory addFirst:path.
- DirectoryHistoryWhere addFirst:pos.
-
- "Created: / 8.11.1997 / 17:16:29 / cg"
+ self class addToHistory:path
!
changeToPreviousDirectory
@@ -6228,7 +6305,7 @@
"show/insert contents of fileName in subView"
|path buffer s n i ok convert text msg eol guess action enc
- fontsEncoding pref failWarning|
+ fontsEncoding pref failWarning f|
fileName asFilename isAbsolute ifFalse:[
path := currentDirectory filenameFor:fileName.
@@ -6368,6 +6445,11 @@
].
insert ifFalse:[
+ (f := fileName asFilename) isAbsolute ifFalse:[
+ f := (currentDirectory construct:fileName)
+ ].
+ self class addToVisitedFileHistory:f pathName.
+
self show:text
] ifTrue:[
subView insertSelectedStringAtCursor:text asString
@@ -7065,6 +7147,10 @@
"Modified: / 18.6.1998 / 15:27:35 / cg"
!
+hasVisitHistory
+ ^ self class hasVisitHistory
+!
+
path
"return my currentDirectories pathName;
sent from the pathField to aquire the pathname when I changed directory"
@@ -7081,5 +7167,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.392 2001-01-10 14:45:27 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.393 2001-01-19 10:17:54 cg Exp $'
! !