FileSelectionList.st
changeset 2226 bf23595862d9
parent 2093 ac231f0404d9
child 2377 977c3d87e61f
--- a/FileSelectionList.st	Mon Aug 21 13:21:20 2000 +0200
+++ b/FileSelectionList.st	Mon Aug 21 13:23:26 2000 +0200
@@ -10,13 +10,15 @@
  hereby transferred.
 "
 
+"{ Package: 'stx:libwidg' }"
+
 SelectionInListView subclass:#FileSelectionList
 	instanceVariableNames:'pattern directory timeStamp directoryId directoryName
 		directoryContents directoryFileTypes realAction matchBlock
 		stayInDirectory ignoreParentDirectory markDirectories
 		ignoreDirectories directoryChangeCheckBlock quickDirectoryChange
 		directoryChangeAction directorySelectAction fileSelectAction
-		ignoreFiles directoryHolder'
+		ignoreFiles directoryHolder directoryStack'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Lists'
@@ -726,6 +728,18 @@
     "Modified: 5.3.1996 / 02:38:06 / cg"
 !
 
+keyPress:key x:x y:y
+    key == #CursorLeft ifTrue:[
+        self changeToParentDirectory.
+        ^ self
+    ].
+    (key == #CursorRight) ifTrue:[
+        self changeToPreviousDirectory.
+        ^ self
+    ].
+    super keyPress:key x:x y:y
+!
+
 selectionChanged
     "if the selection changed, check for it being a directory
      and possibly go there. If its not a directory, perform the realAction."
@@ -813,11 +827,22 @@
 changeDirectory
     "change directory to the selected one"
 
-    |entry ok newDir warnMessage oldDir|
+    |entry|
 
     entry := self selectionValue.
     (entry isNil or:[entry isEmpty]) ifTrue:[ ^ false].
 
+    (self changeDirectoryTo:entry) ifFalse:[^ false].
+
+    directoryStack := nil.
+!
+
+changeDirectoryTo:newDirectory
+    "change directory; check if allowed; return true if change was ok"
+
+    |entry ok newDir warnMessage oldDir|
+
+    entry := newDirectory.
     (entry endsWith:' ...') ifTrue:[
         entry := entry copyWithoutLast:4.
     ].
@@ -849,10 +874,36 @@
             self setSelectElement:oldDir 
         ].
     ].
+    ^ ok
+!
 
-    "Created: 4.3.1996 / 17:45:18 / cg"
-    "Modified: 26.5.1996 / 15:03:21 / cg"
-    "Modified: 18.9.1997 / 23:34:39 / stefan"
+changeToParentDirectory
+    "change to the parent directory"
+
+    |current parent|
+
+    current := self directory asFilename.
+    parent := current directory.
+    parent = current ifTrue:[^ false].
+
+    (self changeDirectoryTo:'..') ifFalse:[^ false].
+
+    directoryStack isNil ifTrue:[
+        directoryStack := OrderedCollection new.
+    ].
+    directoryStack addFirst:current pathName
+!
+
+changeToPreviousDirectory
+    "change to the previous directory"
+
+    |current previous|
+
+    directoryStack size == 0 ifTrue:[^ false].
+
+    previous := directoryStack removeFirst.
+
+    (self changeDirectoryTo:(previous asFilename baseName)) ifFalse:[^ false].
 !
 
 selectionIsDirectory
@@ -1007,5 +1058,5 @@
 !FileSelectionList class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.46 1999-12-20 10:55:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.47 2000-08-21 11:23:26 cg Exp $'
 ! !