TerminalView.st
changeset 3758 59fe4398679a
parent 3225 65c338f35160
child 4028 33d2fd47db90
--- a/TerminalView.st	Mon Oct 05 16:07:10 2009 +0200
+++ b/TerminalView.st	Tue Oct 06 01:22:47 2009 +0200
@@ -89,6 +89,31 @@
     [see also:]
         TelNetTool
 "
+!
+
+example
+"
+    |terminal in out inputLine|
+
+    in := InternalPipeStream new.
+    out := InternalPipeStream new.
+
+    terminal := TerminalView openOnInput:in output:out.
+    terminal localEcho:true.
+    terminal inputTranslateCRToNL:true.
+
+    out nextPutLine:'Hello world - please type at me:'.
+
+    [
+        inputLine := in nextLine asString.
+        inputLine ~= '#exit' ifTrue:[
+            out nextPutLine:(Compiler evaluate:inputLine) printString.
+        ].
+        inputLine = '#exit'
+    ] whileFalse.
+
+    terminal topView destroy.
+"
 ! !
 
 !TerminalView class methodsFor:'initialization'!
@@ -224,7 +249,7 @@
     top iconLabel:'shell'.
     top icon:(self defaultIcon).
     top open.
-    ^ top
+    ^ scr
 
     "Modified: / 5.5.1999 / 17:25:59 / cg"
 !
@@ -585,7 +610,8 @@
         "/ send it down to inStream ...
         inStream nextPut:aKey.
         localEcho ifTrue:[
-            self nextPut:aKey
+            self nextPut:aKey.
+            self flush.
         ].
         ^ self
     ].
@@ -607,6 +633,7 @@
     ] ifFalse:[
         seq := kbdSequences at:aKey ifAbsent:nil.
     ].
+
     seq notNil ifTrue:[
         Debug ifTrue:[
             Transcript show:'->' ; showCR:seq storeString.
@@ -615,7 +642,8 @@
 
         inStream nextPutAll:seq.
         localEcho ifTrue:[
-            self nextPutAll:seq
+            seq do:[:k | self nextPut:k].
+            self flush.
         ].
         ^ self
     ].
@@ -645,9 +673,9 @@
 
     seq := kbdSequences at:rawKey ifAbsent:nil.
     seq notNil ifTrue:[
-    Debug ifTrue:[
-        Transcript show:'->' ; showCR:seq storeString.
-    ].
+        Debug ifTrue:[
+            Transcript show:'->' ; showCR:seq storeString.
+        ].
         inStream nextPutAll:(seq withEscapes).
         ^ self
     ].
@@ -1111,6 +1139,7 @@
             ] do:[
                 |n sensor|
 
+                Delay waitForSeconds:0.01.
                 outStream readWait.
                 sensor := self sensor.
                 (sensor notNil and:[sensor hasKeyPressEventFor:self]) ifTrue:[
@@ -1918,7 +1947,11 @@
 !TerminalView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.127 2007-04-10 14:36:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.128 2009-10-05 23:22:47 cg Exp $'
+!
+
+version_CVS
+    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.128 2009-10-05 23:22:47 cg Exp $'
 ! !
 
 TerminalView initialize!