[talk] Receiving the output of a terminal

Thomas Levine _ at thomaslevine.com
Wed Jul 12 05:59:38 EDT 2017


How can I receive the output of a tty in another program? Or, perhaps
an easier way of asking this: is there good documentation on how to
implement a terminal emulator?

To give you an idea of what I am looking for, it could naïvely sort of
make sense that the following procedure would accomplish what I want.
Inside the sending virtual terminal, run this.

  ln -s $(tty) /tmp/tty
  
Then, inside the receiving program, run this

  cat /tmp/tty

Of course it does not do what I want, probably because both the first
terminal and the cat are consuming output of the tty.



I want this so I can improve my screen reader software. In the present
implementation I have patched script(1) so that output to the file is
less buffered and so that header and footer messages are not printed.
https://thomaslevine.com/scm/tsh/artifact/ab625a43ee958dba

Then I send the output from the resulting patched script(1) to a FIFO,
and I read from the FIFO into espeak.
https://thomaslevine.com/scm/tsh/artifact/75f981520a431d96

I think I should be able to implement this far more simply by reading
directly from an ordinary tty rather than using script(1).

My present implementation is still much better than that of any other
screen reader that I am aware of. Mine is far simpler than all the
others that I have read about because the others all implement
unnecessary non-standard alternatives to things that already already
exist in shells or in Unix-style programs that can easily be called from
shells. The main benefit of doing this without patching script(1) is
thus to make it easier to port to other systems.



More information about the talk mailing list