Transcript

The Transcript offers a rich and interactive interface for displaying live information coming from a system. Text is only the beginning!

The API

The API is backward compatible with the existing transcript. To enable the new features, we introduced a builder. For example:

transcript nextPutAll: 'something'
  

becomes:

transcript next putAll: 'something'
  

Between next and putAll:, we can add multiple attributes to the text output.

The following example shows the complete API.

completeAPI
	<gtExample>
	| transcript |
	transcript := self transcript.
	transcript 
		nextPutAll: 'This is an example of';
		space;
		nextPutAll: 'the new GT Transcript';
		nextPut: '.';
		cr.
	transcript next
		putAll: 'Beside typical text, it can also handle:';
		cr.
	transcript next
		tab;
		color: Color blue;
		putAll: 'Colored text';
		cr.
	transcript tab.
	transcript next	
		fontSize: 20;
		putAll: 'Varying size text';
		cr.
	transcript next
		tab;
		expanding: [ BlElement new background: Color indexedColors atRandom; yourself ];
		putAll: 'Embelished with extra expansion';
		cr.
	[ 1/0 ] on: Error do: [ :err | 
		transcript next 
			tab;
			putAll: 'Exception: ';
			showException: err ].
	"transcript next 
		tab;
		italic;
		streamAll: [ transcript next putAll: 'And others ...' ]."
	^ transcript 
    

Logging an animation

To get an idea of how this tool could be useful, take a look at the following example. A Bloc animation is logged in a visual, domain centric way, providing insight far superior to plain text.

transcriptWitAnimation
	<gtExample>
	<noTest>
	| animation transcript space |
	transcript := self transcript.
	animation := self blocAnimation.
	
	space := BlSpace new.
	space host: BlHeadlessHost new.
	space addChild: animation target.
	space show.
		
	animation
		addEventHandlerOn: BlAnimationStepEvent
		do: [ :anEvent | 
			| snapshot |
			snapshot := animation target asSpartaForm.
			transcript next
				cr;
				expanded: [ BlElement new
						constraintsDo: [ :c | c textFlow pushLine ];
						size: snapshot extent;
						background: snapshot ];
				putAll: 'Animation progress:';
				space;
				putAll: anEvent progress asString.
			animation target asSpartaForm extent ];
		onFinishedDo: [ space close ].
	
	^ transcript