Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Prompt redrawing issues with wrapped prompt on SIGWINCH
- X-seq: zsh-workers 34929
- From: Daniel Hahler <genml+zsh-workers@xxxxxxxxxx>
- To: Zsh Hackers' List <zsh-workers@xxxxxxx>
- Subject: Re: Prompt redrawing issues with wrapped prompt on SIGWINCH
- Date: Sat, 18 Apr 2015 19:04:13 +0200
- Authentication-results: amavis.thequod.de (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=thequod.de
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= content-transfer-encoding:content-type:content-type:in-reply-to :references:subject:subject:mime-version:user-agent:from:from :date:date:message-id:received:received; s=postfix2; t= 1429376654; bh=Pu926bgPwpuZEJYh+mjsVJZRlVG1LmNpRHWpT3Wu+ds=; b=Y OuCDLZCQsZkOH8f2k1RzuJYs/OCohalyoSr2dFSShdA+L1GCILP9rSxNWyBOUxlB Lf/HprogWmV0ZdE9DZzMP8ADhhG6RGDqw1rYN/xn8rtvXbq+/cjYpcLlV5uuD2xY h9DjbBi5kXFskGRf+r8g31ziOK99IOQuBXa1gp0mDo=
- In-reply-to: <150418085735.ZM12718@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <55318F9F.7040204@thequod.de> <CAHYJk3Sdrg8FTbu0FJUYCdA_iTFYjAXHhH8f8QJ4fUA1==dCPA@mail.gmail.com> <150418085735.ZM12718@torch.brasslantern.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thanks for your explanations!
Some remarks: it does not only affect urxvt, but also gnome-terminal. So it's likely to
be a common issue with all terminals?!
Could this be addressed by e.g. having the terminal notify zsh about SIGWINCH before reflowing/rewrapping the text, or something similar?
> PS1=$'${(pl:COLUMNS-1::=:)}\n %# '
This suggested workaround only helps if you resize the window by one column, e.g.
when using the mouse. But modkey-h/l in awesome changes the master-window-factor
by a percent of the screen size.
I had this workaround before already, without knowing why it worked (under some
conditions). Now at least that is clearer! :)
Thanks,
Daniel.
On 18.04.2015 17:57, Bart Schaefer wrote:
> On Apr 18, 5:43am, Mikael Magnusson wrote:
> }
> } On Sat, Apr 18, 2015 at 12:56 AM, Daniel Hahler wrote:
> } >
> } > I am seeing weird redrawing issues when resizing the terminal window with the prompt at the bottom, and the prompt needs to be rewrapped.
> } >
> }
> } Urxvt reflows long lines on resize and obviously this happens before
> } zsh gets a chance to redraw the prompt. I don't know if there's any
> } possible way zle can know how the cursor moved because of this, and
> } especially difficult is to know how much the display scrolled.
>
> In fact you can see what's happening if you change your test case like
> so:
>
> PS1='${(pl:COLUMNS::=:)} %# %{$(sleep 5)%}'
>
> (I removed some unnecessary expansions and changed quoting to get rid of
> backslashes.) The above makes zsh pause for 5 seconds in the middle of
> drawing the prompt. This will allow you to see what urxvt has done with
> the display and the cursor position before zsh gets a chance to begin to
> redraw the prompt.
>
> On my system the cursor ends up near the left end of the first line of
> "======" (directly above where it was previously, the "======" having
> wrapped to two lines) when urxvt is done narrowing the window. The
> prompt redraw expects it to be at the end of the second line near the
> "%" sign, so it moves up one line before beginning to redraw.
>
> Conversely when widening the window, ZLE expects the (previously full)
> line of "=====" to have scrolled the terminal down one line because an
> "=" was printed in the lower right corner, so it again moves up before
> displaying the prompt. (Unlike the misplaced cursor, this may be a
> situation that could be fixed by comparing the previous and new values
> of $COLUMNS before deciding how many lines the prompt occupies.)
>
> You can avoid both of those problems by defining the prompt this way:
>
> PS1='${(pl:COLUMNS-1::=:)}
> %# '
>
> That is, leave one blank column at the right and insert an explicit
> newline instead of relying on urxvt to wrap at the margin. The newline
> forces urxvt to put the cursor on the correct line when narrowing, and
> the shortened line of "======" allows zsh to ignore auto-margin-wrap
> and therefore correctly compute the number of lines the prompt uses
> when widening.
>
> This can be written on one line with $'...' syntax:
>
> PS1=$'${(pl:COLUMNS-1::=:)}\n %# '
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iD8DBQFVMo6NfAK/hT/mPgARAljnAJ9jrcw/700cwDRKvzQA/HOqa8Cw6gCeKFcb
P2dRi5KptX6iJdLUZjb+aGY=
=bANY
-----END PGP SIGNATURE-----
Messages sorted by:
Reverse Date,
Date,
Thread,
Author