[gambit-list] |read-char| without #\newline

Hendrik Boom hendrik at topoi.pooq.com
Wed Sep 4 12:23:18 EDT 2019


On Wed, Sep 04, 2019 at 12:18:41PM -0400, John Cowan wrote:
> It's probably best to use dynamic-wind, turning the settings on in the
> before-thunk and off in the after-thunk, so you don't wind up with the
> terminal set wrongly when the process terminates, like this:
> 
> (dynamic-wind (lambda () (setup-port port)) (let loop ...) (lambda ()
> (restore-port port))))

Is there a function like tty-mode-set! that reports on the current 
mode-setting so that it can be restored later?

-- hendrik

> 
> 
> On Wed, Sep 4, 2019 at 12:05 PM Marc Feeley <feeley at iro.umontreal.ca> wrote:
> 
> >
> > Marc
> >
> >
> >
> > > On Sep 4, 2019, at 11:34 AM, John Cowan <cowan at ccil.org> wrote:
> > >
> > > The buffering setting has to do with buffering within the Scheme
> > process, whereas the tty setting has to do with buffering within the
> > operating system.  In order to get single-character reads from the
> > terminal, you have to turn off both.
> >
> > Indeed.
> >
> > The tty settings can be changed by calling tty-mode-set! as shown below.
> >
> > Marc
> >
> >
> > ;;; File: console-read-one-char-at-a-time.scm
> >
> > ;; run like this:
> > ;;
> > ;;   gsi console-read-one-char-at-a-time.scm
> >
> > (define (setup port)
> >   (if (tty? port) ;; change the tty settings to read raw characters 1 at a
> > time
> >       (tty-mode-set! port
> >                      #f ;; input-allow-special
> >                      #f ;; input-echo
> >                      #t ;; input-raw
> >                      #f ;; output-raw
> >                      0))) ;; speed
> >
> > (define port (current-input-port))
> >
> > (setup port)
> >
> > (let loop ()
> >   (let ((c (read-char port)))
> >     (pp (list 'typed c))
> >     (loop)))
> >
> >
> >

> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://mailman.iro.umontreal.ca/cgi-bin/mailman/listinfo/gambit-list





More information about the Gambit-list mailing list