Re: [dev] a terminal transformer, analogous to a unix filter

From: Greg Reagle <list_AT_speedpost.net>
Date: Sun, 22 Jan 2023 12:19:32 -0500

On Sat, Jan 21, 2023, at 10:29 AM, Rodrigo Martins wrote:
> This has great potential. It can simplify the terminal program while
> being very unixy.
>
> Here are some ideas for filters/transformers:
>
> - Unicode input: like composition key in the linux terminal or Xorg.
> - Lock: asks for password when locked, behaves like cat otherwise.
> - Macro: allows recording and replaying key sequences.
> - Keybinding: allows configuring key sequences to launch programs.
> - Color remover: doesn't forward escape sequences that change color.
> - Clipboard: allows copying and pasting.
> - Status bar: takes over a line of the terminal, showing system status.

Yes, exactly, if it can work. I ask myself: if it were possible to compose (pipeline), wouldn't someone have thought of it already, and done it already?

For the Unicode input example, I know there are other, probably easier and better ways to include exotic characters, but it is a good example to think of as a terminal transformer. I could write a very simple and small filter (stdin to stdout) that replaces 0x???? (where each question mark is a hex digit) with its utf-8-encoded code-point. It could be attached to the input stream and/or the output stream. Such a filter would be very easy to write, but quite useful, if it could be hooked up to a terminal emulator. Of course I would have to think of some way to escape the 0x????, i.e. send it through literally. And it would work on top of *any* terminal emulator.

What is holding me back right now is just getting the skeleton of a terminal transformer written. It would provide a pty/tty and communicate with another pty/tty (e.g. st or xterm). The skeleton program would just pass every byte through in both directions. Can anyone think of how to write this? Give some advice?
Received on Sun Jan 22 2023 - 18:19:32 CET

This archive was generated by hypermail 2.3.0 : Sun Jan 22 2023 - 19:36:07 CET