'From Squeak3.7alpha of ''11 September 2003'' [latest update: #5595] on 6 December 2003 at 10:41:05 am'! "Change Set: ArchiveViewerNicerShortContents-3-klc Date: 5 December 2003 Author: Ken Causey v3 Realized I could specify the number of characters shown exactly. v2 A second version after comments from Simon Michael. This version is refactored a little bit and produces results more like FileList2. Unless you toggle the button to 'View All Contents' the text of the file is trimmed. Previously it was trimmed at a fixed 5000 characters with no indication that it had been trimmed (other than the button not being toggled). I changed the behaviour so that if possible it trims the output at the end of the last line before 5000 characters and notes that the output is trimmed."! !ArchiveViewer methodsFor: 'initialization' stamp: 'KLC 12/6/2003 10:40'! briefContents "Trim to 5000 characters if longer then point out that it is trimmed" self selectedMember ifNil: [^ '']. ^self selectedMember contents size > 5000 ifTrue: [ | subContents lastLineEndingIndex tempIndex | subContents _ self selectedMember contentsFrom: 1 to: 5000. lastLineEndingIndex _ subContents lastIndexOf: Character cr. tempIndex _ subContents lastIndexOf: Character lf. tempIndex > lastLineEndingIndex ifTrue: [lastLineEndingIndex _ tempIndex]. lastLineEndingIndex = 0 ifFalse: [subContents _ subContents copyFrom: 1 to: lastLineEndingIndex]. 'File ''', self selectedMember fileName, ''' is ', self selectedMember contents size printString, ' bytes long. Toggle the ''View All Contents'' button above to see the entire file. Here are the first ', subContents size printString , ' characters... ------------------------------------------ ', subContents , ' ------------------------------------------ ... end of the first ', subContents size printString , ' characters.' ] ifFalse: [self selectedMember contents] ! ! !ArchiveViewer methodsFor: 'initialization' stamp: 'KLC 12/6/2003 10:21'! contents self selectedMember ifNil: [^ '']. viewAllContents ifFalse: [^ self briefContents]. ^ self selectedMember contents! !