[racket] buffer mode

From: Thomas Chust (chust at web.de)
Date: Sun Aug 15 17:00:12 EDT 2010

2010/8/15 Richard Mittel <rich.mittel at gmail.com>:
> I'm trying to get read-char to read a character as soon as it is typed, but
> read-char insists on buffering the input until a carriage return is
> entered.  The Racket reference says that the buffer mode is controlled by
> file-stream-buffer-mode, but it seems to have no effect.  (More confusingly,
> the doc says that line buffering, which I think is the behavior I'm seeing,
> is not allowed on input ports.)
> [...]

Hello Richard,

at least in Unix environments, line buffering of direct user input is
usually done by the terminal device, ie. at a stage in the pipeline
before the Racket interpreter ever gets to see the input.

To change this behaviour, your program would have to call tcsetattr(3)
from the POSIX C library or invoke the external utility program
stty(1) on the terminal file descriptor before reading input from it.

Some time ago I wrote a small module that can do the latter, which I
attach to this message for your reference.


When C++ is your hammer, every problem looks like your thumb.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: terminal.ss
Type: application/octet-stream
Size: 1434 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100815/199691ad/attachment.obj>

Posted on the users mailing list.