[Openmcl-devel] Quick Query...

Gary Byers gb at clozure.com
Thu Nov 11 06:55:14 PST 2004



On Thu, 11 Nov 2004, Doug Philips wrote:

> Hey all,
>    I'm at a loss for where to look to find out
> how I can do non-blocking I/O, esp. how I can put "stdin" (the keyboard) into unbuffered/raw
> mode (from the command line, I'm not interested in writing GUI code, just not having to wait for a return/enter to get character input)... having grunged over the docs and having been unable to formulate a google query with useful results... Can anyone give me a quick URL, pointer, ?
> Thanks,
>      Doug
>

There's some code for manipulating TTY modes in "ccl:library;pty.lisp".

? (require "PTY")

? (ccl::disable-tty-local-modes 0 #$ICANON)
T

will turn off "input canonicalization" on file descriptor 0, which is
at least part of what you need to do here.  (That basically turns off
the line-buffering/line-editing that the OS does.)


(Of course, that only has an effect if the file descriptor is a TTY/PTY
device.)

If the #$ICANON mode is disabled, you can do things like:

? (progn (read-char) (read-char))
a
#\a

(where the first READ-CHAR consumes the newline, which isn't really
necessary to make the reader happy anymore.)  So, you can do:

? (read-char)
#\Space

(where there's a space after the close-paren) without having to type
a newline.







More information about the Openmcl-devel mailing list