From 5a73f91fa2f713e0cc783012c0380cdf03611fd5 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Thu, 21 Jun 1990 22:11:52 +0000 Subject: [PATCH] Change console-input-port so that it always buffers the input. Because of this change there is no need to use the special terminal input primitives -- these should be flushed from the microcode. All buffered input channels now support the `interval' argument of the `char-ready?' operation. --- v7/src/runtime/io.scm | 38 +++++++++++++++++++------------------- v7/src/runtime/runtime.pkg | 7 ++++--- v7/src/runtime/version.scm | 4 ++-- v8/src/runtime/runtime.pkg | 7 ++++--- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/v7/src/runtime/io.scm b/v7/src/runtime/io.scm index b8ba7b9a9..f980f624d 100644 --- a/v7/src/runtime/io.scm +++ b/v7/src/runtime/io.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/io.scm,v 14.6 1990/06/20 20:29:20 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/io.scm,v 14.7 1990/06/21 22:11:38 cph Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -261,13 +261,6 @@ MIT in each case. |# ((ucode-primitive file-set-position 2) (channel-descriptor channel) position)) -(define (terminal-read-char channel) - ((ucode-primitive terminal-read-char 1) (channel-descriptor channel))) - -(define (terminal-char-ready? channel delay) - ((ucode-primitive terminal-char-ready? 2) (channel-descriptor channel) - delay)) - (define (terminal-buffered? channel) ((ucode-primitive terminal-buffered? 1) (channel-descriptor channel))) @@ -503,17 +496,24 @@ MIT in each case. |# (and (not (negative? n)) (+ (input-buffer/chars-available buffer) n)))))) -(define (input-buffer/char-ready? buffer) - (char-ready? buffer - (lambda (buffer) - (case (channel-blocking? (input-buffer/channel buffer)) - ((#F) - (input-buffer/fill buffer)) - ((#T) - (with-channel-blocking (input-buffer/channel buffer) - false - (lambda () (input-buffer/fill buffer)))) - (else false))))) +(define (input-buffer/char-ready? buffer interval) + (let ((fill + (if (positive? interval) + (lambda () + (let ((timeout (+ (real-time-clock) interval))) + (let loop () + (cond ((input-buffer/fill buffer) true) + ((< (real-time-clock) timeout) (loop)) + (else false))))) + (lambda () + (input-buffer/fill buffer))))) + (char-ready? buffer + (lambda (buffer) + (let ((channel (input-buffer/channel buffer))) + (case (channel-blocking? channel) + ((#F) (fill)) + ((#T) (with-channel-blocking channel false fill)) + (else false))))))) (define (char-ready? buffer fill) (let ((end-index (input-buffer/end-index buffer))) diff --git a/v7/src/runtime/runtime.pkg b/v7/src/runtime/runtime.pkg index ae1958354..2a2658208 100644 --- a/v7/src/runtime/runtime.pkg +++ b/v7/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/runtime.pkg,v 14.67 1990/06/20 20:29:56 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/runtime.pkg,v 14.68 1990/06/21 22:11:42 cph Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -1318,15 +1318,16 @@ MIT in each case. |# output-buffer/write-string-block tty-output-channel) (export (runtime console-input) + channel-type=file? channel-type=terminal? + input-buffer/channel input-buffer/char-ready? + input-buffer/peek-char input-buffer/read-char make-input-buffer terminal-buffered terminal-buffered? - terminal-char-ready? terminal-nonbuffered - terminal-read-char tty-input-channel) (initialization (initialize-package!))) diff --git a/v7/src/runtime/version.scm b/v7/src/runtime/version.scm index 329dfc37b..cc0a8dec4 100644 --- a/v7/src/runtime/version.scm +++ b/v7/src/runtime/version.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/version.scm,v 14.82 1990/06/20 20:37:44 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/version.scm,v 14.83 1990/06/21 22:11:52 cph Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -45,7 +45,7 @@ MIT in each case. |# '())) (add-system! microcode-system) (add-event-receiver! event:after-restore snarf-microcode-version!) - (add-identification! "Runtime" 14 82)) + (add-identification! "Runtime" 14 83)) (define microcode-system) diff --git a/v8/src/runtime/runtime.pkg b/v8/src/runtime/runtime.pkg index a4dc7ab86..074e826c8 100644 --- a/v8/src/runtime/runtime.pkg +++ b/v8/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/runtime.pkg,v 14.67 1990/06/20 20:29:56 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/runtime.pkg,v 14.68 1990/06/21 22:11:42 cph Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -1318,15 +1318,16 @@ MIT in each case. |# output-buffer/write-string-block tty-output-channel) (export (runtime console-input) + channel-type=file? channel-type=terminal? + input-buffer/channel input-buffer/char-ready? + input-buffer/peek-char input-buffer/read-char make-input-buffer terminal-buffered terminal-buffered? - terminal-char-ready? terminal-nonbuffered - terminal-read-char tty-input-channel) (initialization (initialize-package!))) -- 2.25.1