From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Peter Santoro Newsgroups: gmane.lisp.guile.user Subject: Re: non-blocking keyboard input inside customized repl Date: Wed, 29 Jan 2003 21:24:48 -0500 Organization: Peter Santoro Computing LLC Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <3E388CF0.3070505@pscomp.com> References: <3E37325F.8060805@pscomp.com> Reply-To: peter@pscomp.com NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1043892981 25246 80.91.224.249 (30 Jan 2003 02:16:21 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 30 Jan 2003 02:16:21 +0000 (UTC) Cc: guile-user@gnu.org Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18e4FW-0006Yo-00 for ; Thu, 30 Jan 2003 03:16:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18e4Gj-0003xa-05 for guile-user@m.gmane.org; Wed, 29 Jan 2003 21:17:33 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18e4GN-0003xI-00 for guile-user@gnu.org; Wed, 29 Jan 2003 21:17:11 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18e4GM-0003x1-00 for guile-user@gnu.org; Wed, 29 Jan 2003 21:17:10 -0500 Original-Received: from mtiwmhc13.worldnet.att.net ([204.127.131.117]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18e4GL-0003wj-00 for guile-user@gnu.org; Wed, 29 Jan 2003 21:17:09 -0500 Original-Received: from pscomp.com (250.hartford-03rh16rt.ct.dial-access.att.net[12.90.165.250]) by mtiwmhc13.worldnet.att.net (mtiwmhc13) with SMTP id <2003013002170711300g8bu9e>; Thu, 30 Jan 2003 02:17:07 +0000 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en Original-To: Paul Jarc In-Reply-To: X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: General Guile related discussions List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:1585 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1585 Paul Jarc wrote: >Peter Santoro wrote: > > >>I would like to be able use non-blocking keyboard input in my >>customized REPL user interface. Is there a non-blocking read-char >>available in guile, so that the ENTER key doesn't always have to be >>pressed? >> >> > >It sounds like what you want is raw terminal input. Non-blocking >input is different: it means that (read-char) will return immediately >(possibly throwing an exception) even if there is nothing to read yet. > >For raw terminal input, you'd need tcsetattr, which doesn't seem to be >directly available in Guile. But maybe you can use the readline >module to do what you want. > > >paul > > > Thanks for the suggestions. I tried the following in guile 1.6.1 and it works ok. As I'm not a scheme guru, any suggestions for improvement are welcomed. Peter (define (term:reset settings) (system (string-append "stty " settings))) (define (term:get-tty-settings) (shell-command-to-string "stty -g")) (define (term:set-raw) (system "stty -icanon -echo min 1 time 0")) (define (read-char-immediate) (if (not (isatty? (current-output-port))) (error "Not running with a tty.")) (let ((tty-settings (term:get-tty-settings))) (term:set-raw) (let ((ch (read-char))) (term:reset tty-settings) ch ))) (define (with-immediate-read-char thunk) (if (not (isatty? (current-output-port))) (error "Not running with a tty.")) (let ((tty-settings (term:get-tty-settings))) (term:set-raw) (let ((res (thunk))) (term:reset tty-settings) res ))) _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user