From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7296 invoked by alias); 18 Dec 2013 06:43:45 -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: 32146 Received: (qmail 19890 invoked from network); 18 Dec 2013 06:43:39 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <131217224337.ZM20989@torch.brasslantern.com> Date: Tue, 17 Dec 2013 22:43:37 -0800 X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Simulating ZLE_RPROMPT_INDENT=0 MIME-version: 1.0 Content-type: text/plain; charset=us-ascii I wrote: > Src/Zle/zle_refresh.c:moveto() knows that the last character that was > output for the right-prompt was in the rightmost column. What it does > not know is whether that left the cursor AT the rightmost column, or > whether it wrapped around to the next line. For terminals like xterm where the line doesn't wrap until the *next* character is output, one can do something like this: zmodload zsh/terminfo RPS1="${RPS1%?}%{${(M)RPS1%?}${terminfo[cub1]}%}" What this does is: - Tell ZLE that $RPS1 is one character shorter than it really is, by putting the last character inside %{ %} - Include a "move back one" sequence after that last character; when this is output, the terminal will silently swallow it without moving the cursor. Thus there's a way to create the ZLE_RPROMPT_INDENT=0 behavior in almost any version of zsh, if your terminal works in the "right" way. I believe we concluded some years ago that it's not possible to reliably tell from termcap/terminfo descriptions whether this sort of trick will work, which is why moveto() is written the way it is. However, as we have now made ZLE_RPROMPT_INDENT the user's responsibility, we could simply assume that if ZLE_RPROMPT_INDENT=0, then printing the cub1 sequence will do the right thing. (An extra check could be that the cub1 sequence is not backspace or del.) To do this would require that rprompt_off be available in moveto(), which likely means it needs to become global like vln and vcs. It's rather inefficient anyway to be looking up the value of ZLE_RPROMPT_INDENT every time zrefresh() is called; it ought to be handled like LINES/COLUMNS.