commander-s/scheme/tty-debug.scm

25 lines
510 B
Scheme

(define debug-mode #f)
(define *tty-port* #f)
(define (init-tty-debug-output!)
(and debug-mode
(call-with-values
open-pty
(lambda (input-port name)
(set! *tty-port* (dup->outport input-port))
(close input-port)
(set-port-buffering *tty-port* bufpol/block 8192)
name))))
(define debug-message
(lambda args
(if (and debug-mode *tty-port*)
(with-current-output-port*
*tty-port*
(lambda ()
(for-each write args)
(newline)
(flush-tty/output *tty-port*))))))