From 8173da5d083377cf9f7211e92e79e60941dfb8c0 Mon Sep 17 00:00:00 2001 From: John Lorentzson Date: Fri, 18 Jul 2025 17:09:17 +0200 Subject: [PATCH] Add "slow mode" to editor loosely simulating a 9600 baud serial line --- wip-duuqnd/editor/editor.lisp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wip-duuqnd/editor/editor.lisp b/wip-duuqnd/editor/editor.lisp index 66d8da9..8db382a 100644 --- a/wip-duuqnd/editor/editor.lisp +++ b/wip-duuqnd/editor/editor.lisp @@ -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)