Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: draw prompt on the correct line after window change



On Tue, Jul 16, 2019 at 1:28 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Install some of the alternate window managers provided with the
> various OSs you have, rather than the default ones.  There's a
> plethora of them.  The main thing is one that does live redraw while
> resizing windows, rather than having you drag a window outline around
> and then snapping the window to the outline when you release the
> mouse.

Got it. So far all tests I've done were with window managers that
redraw the window continuously while it's being resized. I'll make
sure to test with those that don't redraw until the mouse button is
released.

> > This patch [is] only doing writes to the terminal without any reads.
> > Whenever ZLE prints prompt, it issues TCSAVECURSOR
>
> OK, then there is a different problem:  Nothing prevents the prompt
> itself from printing TCSAVECURSOR/TCRESTRCURSOR, and in fact some of
> the themed prompts provided with zsh do that.  There's no way for zsh
> to guarantee that the cursorsaved flag is accurate.

In my patch I attempted to not break code that stores/restores cursor.
It'll work in all the following cases:

1. The cursor is saved and restored by a foreground process.
2. The cursor is saved and restored in precmd.
3. The cursor is saved and restored in preexec.
4. The cursor is saved and restored by PROMPT and/or RPROMPT.

Cursor cannot be restored if the terminal window may have been
scrolled due to extra lines added at the bottom. This limits the
number of places where anyone can save/restore cursors. For example,
saving the cursor in precmd and restoring it in preexec won't work
because there can be new lines added in between (unless
single_line_zle is set, but in this case my patch doesn't save/restore
cursor). I _think_ my code doesn't break working code but I may be
wrong. What should I test with? Which theme(s) save and restore
cursor?

It's worth reiterating that currently prompt refresh on window change
is quite broken. Even if my patch isn't perfect, it still may be an
improvement (it is so far in all my tests).

Roman.



Messages sorted by: Reverse Date, Date, Thread, Author