912 "return part of myself as a string or text with embedded sepCharacters. |
912 "return part of myself as a string or text with embedded sepCharacters. |
913 My elements must be strings or nil; nil entries and empty strings are |
913 My elements must be strings or nil; nil entries and empty strings are |
914 taken as empty lines. |
914 taken as empty lines. |
915 If the argument compressTabs is true, leading spaces are converted |
915 If the argument compressTabs is true, leading spaces are converted |
916 to tab-characters (8col tabs). The last line is followed by a final |
916 to tab-characters (8col tabs). The last line is followed by a final |
|
917 character (if non-nil)." |
|
918 |
|
919 ^ self |
|
920 asStringWith:sepCharacter |
|
921 from:firstLine |
|
922 to:lastLine |
|
923 compressTabs:compressTabs |
|
924 final:endCharacter |
|
925 withEmphasis:true |
|
926 |
|
927 "Modified: / 17.6.1998 / 12:31:19 / cg" |
|
928 ! |
|
929 |
|
930 asStringWith:sepCharacter from:firstLine to:lastLine compressTabs:compressTabs final:endCharacter withEmphasis:withEmphasis |
|
931 "return part of myself as a string or text with embedded sepCharacters. |
|
932 My elements must be strings or nil; nil entries and empty strings are |
|
933 taken as empty lines. |
|
934 If the argument compressTabs is true, leading spaces are converted |
|
935 to tab-characters (8col tabs). The last line is followed by a final |
917 character (if non-nil). |
936 character (if non-nil). |
918 |
937 The withEmphais argument controls if the returned string should preserve |
|
938 any emphasis. If false, a plain string is returned. |
919 This method is tuned for big collections, in not creating many |
939 This method is tuned for big collections, in not creating many |
920 intermediate strings (has linear runtime). For very small collections |
940 intermediate strings (has linear runtime). For very small collections |
921 and small strings, it may be faster to use the comma , operation." |
941 and small strings, it may be faster to use the comma , operation." |
922 |
942 |
923 |idx1 "{ Class:SmallInteger }" |
943 |idx1 "{ Class:SmallInteger }" |
946 lineString := self at:lineIndex. |
966 lineString := self at:lineIndex. |
947 |
967 |
948 lineString isNil ifTrue:[ |
968 lineString isNil ifTrue:[ |
949 totalLength := totalLength + sepCnt |
969 totalLength := totalLength + sepCnt |
950 ] ifFalse: [ |
970 ] ifFalse: [ |
951 lineString hasChangeOfEmphasis ifTrue:[ |
971 withEmphasis ifTrue:[ |
952 needEmphasis := true |
972 lineString hasChangeOfEmphasis ifTrue:[ |
953 ]. |
973 needEmphasis := true |
954 (lineString bitsPerCharacter == 16) ifTrue:[ |
974 ]. |
955 any16Bit := true. |
975 (lineString bitsPerCharacter == 16) ifTrue:[ |
956 stringClass := lineString class |
976 any16Bit := true. |
|
977 stringClass := lineString class |
|
978 ]. |
957 ]. |
979 ]. |
958 totalLength := totalLength + lineString size + sepCnt |
980 totalLength := totalLength + lineString size + sepCnt |
959 ]. |
981 ]. |
960 ]. |
982 ]. |
961 endCharacter isNil ifTrue:[ |
983 endCharacter isNil ifTrue:[ |
978 pos := 1. |
1000 pos := 1. |
979 idx1 to:idx2 do:[:lineIndex | |
1001 idx1 to:idx2 do:[:lineIndex | |
980 lineString := self at:lineIndex. |
1002 lineString := self at:lineIndex. |
981 thisLen := lineString size. |
1003 thisLen := lineString size. |
982 thisLen ~~ 0 ifTrue:[ |
1004 thisLen ~~ 0 ifTrue:[ |
|
1005 withEmphasis ifFalse:[ |
|
1006 lineString := lineString string. |
|
1007 ]. |
|
1008 |
983 (anyTab := compressTabs) ifTrue:[ |
1009 (anyTab := compressTabs) ifTrue:[ |
984 " |
1010 " |
985 mhmh: could use withTabs from String-class here, |
1011 mhmh: could use withTabs from String-class here, |
986 but we should avoid creating too many temporary strings |
1012 but we should avoid creating too many temporary strings |
987 (especially, since this method is typically used when converting |
1013 (especially, since this method is typically used when converting |