hmm we solved that by changing the behavior of stdin before
launching the vm. so you get character by character input, otherwise
stdin is only flushed on lf...

see the starter script from coral.


On 2012-11-13, at 10:01, Pavel Krivanek <[email protected]> wrote:
> Hi,
> 
> is there a way how to use nonblocking input from stdin? I have a
> simple REPL but the stdin is blocking the VM.
> 
> | stdin input lineEnd |
> 
> stdin := FileStream stdin ifNil: [ ^ self ].
> stdin atEnd  ifTrue: [ ^ self ].
> 
> [
>  lineEnd := false.
>  FileStream stdout nextPutAll: '> '.
>  input := String streamContents: [:s|
>  [ stdin atEnd or: [lineEnd] ] whileFalse: [
>        stdin next ifNotNilDo: [:char|
>        char = Character lf ifTrue: [lineEnd := true].
>        s nextPut: char ]]].
> 
>  [ FileStream stdout print: (Compiler evaluate: input); lf ]
>      ifError: [:error | FileStream stdout nextPutAll: 'ERROR: ',
> error asString; lf].
> 
>  Processor yield.
> ] repeat
> 
> Cheers,
> -- Pavel
> 


Reply via email to