commentary
authorClaus Gittinger <cg@exept.de>
Sat, 11 Jan 1997 14:45:24 +0100
changeset 928 d120ad0c0422
parent 927 8cb29ec4a33f
child 929 22265f1bb110
commentary
TextColl.st
TextCollector.st
--- a/TextColl.st	Fri Jan 10 16:19:10 1997 +0100
+++ b/TextColl.st	Sat Jan 11 14:45:24 1997 +0100
@@ -19,7 +19,7 @@
 	category:'Views-Text'
 !
 
-!TextCollector  class methodsFor:'documentation'!
+!TextCollector class methodsFor:'documentation'!
 
 copyright
 "
@@ -72,7 +72,7 @@
 "
 ! !
 
-!TextCollector  class methodsFor:'instance creation'!
+!TextCollector class methodsFor:'instance creation'!
 
 newTranscript
     "create and open a new transcript.
@@ -114,7 +114,7 @@
     "Modified: 5.7.1996 / 14:04:21 / cg"
 ! !
 
-!TextCollector  class methodsFor:'defaults'!
+!TextCollector class methodsFor:'defaults'!
 
 defaultLineLimit
     "the number of lines remembered by default"
@@ -152,7 +152,7 @@
 !
 
 endEntry
-    "flush collected output"
+    "flush collected output; displaying all that has been buffered so far"
 
     |nLines lines|
 
@@ -173,7 +173,7 @@
         outstandingLines size ~~ 0 ifTrue:[
             "insert the bunch of lines - if any"
             lines := outstandingLines.
-            outstandingLines := OrderedCollection new.
+            outstandingLines := nil.
 
             nLines := lines size.
             (nLines ~~ 0) ifTrue:[
@@ -186,8 +186,9 @@
                 ].
             ].
         ].
+
         "and the last partial line - if any"
-        outstandingLine notNil ifTrue:[
+        outstandingLine size > 0 ifTrue:[
             self insertStringAtCursor:outstandingLine.
             outstandingLine := ''.
         ].
@@ -200,7 +201,7 @@
         self installDelayedUpdate
     ]
 
-    "Modified: 18.5.1996 / 15:33:26 / cg"
+    "Modified: 11.1.1997 / 14:41:32 / cg"
 !
 
 lineLimit:aNumber
@@ -212,10 +213,13 @@
 !TextCollector methodsFor:'change & update'!
 
 getListFromModel
+    "a textCollector always scrolls to the bottom"
+
      super getListFromModel.
      self scrollToBottom
 
     "Created: 12.2.1996 / 14:27:56 / stefan"
+    "Modified: 11.1.1997 / 14:41:50 / cg"
 ! !
 
 !TextCollector methodsFor:'events'!
@@ -230,17 +234,25 @@
 !TextCollector methodsFor:'initialize / release'!
 
 destroy
+    "destroy this view"
+
     destroyAction notNil ifTrue:[
-	destroyAction value
+        destroyAction value
     ].
     Processor removeTimedBlock:flushBlock.
     flushBlock := nil.
-    outstandingLines := OrderedCollection new.
+    outstandingLines := nil.
     outstandingLine := ''.
+
     super destroy
+
+    "Modified: 11.1.1997 / 14:40:30 / cg"
 !
 
 editMenu
+    "return my popUpMenu; thats the superClasses menu,
+     minus any accept item."
+
     |m idx|
 
     m := super editMenu.
@@ -251,18 +263,20 @@
     "
     idx := m indexOf:#accept.
     idx ~~ 0 ifTrue:[
-	m remove:idx.
-	(m labels at:(idx - 1)) = '-' ifTrue:[
-	    m remove:idx - 1
-	].
+        m remove:idx.
+        (m labels at:(idx - 1)) = '-' ifTrue:[
+            m remove:idx - 1
+        ].
     ].
     ^ m
+
+    "Modified: 11.1.1997 / 14:41:01 / cg"
 !
 
 initialize
     super initialize.
 
-    outstandingLines := OrderedCollection new.
+    outstandingLines := nil.
 
     flushBlock := [self endEntry].
     flushPending := inFlush := false.
