]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.tools.listener: read-unsafe for interactor†
authorJoe Groff <arcata@gmail.com>
Thu, 13 Oct 2011 18:42:45 +0000 (11:42 -0700)
committerJoe Groff <arcata@gmail.com>
Tue, 18 Oct 2011 04:23:04 +0000 (21:23 -0700)
†there's a failing test with this patch that needs investigation:

===
resource:basis/ui/tools/listener/listener-tests.factor: 90

Unit Test: { [ t ] [ "promise" get 2 seconds ?promise-timeout text = ] }

wait-timeout
===

basis/ui/tools/listener/listener.factor

index 22d897238f863d30905b73811773c1df400fb1cf..f07116d7cbc966834e7c3a70c677d5ea3426da9a 100644 (file)
@@ -23,6 +23,7 @@ IN: ui.tools.listener
 ! evaluate-input resumes the thread.
 TUPLE: interactor < source-editor
 output history flag mailbox thread waiting token-model word-model popup ;
+INSTANCE: interactor noncopying-reader
 
 : register-self ( interactor -- )
     <mailbox> >>mailbox
@@ -150,15 +151,14 @@ M: interactor stream-readln
         3bi
     ] if ;
 
-M: interactor stream-read
-    swap [
-        drop ""
-    ] [
-        [ interactor-read dup [ "\n" join ] when ] dip short head
+M:: interactor stream-read-unsafe ( n buf interactor -- count )
+    n [ 0 ] [
+        interactor interactor-read dup [ "\n" join ] when
+        n short head-slice 0 buf copy
     ] if-zero ;
 
-M: interactor stream-read-partial
-    stream-read ;
+M: interactor stream-read-partial-unsafe
+    stream-read-unsafe ; inline
 
 M: interactor stream-read1
     dup interactor-read {