Re: [dev] [st] Patch/feature request - redraw terminal on resize

From: Markus Wichmann <>
Date: Sun, 25 Oct 2020 08:52:00 +0100

On Sat, Oct 24, 2020 at 07:44:43PM +0100, Daniel Littlewood wrote:
> Hi all,
> I have noticed a feature from tmux that I would like to have in vanilla st.
> The behaviour is that when the screen resizes, the window is redrawn
> to fit the new size.
> In vanilla st, if I make the window smaller then output that was
> previously drawn there is blank.

st implements the terminal screen as a 2D array of character cells
(slightly more complex than that). On resize, it reallocates that array
to fit the new dimensions, and all the cells that are now off-screen are
lost. Other terminal emulators implement the terminal screen as an array
of lines, and resizing merely has the effect of moving the line break.
There are pros and cons to either approach, really.

> If I'm running a program like "man" in the terminal, then the lines
> are broken in a strange place and I have to restart it to get them
> correct.

man formats the manpages with a troff pipeline. Redrawing the screen
would mean re-running the pipeline.

> This sounds like the perfect sort of thing for a patch, but I can't
> see anything in the patches section of the FAQ about this idea.
> Does anybody know if such a patch exists, or where to start
> implementing it myself?

If I understand you correctly, tmux is doing something on resize that
you would like to see in st itself. That means, you have to figure out
what it is tmux is doing on resize that affects the applications running
in st, and then add that behavior into st. I am guessing it is reacting
to SIGWINCH somehow, but for instance man-db does not react to that
signal. and the pager itself is not powerful enough to re-run the troff
pipeline. My guess would be that tmux pushes a CTRL-L into the input
pipeline, as that is the line feed character, and that usually causes
TUI applications to redraw. but those are merely educated guesses.

Received on Sun Oct 25 2020 - 08:52:00 CET

This archive was generated by hypermail 2.3.0 : Sun Oct 25 2020 - 09:00:08 CET