Skip to content
Advertisement

How to write a transparent wrapper to terminal application?

Wrapper should handle special control characters and do something but otherwise not interfere with the actual application. (trying to build a tmux like app)

So far I have the below modifying example in doc: https://docs.python.org/3/library/pty.html#example

JavaScript

The above code works but the vim opened does not cover the entire terminal window. It starts vim with reduced rows and columns bad vim

If I just type vim from the shell it works fine: good vim

Why does this occur and how to fix it? My goal is not just fix the rows and columns but the wrapper should be truely transparent except trap the special ctrl character and do some stuff. whatever tty / colors and other settings the current shell has should be passed on to the actual executable. It should work as if I typed vim. (Linux specific solution is fine. Need not work in all posix. If it needs a c extension is also fine).

Advertisement

Answer

The window size is, uniquely, a property of the PTY itself. You can get and set it using the TIOCGWINSZ and TIOCSWINSZ ioctls:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement