*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Mon, 11 Feb 2002 10:57:34 +0100
changeset 1016 47e190c35919
parent 1015 b03679cb8a3f
child 1017 7c2f77f5cd40
*** empty log message ***
InternalPipeStream.st
--- a/InternalPipeStream.st	Mon Feb 11 10:32:54 2002 +0100
+++ b/InternalPipeStream.st	Mon Feb 11 10:57:34 2002 +0100
@@ -7,6 +7,75 @@
 	category:'Streams'
 !
 
+!InternalPipeStream class methodsFor:'documentation'!
+
+documentation
+"
+    not useful on its own, but can be used to talk to a vt100
+    terminal view ...
+    See example.
+"
+!
+
+examples
+"
+                                                                [exBegin]
+    |p|
+
+    p := InternalPipeStream new.
+    [
+        10 timesRepeat:[
+            p nextPutLine:'hello'
+        ].
+    ] fork.
+
+    [
+        10 timesRepeat:[
+            Transcript showCR:p nextLine
+        ].
+    ] fork.
+                                                                [exEnd]
+
+                                                                [exBegin]
+    |userInput elizasOutput|
+
+    userInput    := InternalPipeStream new.
+    elizasOutput := InternalPipeStream new.
+
+    top := StandardSystemView new.
+    terminal := VT100TerminalView openOnInput: userInput output:elizasOutput in:top.
+
+    top extent:(terminal preferredExtent).
+    top label:'The doctor is in'.
+    top iconLabel:'doctor'.
+    top open.
+    top waitUntilVisible.
+
+    terminal translateNLToCRNL:true.
+    terminal inputTranslateCRToNL:true.
+    terminal localEcho:true.
+
+    elizasOutput nextPutLine:'Hi, I am Eliza'.
+    elizasOutput nextPutLine:'What is your problem ?'.
+    elizasOutput nextPutLine:''.
+    elizasOutput nextPutAll:'>'.
+
+    [top realized] whileTrue:[
+        |line answer matchingRule|
+
+        line := userInput nextLine.
+        (#('quit' 'exit' 'end' 'bye') includes:line) ifTrue:[
+            top destroy.
+            ^ self
+        ].
+
+        answer := 'Tell me more.'
+        elizasOutput nextPutLine:answer.
+        elizasOutput nextPutAll:'>'.
+    ].
+                                                                [exEnd]
+"
+! !
 
 !InternalPipeStream class methodsFor:'instance creation'!
 
@@ -65,5 +134,5 @@
 !InternalPipeStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/InternalPipeStream.st,v 1.1 2002-02-11 09:32:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/InternalPipeStream.st,v 1.2 2002-02-11 09:57:34 cg Exp $'
 ! !