Add "slow mode" to editor loosely simulating a 9600 baud serial line

This commit is contained in:
John Lorentzson 2025-07-18 17:09:17 +02:00
parent c2fde9fdd0
commit 8173da5d08

View file

@ -11,6 +11,9 @@
(require '#:sb-posix)
(defvar *eio*)
(defparameter *slow-mode-p* nil
"Slows down the sending of characters to the terminal to simulate the slow
serial connection the editor normally runs under.")
(defclass hybrid-stream (fundamental-stream)
((%input-stream :accessor input-stream :initarg :input-stream)
@ -29,7 +32,10 @@
(sb-posix:file-descriptor (output-stream stream)))
(defmethod stream-write-byte ((stream hybrid-stream) integer)
(write-byte integer (output-stream stream)))
(write-byte integer (output-stream stream))
(when *slow-mode-p*
(force-output stream)
(sleep 10/9600)))
(defmethod stream-write-char ((stream hybrid-stream) character)
(if (char= character #\Newline)