[plt-scheme] basic question about display + read + threads

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Feb 15 00:17:48 EST 2005

On Feb 15, Psy-Kosh wrote:
> is there any way to do something like that, but in such a way that
> instead of, say, when typing text on the read line, ending up with
> "ThHI!is is the teHI!xt I aHI!m enteHI!ring", all the text entry
> line and all the text already on it gets "pushed down" a line each
> time text is displayed, so that instead the text in the display
> thread will always display above the input line, as opposed to in
> the middle of it?

This is not a problem of MzScheme, but a problem of the terminal.  The
same will happen if you use any program that spits out stuff in the
background.  One solution for this is to not use a terminal, but some
program that will do things properly.  DrScheme looks a little
confusing but it gets the job done.  If you want a more `raw'
interface, you can use shell mode in Emacs.  In both of these cases,
typing does not actually go to the program untill you hit enter, and
in the meanwhile the program (DrScheme or Emacs) knows to show the
output in the same place while collecting your input afterwards.

Another possible solution is to redirect the error output someplace
else and look at that using some other tool -- you can actually do
that with any file, not just the error output.  For example, when
debugging complex programs, I sometimes do something like this --
define a debug printf function:

  (define (dprintf fmt . args)
    (with-output-to-file "/tmp/debug"
      (lambda () (apply printf fmt args))

Then I'll start one `debug' terminal and run "tail -f /tmp/debug" in
it.  Finally, I run my program in the original window and all
debugging output is shown in the debug terminal.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.