TextView.st
changeset 2884 101120a2c8b5
parent 2881 0c8e7e9edc0a
child 2886 9c655e153e71
equal deleted inserted replaced
2883:6cdb4a5a7b5e 2884:101120a2c8b5
  2058      leading spaces will be replaced by tab-characters in the output."
  2058      leading spaces will be replaced by tab-characters in the output."
  2059 
  2059 
  2060     |startNr nLines string encoder|
  2060     |startNr nLines string encoder|
  2061 
  2061 
  2062     encoder := CharacterEncoder encoderToEncodeFrom:characterEncoding into:encodingSymOrNil.
  2062     encoder := CharacterEncoder encoderToEncodeFrom:characterEncoding into:encodingSymOrNil.
  2063 
       
  2064     aStream isFileStream ifTrue:[
  2063     aStream isFileStream ifTrue:[
  2065         "on some systems, writing linewise is very slow (via NFS)
  2064         "on some systems, writing linewise is very slow (via NFS)
  2066          therefore we convert to a string and write it in big chunks.
  2065          therefore we convert to a string and write it in big chunks.
  2067          To avoid creating huge strings, we do it in blocks of 1000 lines,
  2066          To avoid creating huge strings, we do it in blocks of 1000 lines,
  2068          limiting temporary string creation to about 50-80k.
  2067          limiting temporary string creation to about 50-80k.
  2071         nLines := list size.
  2070         nLines := list size.
  2072         [startNr <= nLines] whileTrue:[
  2071         [startNr <= nLines] whileTrue:[
  2073             string := list asStringWithCRsFrom:startNr 
  2072             string := list asStringWithCRsFrom:startNr 
  2074                                             to:((startNr + 1000) min:nLines)
  2073                                             to:((startNr + 1000) min:nLines)
  2075                                   compressTabs:compressTabs.
  2074                                   compressTabs:compressTabs.
  2076             aStream nextPutAll:(encoder encodeString:string).
  2075             aStream nextPutAll:(encoder encodeString:string string).
  2077             startNr := startNr + 1000 + 1.
  2076             startNr := startNr + 1000 + 1.
  2078         ].
  2077         ].
  2079     ] ifFalse:[
  2078     ] ifFalse:[
  2080         list do:[:aLine |
  2079         list do:[:aLine |
  2081             aLine notNil ifTrue:[
  2080             aLine notNil ifTrue:[
  3867 ! !
  3866 ! !
  3868 
  3867 
  3869 !TextView class methodsFor:'documentation'!
  3868 !TextView class methodsFor:'documentation'!
  3870 
  3869 
  3871 version
  3870 version
  3872     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.232 2004-02-16 16:56:04 cg Exp $'
  3871     ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.233 2004-02-17 12:10:42 cg Exp $'
  3873 ! !
  3872 ! !
  3874 
  3873 
  3875 TextView initialize!
  3874 TextView initialize!