[comp.lang.smalltalk] UnixFileList - problems and solutions

holdam@daimi.UUCP (01/12/87)

We have discovered some minor problems with the UnixFileList-browser.
One of them was that it was not possible to read files from
a directory with a name of a reasonable length (greater than 30).
The change to the method open in class UnixFileList
solves this problem.

The other problem was that you could not scroll the contents
of the OnlyWhenSelectedCodeView when it was showing a directory.
The change to the method text in the same class is a solution to this.

We have another problem which we haven't found a solution to.
We are running PS-Smalltalk on Sun 3's, and if you push the Caps Lock
button on the keyboard, every keystroke is translated into an uppercase
X. This is not very useful, so if anyone has a solution to the problem,
or some hints where to look we would be grateful.


Jan Holdam
Department of Computer Science
Aarhus University
DK-8000 Aarhus C
Denmark

UUCP: holdam@daimi.UUCP or ..!mcvax!diku!daimi!holdam

------------------cut here---------------------------

'From Smalltalk-80, version 2, of April 1, 1983 on 16 September 1986 at 3:21:43 pm'!



!UnixFileList class methodsFor: 'instance creation'!

open      "UnixFileList open"
   "Create and schedule a view of a new
    instance of me on the current working directory."
   "Changed by Jan Holdam"


   | cwd size |
   cwd _ String new: 150. "Was 30"
   size _ (UnixSystemCall getWorkingDirectoryInto: cwd) value.
   ^self openOn: (cwd copyFrom: 1 to: size)! !


'From Smalltalk-80, version 2, of April 1, 1983 on 27 November 1986 at 1:11:31 pm'!



!UnixFileList methodsFor: 'text'!

text
   | text dirList dirStream |
   isDirectory
      ifTrue: [
         emptyDir
            ifFalse: [text _ '-Directory is not empty, cannot be removed. -'
                         asText emphasizeFrom: 2 to: 43 with: 3]
            ifTrue: [dirList _ SortedCollection new.
               dirStream _ WriteStream on: (String new).
               dirStream nextPutAll: ('-directory -'); cr; cr.
               dirList addAll: ((UnixFileDirectory named: selectionName) filesMatching: '*').
               dirList do: [ :name | dirStream nextPutAll: name; cr].
               text _ dirStream contents asText emphasizeFrom: 2 to: 11 with: 3.
               isReading _ true "to make scrolling in directories possible/jh/861127"]]
      ifFalse: [ "Then it is a file."
         isReading
            ifTrue:
               [fileName == nil ifTrue: [^nil].
               (UnixFileDirectory includesKey: fileName)
                  ifTrue: [text _ Cursor read showWhile:
                     [(FileStream fileNamed: fileName) contentsOfEntireFile asText].
                     swap ifTrue: [text string swapCrLfs]]
                  ifFalse:
                     [text _ '-new file -' asText emphasizeFrom: 2 to: 10 with: 3]]
            ifFalse:
               [fileName == nil
                  ifTrue:
                     [text _ '' asText]
                  ifFalse:
                     [(UnixFileDirectory includesKey: fileName)
                        ifTrue:
                           [text _ '-file -  Select ''get contents'' to view contents. ' asText.
                           text emphasizeFrom: 2 to: 6 with: 3; emphasizeFrom: 10 to: text size with: 3]
                        ifFalse:
                           [text _ '-new file -' asText emphasizeFrom: 2 to: 10 with: 3.
                           isReading _ true.]]]].
   ^text! !