On with-raw-mode & friends GÃ¶ran Weinholt 07 Oct 2019 20:55 UTC
I've updated the SRFI 170 implementation in Loko Scheme wrt draft #7 and
I think it covers everything now. However, I ran into difficulties while
implementing with-raw-mode, with-rare-mode and without-echo.
The draft says that they are based on dynamic-wind. However,
dynamic-wind handlers are run when Loko switches between tasks. There do
not even need to be multiple tasks using the terminal for this to cause
problems, because the exit handlers are run when switching from the task
to the scheduler. This means that the terminal modes are restored to
normal while the scheduler is active, which is when the user is typing.
Thus without-echo can be working fine, but the text is still echoed.
For now I've used with-exception-handler in a way that ensures that the
terminal is restored if the thunk exits normally or through an
exception. Maybe there is some big hole in this idea, but it will at
least not interfere with the intended usage:
| The general paradigm for using the following procedures is to set up
| your application, then run it in the proc provided to them, a
| procedure that takes the same port arguments in the same order as the
| containing with- or without- procedure.
| The without-echo procedure is an exception in that it's generally used
| to enter a password or passphrase. The procedures return the values
| that proc returns.
The drafts are looking better and better.