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

From: <suckless_AT_lists.clunk.work>
Date: Fri, 27 Jan 2023 04:56:44 +0000

------- Original Message -------
On Sunday, January 22nd, 2023 at 09:19, Greg Reagle - list at speedpost.net <gykvvajasvicdwbqwbtcevf_AT_simplelogin.co> wrote:


> ------------------------------
> 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?

In an unrelated search I was looking at the `script` utility. My understanding is that it acts as a proxy in addition to logging the session to file. Perhaps investigating the source code [1] would help with the proxy aspect?

[1] https://github.com/util-linux/util-linux/blob/ec96a89ed9551ffacfc58b3056c8070444e3a2f3/term-utils/script.c
Received on Fri Jan 27 2023 - 05:56:44 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 27 2023 - 06:36:27 CET