@@ -274,6 +288,8 @@
     entryStream := ActorStream new.
     entryStream nextPutBlock:[:something | self nextPut:something].
     entryStream nextPutAllBlock:[:something | self nextPutAll:something]
+
+    "Modified: 11.1.1997 / 14:35:32 / cg"
 !
 
 mapped
@@ -372,8 +388,12 @@
 
     access critical:[
         collecting ifTrue:[
-            outstandingLine notNil ifTrue:[
-                outstandingLines add:outstandingLine.
+            outstandingLine notNil ifTrue:[  "/ mhmh - is never nil
+                outstandingLines isNil ifTrue:[
+                    outstandingLines := OrderedCollection with:outstandingLine
+                ] ifFalse:[
+                    outstandingLines add:outstandingLine.
+                ]
             ].
             outstandingLine := ''.
         ] ifFalse:[
@@ -389,7 +409,7 @@
         ]
     ]
 
-    "Modified: 17.9.1996 / 00:08:49 / cg"
+    "Modified: 11.1.1997 / 14:39:00 / cg"
 !
 
 doesNotUnderstand:aMessage
@@ -401,11 +421,17 @@
 !
 
 lineLength
+    "to make a textCollector (somewhat) compatible with printer
+     streams, support the lineLength query"
+
     ^ width // (font width)
+
+    "Modified: 11.1.1997 / 14:42:41 / cg"
 !
 
 nextPut:something
-    "this allows TextCollectors to be used Stream-wise"
+    "append somethings printString to my displayed text.
+     This allows TextCollectors to be used Stream-wise"
 
     (something isCharacter) ifTrue:[
         ((something == Character cr) or:[something == Character nl]) ifTrue:[
@@ -428,15 +454,16 @@
 "/    ].
 "/    device flush
 
-    "Modified: 18.5.1996 / 18:30:39 / cg"
+    "Modified: 11.1.1997 / 14:43:05 / cg"
 !
 
 nextPutAll:something
-    "this allows TextCollectors to be used Stream-wise"
+    "append all of something to my displayed text.
+     This allows TextCollectors to be used Stream-wise"
 
     ^ self show:something
 
-    "Modified: 18.5.1996 / 18:31:11 / cg"
+    "Modified: 11.1.1997 / 14:43:26 / cg"
 !
 
 show:anObject
@@ -445,6 +472,7 @@
     |aString lines|
 
     aString := anObject printString.
+
     (aString includes:(Character cr)) ifTrue:[
         lines := aString asStringCollection.
         lines keysAndValuesDo:[:nr :line |
@@ -460,7 +488,7 @@
 
     collecting ifTrue:[
         access critical:[
-            outstandingLine notNil ifTrue:[
+            outstandingLine size > 0 ifTrue:[
                 outstandingLine := outstandingLine , aString
             ] ifFalse:[
                 outstandingLine := aString
@@ -475,12 +503,16 @@
         ].
     ]
 
-    "Modified: 18.5.1996 / 15:45:00 / cg"
+    "Modified: 11.1.1997 / 14:38:43 / cg"
 ! !
 
 !TextCollector methodsFor:'transcript specials'!
 
 beTranscript
+    "make the receiver be the systemTranscript; this one
+     is accessable via the global Transcript and gets relevant
+     system messages from various places."
+
     |fg bg cFg cBg|
 
     Smalltalk at:#Transcript put:self.
@@ -490,6 +522,9 @@
     "
     self destroyAction:[Smalltalk at:#Transcript put:Stderr].
 
+    "/ user may prefer a special color for this one;
+    "/ look into the style definitions ...
+
     fg := styleSheet colorAt:'transcriptForegroundColor' default:self foregroundColor.
     bg := styleSheet colorAt:'transcriptBackgroundColor' default:self backgroundColor.
     self foregroundColor:fg backgroundColor:bg.
@@ -500,10 +535,12 @@
     self cursorForegroundColor:cFg backgroundColor:cBg. 
 
     "self lineLimit:1000. " "or whatever you think makes sense"
+
+    "Modified: 11.1.1997 / 14:44:58 / cg"
 ! !
 
-!TextCollector  class methodsFor:'documentation'!
+!TextCollector class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/TextColl.st,v 1.33 1996-09-16 22:36:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/TextColl.st,v 1.34 1997-01-11 13:45:24 cg Exp $'
 ! !
--- a/TextCollector.st	Fri Jan 10 16:19:10 1997 +0100
+++ b/TextCollector.st	Sat Jan 11 14:45:24 1997 +0100
@@ -19,7 +19,7 @@
 	category:'Views-Text'
 !
 
-!TextCollector  class methodsFor:'documentation'!
+!TextCollector class methodsFor:'documentation'!
 
 copyright
 "
@@ -72,7 +72,7 @@
 "
 ! !
 
-!TextCollector  class methodsFor:'instance creation'!
+!TextCollector class methodsFor:'instance creation'!
 
 newTranscript
     "create and open a new transcript.
@@ -114,7 +114,7 @@
     "Modified: 5.7.1996 / 14:04:21 / cg"
 ! !
 
-!TextCollector  class methodsFor:'defaults'!
+!TextCollector class methodsFor:'defaults'!
 
 defaultLineLimit
     "the number of lines remembered by default"
@@ -152,7 +152,7 @@
 !
 
 endEntry
-    "flush collected output"
+    "flush collected output; displaying all that has been buffered so far"
 
     |nLines lines|
 
@@ -173,7 +173,7 @@
         outstandingLines size ~~ 0 ifTrue:[
             "insert the bunch of lines - if any"
             lines := outstandingLines.
-            outstandingLines := OrderedCollection new.
+            outstandingLines := nil.
 
             nLines := lines size.
             (nLines ~~ 0) ifTrue:[
@@ -186,8 +186,9 @@
                 ].
             ].
         ].
+
         "and the last partial line - if any"
-        outstandingLine notNil ifTrue:[
+        outstandingLine size > 0 ifTrue:[
             self insertStringAtCursor:outstandingLine.
             outstandingLine := ''.
         ].
@@ -200,7 +201,7 @@
         self installDelayedUpdate
     ]
 
-    "Modified: 18.5.1996 / 15:33:26 / cg"
+    "Modified: 11.1.1997 / 14:41:32 / cg"
 !
 
 lineLimit:aNumber
@@ -212,10 +213,13 @@
 !TextCollector methodsFor:'change & update'!
 
 getListFromModel
+    "a textCollector always scrolls to the bottom"
+
      super getListFromModel.
      self scrollToBottom
 
     "Created: 12.2.1996 / 14:27:56 / stefan"
+    "Modified: 11.1.1997 / 14:41:50 / cg"
 ! !
 
 !TextCollector methodsFor:'events'!
@@ -230,17 +234,25 @@
 !TextCollector methodsFor:'initialize / release'!
 
 destroy
+    "destroy this view"
+
     destroyAction notNil ifTrue:[
-	destroyAction value
+        destroyAction value
     ].
     Processor removeTimedBlock:flushBlock.
     flushBlock := nil.
-    outstandingLines := OrderedCollection new.
+    outstandingLines := nil.
     outstandingLine := ''.
+
     super destroy
+
+    "Modified: 11.1.1997 / 14:40:30 / cg"
 !
 
 editMenu
+    "return my popUpMenu; thats the superClasses menu,
+     minus any accept item."
+
     |m idx|
 
     m := super editMenu.
@@ -251,18 +263,20 @@
     "
     idx := m indexOf:#accept.
     idx ~~ 0 ifTrue:[
-	m remove:idx.
-	(m labels at:(idx - 1)) = '-' ifTrue:[
-	    m remove:idx - 1
-	].
+        m remove:idx.
+        (m labels at:(idx - 1)) = '-' ifTrue:[
+            m remove:idx - 1
+        ].
     ].
     ^ m
+
+    "Modified: 11.1.1997 / 14:41:01 / cg"
 !
 
 initialize
     super initialize.
 
-    outstandingLines := OrderedCollection new.
+    outstandingLines := nil.
 
     flushBlock := [self endEntry].
     flushPending := inFlush := false.
@@ -274,6 +288,8 @@
     entryStream := ActorStream new.
     entryStream nextPutBlock:[:something | self nextPut:something].
     entryStream nextPutAllBlock:[:something | self nextPutAll:something]
+
+    "Modified: 11.1.1997 / 14:35:32 / cg"
 !
 
 mapped
@@ -372,8 +388,12 @@
 
     access critical:[
         collecting ifTrue:[
-            outstandingLine notNil ifTrue:[
-                outstandingLines add:outstandingLine.
+            outstandingLine notNil ifTrue:[  "/ mhmh - is never nil
+                outstandingLines isNil ifTrue:[
+                    outstandingLines := OrderedCollection with:outstandingLine
+                ] ifFalse:[
+                    outstandingLines add:outstandingLine.
+                ]
             ].
             outstandingLine := ''.
         ] ifFalse:[
@@ -389,7 +409,7 @@
         ]
     ]
 
-    "Modified: 17.9.1996 / 00:08:49 / cg"
+    "Modified: 11.1.1997 / 14:39:00 / cg"
 !
 
 doesNotUnderstand:aMessage
@@ -401,11 +421,17 @@
 !
 
 lineLength
+    "to make a textCollector (somewhat) compatible with printer
+     streams, support the lineLength query"
+
     ^ width // (font width)
+
+    "Modified: 11.1.1997 / 14:42:41 / cg"
 !
 
 nextPut:something
-    "this allows TextCollectors to be used Stream-wise"
+    "append somethings printString to my displayed text.
+     This allows TextCollectors to be used Stream-wise"
 
     (something isCharacter) ifTrue:[
         ((something == Character cr) or:[something == Character nl]) ifTrue:[
@@ -428,15 +454,16 @@
 "/    ].
 "/    device flush
 
-    "Modified: 18.5.1996 / 18:30:39 / cg"
+    "Modified: 11.1.1997 / 14:43:05 / cg"
 !
 
 nextPutAll:something
-    "this allows TextCollectors to be used Stream-wise"
+    "append all of something to my displayed text.
+     This allows TextCollectors to be used Stream-wise"
 
     ^ self show:something
 
-    "Modified: 18.5.1996 / 18:31:11 / cg"
+    "Modified: 11.1.1997 / 14:43:26 / cg"
 !
 
 show:anObject
@@ -445,6 +472,7 @@
     |aString lines|
 
     aString := anObject printString.
+
     (aString includes:(Character cr)) ifTrue:[
         lines := aString asStringCollection.
         lines keysAndValuesDo:[:nr :line |
@@ -460,7 +488,7 @@
 
     collecting ifTrue:[
         access critical:[
-            outstandingLine notNil ifTrue:[
+            outstandingLine size > 0 ifTrue:[
                 outstandingLine := outstandingLine , aString
             ] ifFalse:[
                 outstandingLine := aString
@@ -475,12 +503,16 @@
         ].
     ]
 
-    "Modified: 18.5.1996 / 15:45:00 / cg"
+    "Modified: 11.1.1997 / 14:38:43 / cg"
 ! !
 
 !TextCollector methodsFor:'transcript specials'!
 
 beTranscript
+    "make the receiver be the systemTranscript; this one
+     is accessable via the global Transcript and gets relevant
+     system messages from various places."
+
     |fg bg cFg cBg|
 
     Smalltalk at:#Transcript put:self.
@@ -490,6 +522,9 @@
     "
     self destroyAction:[Smalltalk at:#Transcript put:Stderr].
 
+    "/ user may prefer a special color for this one;
+    "/ look into the style definitions ...
+
     fg := styleSheet colorAt:'transcriptForegroundColor' default:self foregroundColor.
     bg := styleSheet colorAt:'transcriptBackgroundColor' default:self backgroundColor.
     self foregroundColor:fg backgroundColor:bg.
@@ -500,10 +535,12 @@
     self cursorForegroundColor:cFg backgroundColor:cBg. 
 
     "self lineLimit:1000. " "or whatever you think makes sense"
+
+    "Modified: 11.1.1997 / 14:44:58 / cg"
 ! !
 
-!TextCollector  class methodsFor:'documentation'!
+!TextCollector class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/TextCollector.st,v 1.33 1996-09-16 22:36:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/TextCollector.st,v 1.34 1997-01-11 13:45:24 cg Exp $'
 ! !