The Trunk: Collections-mt.626.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-mt.626.mcz

commits-2
Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.626.mcz

==================== Summary ====================

Name: Collections-mt.626
Author: mt
Time: 1 May 2015, 8:10:29.695 pm
UUID: e8f27fe3-f480-8244-92bb-a23d8f61fd20
Ancestors: Collections-mt.625

Added the (configurable) possibility to disable forced transcript updates as well as to enable a generic redirection to stdout.

Only works when using the #show: or #showln: interface in Transcript.

=============== Diff against Collections-mt.625 ===============

Item was changed:
  WriteStream subclass: #TranscriptStream
  instanceVariableNames: 'lastChar'
+ classVariableNames: 'AccessSema ForceUpdate RedirectToStdOut'
- classVariableNames: 'AccessSema'
  poolDictionaries: ''
  category: 'Collections-Streams'!
 
  !TranscriptStream commentStamp: 'fbs 12/30/2013 09:53' prior: 0!
  This class is a much simpler implementation of Transcript protocol that supports multiple views and very simple conversion to morphic.  Because it inherits from Stream, it is automatically compatible with code that is designed to write to streams.!

Item was added:
+ ----- Method: TranscriptStream class>>forceUpdate (in category 'preferences') -----
+ forceUpdate
+
+ <preference: 'Force transcript updates to screen'
+ categoryList: #(printing morphic debug)
+ description: 'When enabled, transcript updates will immediately shown in the screen no matter how busy the UI process is.'
+ type: #Boolean>
+ ^ ForceUpdate ifNil: [true]!

Item was added:
+ ----- Method: TranscriptStream class>>forceUpdate: (in category 'preferences') -----
+ forceUpdate: aBoolean
+
+ ForceUpdate := aBoolean.!

Item was changed:
+ ----- Method: TranscriptStream class>>new (in category 'instance creation') -----
- ----- Method: TranscriptStream class>>new (in category 'as yet unclassified') -----
  new
  ^ self on: (String new: 1000)
  "
  INSTALLING:
  TextCollector allInstances do:
  [:t | t breakDependents.
  t become: TranscriptStream new].
 
  TESTING: (Execute this text in a workspace)
  Do this first...
  tt := TranscriptStream new.
  tt openLabel: 'Transcript test 1'.
  Then this will open a second view -- ooooh...
  tt openLabel: 'Transcript test 2'.
  And finally make them do something...
  tt clear.
  [Sensor anyButtonPressed] whileFalse:
  [1 to: 20 do: [:i | tt print: (2 raisedTo: i-1); cr; endEntry]].
  "!

Item was changed:
+ ----- Method: TranscriptStream class>>newTranscript: (in category 'instance creation') -----
- ----- Method: TranscriptStream class>>newTranscript: (in category 'as yet unclassified') -----
  newTranscript: aTextCollector
  "Store aTextCollector as the value of the system global Transcript."
  Smalltalk at: #Transcript put: aTextCollector!

Item was added:
+ ----- Method: TranscriptStream class>>redirectToStdOut (in category 'preferences') -----
+ redirectToStdOut
+ <preference: 'Redirect transcript to stdout'
+ categoryList: #(printing morphic debug)
+ description: 'When enabled, no Morphic is needed when using the transcript interface to debug.'
+ type: #Boolean>
+ ^ RedirectToStdOut ifNil: [false]!

Item was added:
+ ----- Method: TranscriptStream class>>redirectToStdOut: (in category 'preferences') -----
+ redirectToStdOut: aBoolean
+
+ RedirectToStdOut := aBoolean.!

Item was changed:
  ----- Method: TranscriptStream>>endEntry (in category 'stream extensions') -----
  endEntry
  "Display all the characters since the last endEntry, and reset the stream"
  self semaphore critical:[
+ self class forceUpdate
+ ifTrue: [self changed: #appendEntry]
+ ifFalse: [self changed: #appendEntryLater].
- self changed: #appendEntry.
  self reset.
  ].!

Item was changed:
  ----- Method: TranscriptStream>>show: (in category 'stream extensions') -----
+ show: anObject
+ "TextCollector compatibility"
+
+ [
+ self target nextPutAll: anObject asString.
+ self endEntry
+ ] on: FileWriteError do: [self class redirectToStdOut: false].!
- show: anObject  "TextCollector compatibility"
- self nextPutAll: anObject asString; endEntry!

Item was changed:
  ----- Method: TranscriptStream>>showln: (in category 'stream extensions') -----
+ showln: anObject
+ "TextCollector compatibility. Ensure a new line before inserting a message."
+
+ [
+ self target
+ cr;
+ nextPutAll: anObject asString.
+ self endEntry.
+ ] on: FileWriteError do: [self class redirectToStdOut: false].!
- showln: anObject  "TextCollector compatibility"
- self nextPutAll: anObject asString; cr ;  endEntry!

Item was added:
+ ----- Method: TranscriptStream>>target (in category 'stream extensions') -----
+ target
+
+ ^ self class redirectToStdOut
+ ifTrue: [FileStream stdout]
+ ifFalse: [self]!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.626.mcz

marcel.taeumel (old)
We should think about moving TranscriptStream out of the Collections package because of its dependencies.

Best,
Marcel