# HG changeset patch # User Claus Gittinger # Date 817087810 -3600 # Node ID 6ccc226ce3a6295026c060f9da0393ab98036cc2 # Parent fc2fc4347d5def9f16b1a3f6a3e1948ab69a6e60 checkin from browser diff -r fc2fc4347d5d -r 6ccc226ce3a6 FSelList.st --- a/FSelList.st Thu Nov 23 01:48:21 1995 +0100 +++ b/FSelList.st Thu Nov 23 01:50:10 1995 +0100 @@ -10,12 +10,10 @@ hereby transferred. " -'From Smalltalk/X, Version:2.10.4 on 1-feb-1995 at 3:54:12 pm'! - SelectionInListView subclass:#FileSelectionList instanceVariableNames:'pattern directory timeStamp directoryId directoryContents - directoryFileTypes fileTypes realAction matchBlock - stayInDirectory ignoreParentDirectory' + directoryFileTypes fileTypes realAction matchBlock + stayInDirectory ignoreParentDirectory' classVariableNames:'' poolDictionaries:'' category:'Views-Text' @@ -37,10 +35,6 @@ " ! -version - ^ '$Header: /cvs/stx/stx/libwidg/Attic/FSelList.st,v 1.15 1995-11-11 16:20:20 cg Exp $' -! - documentation " this class implements file selection lists - its basically a @@ -214,45 +208,26 @@ list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. top open " -! ! - -!FileSelectionList methodsFor:'drawing'! - -redrawVisibleLine:visLineNr - "if the line is one for a directory, draw a right arrow" - - |l| - - super redrawVisibleLine:visLineNr. - l := self visibleLineToListLine:visLineNr. - l notNil ifTrue:[ - (fileTypes at:l) == #directory ifTrue:[ - self drawRightArrowInVisibleLine:visLineNr - ] - ] ! -redrawFromVisibleLine:startVisLineNr to:endVisLineNr - "redefined to look for directory in every line" - - |l| - - "first, draw chunk of lines" - super redrawFromVisibleLine:startVisLineNr to:endVisLineNr. - - "then draw marks" - startVisLineNr to:endVisLineNr do:[:visLineNr | - l := self visibleLineToListLine:visLineNr. - l notNil ifTrue:[ - (fileTypes at:l) == #directory ifTrue:[ - self drawRightArrowInVisibleLine:visLineNr - ] - ] - ] +version + ^ '$Header: /cvs/stx/stx/libwidg/Attic/FSelList.st,v 1.16 1995-11-23 00:50:10 cg Exp $' ! ! !FileSelectionList methodsFor:'accessing'! +action:aBlock + "set the action to be performed on a selection" + + realAction := aBlock +! + +directory + "return the shown directory" + + ^ directory +! + directory:nameOrDirectory "set the lists contents to the filenames in the directory" @@ -281,27 +256,6 @@ ] ! -directory - "return the shown directory" - - ^ directory -! - -action:aBlock - "set the action to be performed on a selection" - - realAction := aBlock -! - -stayInDirectory:aBoolean - "set/clear the flag which controls if selecting a directory - should locally change (if false) or be handled just like - the selection of a file (if true). - The default is false (i.e. change and do not tell via action)" - - stayInDirectory := aBoolean -! - ignoreParentDirectory:aBoolean "set/clear the flag which controls if the parent directory (..) is shown in the list. The default is false (i.e. show it)" @@ -309,6 +263,13 @@ ignoreParentDirectory := aBoolean ! +matchBlock:aBlock + "set the matchBlock - if non-nil, it controls which + names are shown in the list." + + matchBlock := aBlock +! + pattern:aPattern "set the pattern - if it changes, update the list." @@ -332,11 +293,112 @@ ! -matchBlock:aBlock - "set the matchBlock - if non-nil, it controls which - names are shown in the list." +stayInDirectory:aBoolean + "set/clear the flag which controls if selecting a directory + should locally change (if false) or be handled just like + the selection of a file (if true). + The default is false (i.e. change and do not tell via action)" + + stayInDirectory := aBoolean +! ! + +!FileSelectionList methodsFor:'drawing'! + +redrawFromVisibleLine:startVisLineNr to:endVisLineNr + "redefined to look for directory in every line" + + |l| + + "first, draw chunk of lines" + super redrawFromVisibleLine:startVisLineNr to:endVisLineNr. + + "then draw marks" + startVisLineNr to:endVisLineNr do:[:visLineNr | + l := self visibleLineToListLine:visLineNr. + l notNil ifTrue:[ + (fileTypes at:l) == #directory ifTrue:[ + self drawRightArrowInVisibleLine:visLineNr + ] + ] + ] +! + +redrawVisibleLine:visLineNr + "if the line is one for a directory, draw a right arrow" + + |l| + + super redrawVisibleLine:visLineNr. + l := self visibleLineToListLine:visLineNr. + l notNil ifTrue:[ + (fileTypes at:l) == #directory ifTrue:[ + self drawRightArrowInVisibleLine:visLineNr + ] + ] +! ! + +!FileSelectionList methodsFor:'initialization'! + +initialize + directory := FileDirectory currentDirectory. + stayInDirectory := false. + ignoreParentDirectory := false. + + super initialize. - matchBlock := aBlock + pattern := '*'. + self initializeAction. + + "nontypical use ..." + " + FileSelectionList new open + (FileSelectionList new directory:'/etc') open + (ScrollableView for:FileSelectionList) open + (HVScrollableView for:FileSelectionList) open + " +! + +initializeAction + "setup action as: selections in list get forwarded to enterfield if not + a directory; otherwise directory is changed" + + actionBlock := [:lineNr | + |entry ok| + + self selection isCollection ifFalse:[ + entry := self selectionValue. + (entry endsWith:' ...') ifTrue:[ + entry := entry copyWithoutLast:4 "copyTo:(entry size - 4)". + ]. + (stayInDirectory not + and:[(directory typeOf:entry) == #directory]) ifTrue:[ + ok := false. + (directory isReadable:entry) ifFalse:[ + self warn:(resources string:'not allowed to read directory %1' with:entry) + ] ifTrue:[ + (directory isExecutable:entry) ifFalse:[ + self warn:(resources string:'not allowed to change to directory %1' with:entry) + ] ifTrue:[ + self directory:(directory pathName , Filename separator asString , entry). + ok := true. + ] + ]. + ok ifFalse:[ + self deselect + ] + + ] ifFalse:[ + realAction notNil ifTrue:[ + realAction value:lineNr + ] + ] + ] + ] +! + +reinitialize + directory := FileDirectory currentDirectory. + super reinitialize ! ! !FileSelectionList methodsFor:'private'! @@ -410,13 +472,6 @@ self cursor:oldCursor. ! -widthForScrollBetween:firstLine and:lastLine - "return the width in pixels for a scroll between firstLine and lastLine - - return full width here since there might be directory marks" - - ^ (width - margin - margin) -! - visibleLineNeedsSpecialCare:visLineNr |l| @@ -426,70 +481,13 @@ ^ super visibleLineNeedsSpecialCare:visLineNr ]. ^ false -! ! - -!FileSelectionList methodsFor:'initialization'! - -initializeAction - "setup action as: selections in list get forwarded to enterfield if not - a directory; otherwise directory is changed" - - actionBlock := [:lineNr | - |entry ok| - - self selection isCollection ifFalse:[ - entry := self selectionValue. - (entry endsWith:' ...') ifTrue:[ - entry := entry copyWithoutLast:4 "copyTo:(entry size - 4)". - ]. - (stayInDirectory not - and:[(directory typeOf:entry) == #directory]) ifTrue:[ - ok := false. - (directory isReadable:entry) ifFalse:[ - self warn:(resources string:'not allowed to read directory %1' with:entry) - ] ifTrue:[ - (directory isExecutable:entry) ifFalse:[ - self warn:(resources string:'not allowed to change to directory %1' with:entry) - ] ifTrue:[ - self directory:(directory pathName , Filename separator asString , entry). - ok := true. - ] - ]. - ok ifFalse:[ - self deselect - ] - - ] ifFalse:[ - realAction notNil ifTrue:[ - realAction value:lineNr - ] - ] - ] - ] ! -initialize - directory := FileDirectory currentDirectory. - stayInDirectory := false. - ignoreParentDirectory := false. - - super initialize. - - pattern := '*'. - self initializeAction. +widthForScrollBetween:firstLine and:lastLine + "return the width in pixels for a scroll between firstLine and lastLine + - return full width here since there might be directory marks" - "nontypical use ..." - " - FileSelectionList new open - (FileSelectionList new directory:'/etc') open - (ScrollableView for:FileSelectionList) open - (HVScrollableView for:FileSelectionList) open - " -! - -reinitialize - directory := FileDirectory currentDirectory. - super reinitialize + ^ (width - margin - margin) ! ! !FileSelectionList methodsFor:'realization'! diff -r fc2fc4347d5d -r 6ccc226ce3a6 FileSelectionList.st --- a/FileSelectionList.st Thu Nov 23 01:48:21 1995 +0100 +++ b/FileSelectionList.st Thu Nov 23 01:50:10 1995 +0100 @@ -10,12 +10,10 @@ hereby transferred. " -'From Smalltalk/X, Version:2.10.4 on 1-feb-1995 at 3:54:12 pm'! - SelectionInListView subclass:#FileSelectionList instanceVariableNames:'pattern directory timeStamp directoryId directoryContents - directoryFileTypes fileTypes realAction matchBlock - stayInDirectory ignoreParentDirectory' + directoryFileTypes fileTypes realAction matchBlock + stayInDirectory ignoreParentDirectory' classVariableNames:'' poolDictionaries:'' category:'Views-Text' @@ -37,10 +35,6 @@ " ! -version - ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.15 1995-11-11 16:20:20 cg Exp $' -! - documentation " this class implements file selection lists - its basically a @@ -214,45 +208,26 @@ list action:[:index | Transcript showCr:'you selected: ' , list selectionValue]. top open " -! ! - -!FileSelectionList methodsFor:'drawing'! - -redrawVisibleLine:visLineNr - "if the line is one for a directory, draw a right arrow" - - |l| - - super redrawVisibleLine:visLineNr. - l := self visibleLineToListLine:visLineNr. - l notNil ifTrue:[ - (fileTypes at:l) == #directory ifTrue:[ - self drawRightArrowInVisibleLine:visLineNr - ] - ] ! -redrawFromVisibleLine:startVisLineNr to:endVisLineNr - "redefined to look for directory in every line" - - |l| - - "first, draw chunk of lines" - super redrawFromVisibleLine:startVisLineNr to:endVisLineNr. - - "then draw marks" - startVisLineNr to:endVisLineNr do:[:visLineNr | - l := self visibleLineToListLine:visLineNr. - l notNil ifTrue:[ - (fileTypes at:l) == #directory ifTrue:[ - self drawRightArrowInVisibleLine:visLineNr - ] - ] - ] +version + ^ '$Header: /cvs/stx/stx/libwidg/FileSelectionList.st,v 1.16 1995-11-23 00:50:10 cg Exp $' ! ! !FileSelectionList methodsFor:'accessing'! +action:aBlock + "set the action to be performed on a selection" + + realAction := aBlock +! + +directory + "return the shown directory" + + ^ directory +! + directory:nameOrDirectory "set the lists contents to the filenames in the directory" @@ -281,27 +256,6 @@ ] ! -directory - "return the shown directory" - - ^ directory -! - -action:aBlock - "set the action to be performed on a selection" - - realAction := aBlock -! - -stayInDirectory:aBoolean - "set/clear the flag which controls if selecting a directory - should locally change (if false) or be handled just like - the selection of a file (if true). - The default is false (i.e. change and do not tell via action)" - - stayInDirectory := aBoolean -! - ignoreParentDirectory:aBoolean "set/clear the flag which controls if the parent directory (..) is shown in the list. The default is false (i.e. show it)" @@ -309,6 +263,13 @@ ignoreParentDirectory := aBoolean ! +matchBlock:aBlock + "set the matchBlock - if non-nil, it controls which + names are shown in the list." + + matchBlock := aBlock +! + pattern:aPattern "set the pattern - if it changes, update the list." @@ -332,11 +293,112 @@ ! -matchBlock:aBlock - "set the matchBlock - if non-nil, it controls which - names are shown in the list." +stayInDirectory:aBoolean + "set/clear the flag which controls if selecting a directory + should locally change (if false) or be handled just like + the selection of a file (if true). + The default is false (i.e. change and do not tell via action)" + + stayInDirectory := aBoolean +! ! + +!FileSelectionList methodsFor:'drawing'! + +redrawFromVisibleLine:startVisLineNr to:endVisLineNr + "redefined to look for directory in every line" + + |l| + + "first, draw chunk of lines" + super redrawFromVisibleLine:startVisLineNr to:endVisLineNr. + + "then draw marks" + startVisLineNr to:endVisLineNr do:[:visLineNr | + l := self visibleLineToListLine:visLineNr. + l notNil ifTrue:[ + (fileTypes at:l) == #directory ifTrue:[ + self drawRightArrowInVisibleLine:visLineNr + ] + ] + ] +! + +redrawVisibleLine:visLineNr + "if the line is one for a directory, draw a right arrow" + + |l| + + super redrawVisibleLine:visLineNr. + l := self visibleLineToListLine:visLineNr. + l notNil ifTrue:[ + (fileTypes at:l) == #directory ifTrue:[ + self drawRightArrowInVisibleLine:visLineNr + ] + ] +! ! + +!FileSelectionList methodsFor:'initialization'! + +initialize + directory := FileDirectory currentDirectory. + stayInDirectory := false. + ignoreParentDirectory := false. + + super initialize. - matchBlock := aBlock + pattern := '*'. + self initializeAction. + + "nontypical use ..." + " + FileSelectionList new open + (FileSelectionList new directory:'/etc') open + (ScrollableView for:FileSelectionList) open + (HVScrollableView for:FileSelectionList) open + " +! + +initializeAction + "setup action as: selections in list get forwarded to enterfield if not + a directory; otherwise directory is changed" + + actionBlock := [:lineNr | + |entry ok| + + self selection isCollection ifFalse:[ + entry := self selectionValue. + (entry endsWith:' ...') ifTrue:[ + entry := entry copyWithoutLast:4 "copyTo:(entry size - 4)". + ]. + (stayInDirectory not + and:[(directory typeOf:entry) == #directory]) ifTrue:[ + ok := false. + (directory isReadable:entry) ifFalse:[ + self warn:(resources string:'not allowed to read directory %1' with:entry) + ] ifTrue:[ + (directory isExecutable:entry) ifFalse:[ + self warn:(resources string:'not allowed to change to directory %1' with:entry) + ] ifTrue:[ + self directory:(directory pathName , Filename separator asString , entry). + ok := true. + ] + ]. + ok ifFalse:[ + self deselect + ] + + ] ifFalse:[ + realAction notNil ifTrue:[ + realAction value:lineNr + ] + ] + ] + ] +! + +reinitialize + directory := FileDirectory currentDirectory. + super reinitialize ! ! !FileSelectionList methodsFor:'private'! @@ -410,13 +472,6 @@ self cursor:oldCursor. ! -widthForScrollBetween:firstLine and:lastLine - "return the width in pixels for a scroll between firstLine and lastLine - - return full width here since there might be directory marks" - - ^ (width - margin - margin) -! - visibleLineNeedsSpecialCare:visLineNr |l| @@ -426,70 +481,13 @@ ^ super visibleLineNeedsSpecialCare:visLineNr ]. ^ false -! ! - -!FileSelectionList methodsFor:'initialization'! - -initializeAction - "setup action as: selections in list get forwarded to enterfield if not - a directory; otherwise directory is changed" - - actionBlock := [:lineNr | - |entry ok| - - self selection isCollection ifFalse:[ - entry := self selectionValue. - (entry endsWith:' ...') ifTrue:[ - entry := entry copyWithoutLast:4 "copyTo:(entry size - 4)". - ]. - (stayInDirectory not - and:[(directory typeOf:entry) == #directory]) ifTrue:[ - ok := false. - (directory isReadable:entry) ifFalse:[ - self warn:(resources string:'not allowed to read directory %1' with:entry) - ] ifTrue:[ - (directory isExecutable:entry) ifFalse:[ - self warn:(resources string:'not allowed to change to directory %1' with:entry) - ] ifTrue:[ - self directory:(directory pathName , Filename separator asString , entry). - ok := true. - ] - ]. - ok ifFalse:[ - self deselect - ] - - ] ifFalse:[ - realAction notNil ifTrue:[ - realAction value:lineNr - ] - ] - ] - ] ! -initialize - directory := FileDirectory currentDirectory. - stayInDirectory := false. - ignoreParentDirectory := false. - - super initialize. - - pattern := '*'. - self initializeAction. +widthForScrollBetween:firstLine and:lastLine + "return the width in pixels for a scroll between firstLine and lastLine + - return full width here since there might be directory marks" - "nontypical use ..." - " - FileSelectionList new open - (FileSelectionList new directory:'/etc') open - (ScrollableView for:FileSelectionList) open - (HVScrollableView for:FileSelectionList) open - " -! - -reinitialize - directory := FileDirectory currentDirectory. - super reinitialize + ^ (width - margin - margin) ! ! !FileSelectionList methodsFor:'realization'!