4918 where all tabulator characters are expanded into spaces (assuming 8-col tabs). |
4918 where all tabulator characters are expanded into spaces (assuming 8-col tabs). |
4919 Notice: if the receiver does not contain any tabs, it is returned unchanged; |
4919 Notice: if the receiver does not contain any tabs, it is returned unchanged; |
4920 otherwise a new string is returned. |
4920 otherwise a new string is returned. |
4921 This does handle multiline strings." |
4921 This does handle multiline strings." |
4922 |
4922 |
|
4923 ^ self withTabsExpanded:8 |
|
4924 |
|
4925 " |
|
4926 ('1' , Character tab asString , 'x') withTabsExpanded |
|
4927 ('12345' , Character tab asString , 'x') withTabsExpanded |
|
4928 ('123456' , Character tab asString , 'x') withTabsExpanded |
|
4929 ('1234567' , Character tab asString , 'x') withTabsExpanded |
|
4930 ('12345678' , Character tab asString , 'x') withTabsExpanded |
|
4931 ('123456789' , Character tab asString , 'x') withTabsExpanded |
|
4932 |
|
4933 (String with:Character tab |
|
4934 with:Character tab |
|
4935 with:$1) withTabsExpanded |
|
4936 |
|
4937 (String with:Character tab |
|
4938 with:$1 |
|
4939 with:Character tab |
|
4940 with:$2) withTabsExpanded |
|
4941 |
|
4942 (String with:Character tab |
|
4943 with:$1 |
|
4944 with:Character cr |
|
4945 with:Character tab |
|
4946 with:$2) withTabsExpanded |
|
4947 " |
|
4948 |
|
4949 "Modified: 12.5.1996 / 13:05:10 / cg" |
|
4950 ! |
|
4951 |
|
4952 withTabsExpanded:numSpaces |
|
4953 "return a string consisting of the receivers characters, |
|
4954 where all tabulator characters are expanded into spaces (assuming numSpaces-col tabs). |
|
4955 Notice: if the receiver does not contain any tabs, it is returned unchanged; |
|
4956 otherwise a new string is returned. |
|
4957 This does handle multiline strings." |
|
4958 |
4923 |col "{ SmallInteger }" |
4959 |col "{ SmallInteger }" |
4924 str ch |
4960 str ch |
4925 dstIdx "{ SmallInteger }" |
4961 dstIdx "{ SmallInteger }" |
4926 newSz "{ SmallInteger }" |
4962 newSz "{ SmallInteger }" |
4927 sz "{ SmallInteger }" |
4963 sz "{ SmallInteger }" |
4969 str emphasisAt:dstIdx put:e |
5005 str emphasisAt:dstIdx put:e |
4970 ]. |
5006 ]. |
4971 str at:dstIdx put:ch. |
5007 str at:dstIdx put:ch. |
4972 dstIdx := dstIdx + 1 |
5008 dstIdx := dstIdx + 1 |
4973 ] ifTrue:[ |
5009 ] ifTrue:[ |
4974 (col \\ 8) to:8 do:[:ii | |
5010 (col \\ numSpaces) to:numSpaces do:[:ii | |
4975 str at:dstIdx put:Character space. |
5011 str at:dstIdx put:Character space. |
4976 dstIdx := dstIdx + 1. |
5012 dstIdx := dstIdx + 1. |
4977 col := col + 1 |
5013 col := col + 1 |
4978 ]. |
5014 ]. |
4979 ] |
5015 ] |
4980 ]. |
5016 ]. |
4981 ^ str |
5017 ^ str |
4982 |
5018 |
4983 " |
5019 " |
4984 ('1' , Character tab asString , 'x') withTabsExpanded |
5020 ('1' , Character tab asString , 'x') withTabsExpanded |
|
5021 ('1' , Character tab asString , 'x') withTabsExpanded:4 |
4985 ('12345' , Character tab asString , 'x') withTabsExpanded |
5022 ('12345' , Character tab asString , 'x') withTabsExpanded |
4986 ('123456' , Character tab asString , 'x') withTabsExpanded |
5023 ('123456' , Character tab asString , 'x') withTabsExpanded |
4987 ('1234567' , Character tab asString , 'x') withTabsExpanded |
5024 ('1234567' , Character tab asString , 'x') withTabsExpanded |
4988 ('12345678' , Character tab asString , 'x') withTabsExpanded |
5025 ('12345678' , Character tab asString , 'x') withTabsExpanded |
4989 ('123456789' , Character tab asString , 'x') withTabsExpanded |
5026 ('123456789' , Character tab asString , 'x') withTabsExpanded |