Gambit’s runtime system automatically sets the tty mode to what it was when the tty was first used. So this is not needed.
However, if the program crashes (a situation that couldn’t be caught with dynamic-wind BTW) then I hope you can spell “reset” at the shell with no echo…
Marc
On Sep 4, 2019, at 12:23 PM, Hendrik Boom hendrik@topoi.pooq.com wrote:
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@iro.umontreal.ca wrote:
Marc
On Sep 4, 2019, at 11:34 AM, John Cowan cowan@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@iro.umontreal.ca https://mailman.iro.umontreal.ca/cgi-bin/mailman/listinfo/gambit-list
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://mailman.iro.umontreal.ca/cgi-bin/mailman/listinfo/gambit-list