TextStreamのサンプル。
| ts | ts := TextStream on: (Text new: 100). "強調(italic,bold,narrow,normal,struckOut,underlined)" ts nextPutAll: 'TextEmphasis ';cr. ts withAttribute: TextEmphasis italic do: [ts nextPutAll: 'italic']; cr. ts withAttribute: TextEmphasis bold do: [ts nextPutAll: 'bold']; cr. ts withAttribute: TextEmphasis narrow do: [ts nextPutAll: 'narrow']; cr. ts withAttribute: TextEmphasis normal do: [ts nextPutAll: 'normal']; cr. ts withAttribute: TextEmphasis struckOut do: [ts nextPutAll: 'struckOut']; cr. ts withAttribute: TextEmphasis underlined do: [ts nextPutAll: 'underlined']; cr. "フォント" ts nextPutAll: 'TextFontReference ';cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #BitstreamVeraSansMono) fontNamed: 'BitstreamVeraSansMono')) do: [ts nextPutAll: 'BitstreamVeraSansMono']; cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #Accuat) fontNamed: 'Accuat18')) do: [ts nextPutAll: 'Accuat']; cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #Accujen) fontNamed: 'Accujen09')) do: [ts nextPutAll: 'Accujen']; cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #Accula) fontNamed: 'Accula12')) do: [ts nextPutAll: 'Accujen']; cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #Accumon) fontNamed: 'Accumon09')) do: [ts nextPutAll: 'Accumon']; cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #Accuny) fontNamed: 'Accuny11')) do: [ts nextPutAll: 'Accuny']; cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #Accusf) fontNamed: 'Accusf18')) do: [ts nextPutAll: 'Accusf']; cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #Accushi) fontNamed: 'Accushi12')) do: [ts nextPutAll: 'Accushi']; cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #Accuve) fontNamed: 'Accuve12')) do: [ts nextPutAll: 'Accuve']; cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #Atlanta) fontNamed: 'Atlanta')) do: [ts nextPutAll: 'Atlanta']; cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #BitstreamVeraSans) fontNamed: 'BitstreamVeraSans')) do: [ts nextPutAll: 'BitstreamVeraSans']; cr. ts withAttribute: (TextFontReference toFont: ((TextStyle named: #BitstreamVeraSerif) fontNamed: 'BitstreamVeraSerif')) do: [ts nextPutAll: 'BitstreamVeraSerif']; cr. "色" ts withAttribute: TextColor black do: [ts nextPutAll: 'black']; cr. ts withAttribute: TextColor blue do: [ts nextPutAll: 'blue']; cr. ts withAttribute: TextColor cyan do: [ts nextPutAll: 'cyan']; cr. ts withAttribute: TextColor gray do: [ts nextPutAll: 'gray']; cr. ts withAttribute: TextColor green do: [ts nextPutAll: 'green']; cr. ts withAttribute: TextColor magenta do: [ts nextPutAll: 'magenta']; cr. ts withAttribute: TextColor red do: [ts nextPutAll: 'red']; cr. ts withAttribute: TextColor yellow do: [ts nextPutAll: 'yellow']; cr. "alignment" ts withAttribute: TextAlignment centered do: [ts nextPutAll: 'centered']; cr. ts withAttribute: TextAlignment justified do: [ts nextPutAll: 'justified']; cr. ts withAttribute: TextAlignment leftFlush do: [ts nextPutAll: 'leftFlush']; cr. ts withAttribute: TextAlignment rightFlush do: [ts nextPutAll: 'rightFlush']; cr. "do it" ts withAttribute: (TextDoIt evalString: 'StarMorph new openInWorld') do: [ts nextPutAll: 'StarMorph']; cr. "indent" ts withAttribute: (TextIndent amount: 1) do: [ts nextPutAll: 'amount = 1']; cr. ts withAttribute: (TextIndent amount: 2) do: [ts nextPutAll: 'amount = 2']; cr. "kern" ts withAttribute: (TextKern kern: 1) do: [ts nextPutAll: 'kern = 1']; cr. ts withAttribute: (TextKern kern: 2) do: [ts nextPutAll: 'kern = 2']; cr. ts withAttribute: (TextKern kern: -1) do: [ts nextPutAll: 'kern = -1']; cr. "Link" ts withAttribute: (TextLink scanFrom: 'Symbol asString') do: [ts nextPutAll: 'Symbol asString']; cr. "print it" ts withAttribute: (TextPrintIt evalString: 'SmallInteger maxVal') do: [ts nextPutAll: 'SmallInteger maxVal']; cr. (Workspace new contents: ts contents) openLabel: 'TextStreams'