From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29205 invoked by alias); 18 Apr 2015 15:57:46 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34927 Received: (qmail 10373 invoked from network); 18 Apr 2015 15:57:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=GgkJGa8JTgbSkPKRp3gpTiZl/b3dPMayHJEPQFg3xx8=; b=Itp1KmpeAolAmiaEFFEub2aSiGWngmJsiZu4mcA5rpiuCMyCRX5P724Qnhs959NhDm godfcW1NqXwlDGE2Pc+AS1Fm4t3zALf0HKISCl1DJotS8HxOVP2aLQXqrk+xtproZPnE wdVupXnOVYIm7weaQcp5xmzF4v5xGnz6l7jR1FZyDlGfkSz3iZpIK9BgJxKHTOY/u3Gi mnFOH0BwSMLoq9091haxWBHaZU7flUWLgzCkMpALdG5MxUEXwhm33PMtup+MpTFEPa3L k5mh1zufIRTYIvdn/Tq7T1PuNeknTvn+lOc0eEhzALL6G4BA+ZHv3mrPiBYizkBRYKzZ YxGg== X-Gm-Message-State: ALoCoQmuSgjM9JBYJXrhUo29NR5VT7Qy7tAJTM/nTd18EFw4egCVuYDM9IbV0RJRIvVkHcTWitLD X-Received: by 10.182.153.74 with SMTP id ve10mr7366668obb.54.1429372659342; Sat, 18 Apr 2015 08:57:39 -0700 (PDT) From: Bart Schaefer Message-Id: <150418085735.ZM12718@torch.brasslantern.com> Date: Sat, 18 Apr 2015 08:57:35 -0700 In-Reply-To: Comments: In reply to Mikael Magnusson "Re: Prompt redrawing issues with wrapped prompt on SIGWINCH" (Apr 18, 5:43am) References: <55318F9F.7040204@thequod.de> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "Zsh Hackers' List" Subject: Re: Prompt redrawing issues with wrapped prompt on SIGWINCH MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 18, 5:43am, Mikael Magnusson wrote: } } On Sat, Apr 18, 2015 at 12:56 AM, Daniel Hahler } wrote: } > -----BEGIN PGP SIGNED MESSAGE----- } > Hash: SHA1 } > } > 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 %# '